3 - Intro To Modern Crypto
3 - Intro To Modern Crypto
Comment 7.
8.
each stage is easily reversible
decryption uses keys in reverse order
s on AES 9. decryption does recover plaintext
10. final round has only 3 stages
Substitute Bytes
a simple substitution of each byte
uses one table of 16x16 bytes containing a permutation of all 256 8-bit
values
each byte of state is replaced by byte indexed by row (left 4-bits) &
column (right 4-bits)
eg. byte {86} is replaced by byte in row 8 column 6
which has value {2A}
S-box constructed using defined transformation of values in GF(28)
designed to be resistant to all known attacks
• We now turn to a discussion of each of the four transformations used
in AES. For each stage, we mention the forward (encryption)
algorithm, the inverse (decryption) algorithm, and the rationale for
the design of that stage.
• The Substitute bytes stage uses an S-box to perform a byte-by-byte
substitution of the block. There is a single 8-bit wide S-box used on
every byte. This S-box is a permutation of all 256 8-bit values,
constructed using a transformation which treats the values as
polynomials in GF(28) – however it is fixed, so really only need to
know the table when implementing. Decryption requires the inverse
of the table. These tables are given in Stallings Table 5.2.
• The table was designed to be resistant to known cryptanalytic
attacks. Specifically, the Rijndael developers sought a design that
has a low correlation between input bits and output bits, with the
property that the output cannot be described as a simple
mathematical function of the input, with no fixed points and no
“opposite fixed points”.
Shift Rows
a circular byte shift in each row
1st row is unchanged
2nd row does 1 byte circular shift to left
3rd row does 2 byte circular shift to left
4th row does 3 byte circular shift to left
decrypt inverts using shifts to right
since state is processed by columns, this step permutes bytes
between the columns
• The ShiftRows stage provides a simple “permutation” of the
data, whereas the other steps involve substitutions. Further,
since the state is treated as a block of columns, it is this step
which provides for diffusion of values between columns. It
performs a circular rotate on each row of 0, 1, 2 & 3 places for
respective rows. When decrypting it performs the circular shifts
in the opposite direction for each row. This row shift moves an
individual byte from one column to another, which is a linear
distance of a multiple of 4 bytes, and ensures that the 4 bytes of
one column are spread out to four different columns.
Mix Columns
• Lastly is the Add Round Key stage which is a simple bitwise XOR of the
current block with a portion of the expanded key. Note this is the only step
which makes use of the key and obscures the result, hence MUST be
used at start and end of each round, since otherwise could undo effect of
other steps. But the other steps provide confusion/diffusion/non-linearity.
That us you can look at the cipher as a series of XOR with key then
scramble/permute block repeated. This is efficient and highly secure it is
believed.
AES Key Expansion
takes 128-bit (16-byte) key and expands into array of 44/52/60 32-bit words
start by copying key into first 4 words
then loop creating words that depend on values in previous & 4 places back
in 3 of 4 cases just XOR these together
1st word in 4 has rotate + S-box + XOR round constant on previous, before XOR 4th
back
The AES key expansion algorithm takes as input a 4-word (16-byte) key and
produces a linear array of words, providing a 4-word round key for the initial
AddRoundKey stage and each of the 10/12/14 rounds of the cipher. It
involves copying the key into the first group of 4 words, and then constructing
subsequent groups of 4 based on the values of the previous & 4th back
words. The first word in each group of 4 gets “special treatment” with rotate +
S-box + XOR constant on the previous word before XOR’ing the one from 4
back. In the 256-bit key/14 round version, there’s also an extra step on the
middle word. The text includes in section 5.4 pseudocode that describes the
key expansion.
Key Expansion Rationale
• designed to resist known attacks
• design criteria included
• knowing part key insufficient to find many more
• invertible transformation
• fast on wide range of CPU’s
• use round constants to break symmetry
• diffuse key bits into round keys
• enough non-linearity to hinder analysis
• simplicity of description
• The Rijndael developers designed the expansion key algorithm to be
resistant to known cryptanalytic attacks. It is designed to be simple to
implement, but by using round constants break symmetries, and make it
much harder to deduce other key bits if just some are known (but once
have as many consecutive bits as are in key, can then easily recreate the
full expansion). The design criteria used are listed above.
Private-Key Cryptography
traditional private/secret/single key cryptography uses one key
shared by both sender and receiver
if this key is disclosed communications are compromised
also is symmetric, parties are equal
hence does not protect sender from receiver forging a message & claiming is
sent by sender
The development of public-key cryptography is the greatest and perhaps the only true revolution in the entire
history of cryptography. From its earliest beginnings to modern times, virtually all cryptographic systems have
been based on the elementary tools of substitution and permutation, and can be classed as private/secret/single
key (symmetric) systems. All classical, and modern block and stream ciphers are of this form.
Why Public-Key Cryptography?
• developed to address two key issues:
• key distribution – how to have secure communications in general without having to trust a KDC with your key
• digital signatures – how to verify a message comes intact from the claimed sender
• public invention due to Whitfield Diffie & Martin Hellman at Stanford Uni in 1976
• known earlier in classified community
• The concept of public-key cryptography evolved from an attempt to attack two of the most difficult
problems associated with symmetric encryption: key distribution and digital signatures. The first
problem is that of key distribution, which under symmetric encryption requires either (1) that two
communicants already share a key, which somehow has been distributed to them; or (2) the use of a
key distribution center. This seemed to negated the very essence of cryptography: the ability to
maintain total secrecy over your own communication. The second was that of "digital signatures." If the
use of cryptography was to become widespread, not just in military situations but for commercial and
private purposes, then electronic messages and documents would need the equivalent of signatures
used in paper documents.
• The idea of public key schemes, and the first practical scheme, which was for key distribution only, was
published in 1976 by Diffie & Hellman. The concept had been previously described in a classified report
in 1970 by James Ellis (UK CESG) - and subsequently declassified [ELLI99]. Its interesting to note that
they discovered RSA first, then Diffie-Hellman, opposite to the order of public discovery! There is also a
claim that the NSA knew of the concept in the mid-60’s [SIMM93].
Public-Key Cryptography
• probably most significant advance in the 3000 year history of cryptography
• uses two keys – a public & a private key
• asymmetric since parties are not equal
• uses clever application of number theoretic concepts to function
• complements rather than replaces private key crypto
• Will now discuss the radically different public key systems, in which two keys are used. Public-key
cryptography provides a radical departure from all that has gone before. The development of public-key
cryptography is the greatest and perhaps the only true revolution in the entire history of cryptography. It is
asymmetric, involving the use of two separate keys, in contrast to symmetric encryption, that uses only
one key. Anyone knowing the public key can encrypt messages or verify signatures, but cannot decrypt
messages or create signatures, counter-intuitive though this may seem. The use of two keys has
profound consequences in the areas of confidentiality, key distribution, and authentication. It works by the
clever use of number theory problems that are easy one way but hard the other. Note that public key
schemes are neither more nor less secure than private key (security depends on the key size for both),
nor do they replace private key schemes (they are too slow to do so), rather they complement them. Both
also have issues with key distribution, requiring the use of some suitable protocol.
Public-Key Cryptography
public-key/two-key/asymmetric cryptography involves
the use of two keys:
a public-key, which may be known by anybody, and can be
used to encrypt messages, and verify signatures
a related private-key, known only to the recipient, used to
decrypt messages, and sign (create) signatures
infeasible to determine private key from public
is asymmetric because
those who encrypt messages or verify signatures cannot
decrypt messages or create signatures
• Asymmetric algorithms rely on one key for encryption and a different
but related key for decryption. These algorithms have the following
important characteristic:
• • It is computationally infeasible to determine the decryption key
given only knowledge of the cryptographic algorithm and the
encryption key.
• In addition, some algorithms, such as RSA, also exhibit the following
characteristic:
• • Either of the two related keys can be used for encryption, with the
other used for decryption.
• Anyone knowing the public key can encrypt messages or verify
signatures, but cannot decrypt messages or create signatures,
thanks to some clever use of number theory.
Public-Key Cryptography
• Stallings Figure 9.1a “Public-Key Cryptography”, shows that a public-key encryption scheme has six
ingredients:
• • Plaintext: the readable message /data fed into the algorithm as input.
• • Encryption algorithm: performs various transformations on the plaintext.
• • Public and private keys: a pair of keys selected so that if one is used for encryption, the other is
used for decryption. The exact transformations performed by the algorithm depend on the public or
private key that is provided as input.
• • Ciphertext: the scrambled message produced as output. It depends on the plaintext and the key.
For a given message, two different keys will produce two different ciphertexts.
• • Decryption algorithm: accepts the ciphertext and matching key and produces the original plaintext.
• Consider the following analogy using padlocked boxes: traditional schemes involve the sender
putting a message in a box and locking it, sending that to the receiver, and somehow securely also
sending them the key to unlock the box. The radical advance in public key schemes was to turn this
around, the receiver sends an unlocked box (their public key) to the sender, who puts the message
in the box and locks it (easy - and having locked it cannot get at the message), and sends the
locked box to the receiver who can unlock it (also easy), having the (private) key. An attacker would
have to pick the lock on the box (hard).
Symmetric
vs Public-
Key
Public-Key Cryptosystems
• Stallings Figure 9.4 “Public-Key Cryptosystems: Secrecy and Authentication” illustrates the
essential elements of a public-key encryption scheme.
• Note that public-key schemes can be used for either secrecy or authentication, or both (as shown
here). There is some source A that produces a message in plaintext X The M elements of X are
letters in some finite alphabet. The message is intended for destination B. B generates a related
pair of keys: a public key, PUb, and a private key, PRb. PRb is known only to B, whereas PUb is
publicly available and therefore accessible by A. With the message X and the encryption key PUb
as input, A forms the ciphertext Y = E(PUb, X) The intended receiver, in possession of the matching
private key, is able to invert the transformation: X = D(PRb, Y) An adversary, observing Y and
having access to PUb, but not having access to PRb or X, must attempt to recover X and/or PRb.
This provides confidentiality. Can also use a public-key encryption to provide authentication: Y =
E(PRa, X); X = D(PUa, Y) To provide both the authentication function and confidentiality have a
double use of the public-key scheme (as shown here): Z = E(PUb, E(PRa, X)) X = D(PUa, D(PRb,
Z)) In this case, separate key pairs are used for each of these purposes. The receiver owns and
creates secrecy keys, sender owns and creates authentication keys.
• In practice typically DO NOT do this, because of the computational cost of public-key schemes.
Rather encrypt a session key which is then used with a block cipher to encrypt the actual message,
and separately sign a hash of the message as a digital signature - this will be discussed more later.
Public-Key Applications
c = 0; f = 1
for i = k downto 0
do c = 2 x c
f = (f x f) mod n
if bi == 1 then
c = c + 1
f = (f x a) mod n
return f
Efficient Encryption