Embedded Cryptography 2
Embedded Cryptography 2
Cryptography
Cryptography
Embedded Cryptography 2 4
DES – Data Encryption Standard
Embedded Cryptography 2 5
DES – Data Encryption Standard
DES History
• in 1973 NIST (then NBS) issued request for proposals for a national
cipher standard
• IBM already developed Lucifer cipher
– by team led by Feistel in late 60’s
– used 64-bit data blocks with 128-bit key
• 1974, IBM submits Lucifer
• Lucifer is analyzed and redesigned by NSA and others, and becomes
DES
• 1977, the new cryptosystem becomes the federal standard in USA
(till Nov. 2001).
• Some variants of DES (we’ll discuss them later) still very much in use.
Embedded Cryptography 2 6
DES – Data Encryption Standard
DES encryption algorithm is block cipher and uses a 64-bit block and a 64-bit
encryption key (of which only 56 bits are actively used in the encryption
process). Unfortunately DES has been around for a long time, and the 56-bit
version is now easily crackable (in less than a day, on fairly modest
equipment).
An enhancement, and one which is still fairly compatible with DES, is the 3-
DES algorithm. It has three phases, and splits the key into two. Overall the key
size is typically 112 bits (2x54 bits - with a combination of the three keys - of
which two of the keys are typically the same). The algorithm is
EncryptK3( DecryptK2( EncryptK1(message), where K1 and K3 are typically the
same (to keep compatibility).
Embedded Cryptography 2 8
DES – Data Encryption Standard
Embedded Cryptography 2 10
DES – Data Encryption Standard
The Operations of f Function
• E(Li)=E(011001)=E(01010101) (Expander)
• S-boxes
S1 101 010 001 110 011 100 111 000
001 100 110 010 000 111 101 011
S2 100 000 110 101 111 001 011 010
101 011 000 111 110 010 001 100
The input for an S-box has 4 bits. The first
bit specifies which row will be used: 0 for 1st
Embedded Cryptography 2 11
DES – Data Encryption Standard
Embedded Cryptography 2 12
DES – Data Encryption Standard
Encryption
[1
Embedded Cryptography]2 14
DES – Data Encryption Standard
Encryption (cont.)
64-bit plaintext (X)
Embedded Cryptography 2 16
DES – Data Encryption Standard
(Key Generation)
[1
Embedded Cryptography 2 18
]
DES – Data Encryption Standard
Encryption (Round) (cont.)
Li-1 Ri-1
Expansion/permutation (E_table)
XOR Ki
F Substitution/choice (S-box)
Permutation (P)
XOR
Li Embedded Cryptography 2
Ri 19
DES – Data Encryption Standard
S-box
[1
Embedded Cryptography 2 20
]
DES – Data Encryption Standard
Encryption (Round) (cont.)
• Separate plaintext as L0R0
– L0: left half 32 bits of plaintext
– R0: right half 32 bits of plaintext
• Expansion/permutation: E( )
•
•
•
Substitution/choice: S-box( )
Permutation: P( ) F
• Ri Li 1 ~ P ( S _ box ( E ( Ri 1 ) ~ Keyi ))
Li Ri 1
Embedded Cryptography 2 21
DES – Data Encryption Standard
Expansion Expansion
Embedded Cryptography 2 22
DES – Data Encryption Standard
[1
Embedded Cryptography 2 23]
DES – Data Encryption Standard
Key Generation
(Encryption)
Embedded Cryptography 2
[1 24
]
DES – Data Encryption Standard
(cont.)
Permuted Choice One (PC-1)
C0 D0
▪ ▪
▪ ▪
▪ ▪
Ci-1 Di-1
Permuted Choice Two (PC-2)
Schedule of Left Shifts
Keyi
Ci Di
Embedded Cryptography 2 25
DES – Data Encryption Standard
Key Generation (cont.)
• Original Key: Key0
• Permuted Choice One: PC_1( )
• Permuted Choice Two: PC_2( )
• Schedule of Left Shift: SLS( )
•
( C 0 , D0 ) PC _ 1( Key 0 )
•
( Ci , Di ) SLS ( Ci 1 , Di 1 )
•
Keyi PC _ 2( SLS (Ci 1 , Di 1 ))
Embedded Cryptography 2 26
DES – Data Encryption Standard
Decryption
• The same algorithm as
encryption.
• Reversed the order of key
(Key16, Key15, … Key1).
• For example:
– IP undoes IP-1 step of
encryption.
– 1st round with SK16 undoes
16th encrypt round.
[1
Embedded Cryptography 2
]27
DES – Data Encryption Standard
https://github.com/kevinoconnor7/Simplified-DES
Embedded Cryptography 2 28
DES – Data Encryption Standard
Strength of DES
• Criticism
– Reduction in key size of 72 bits
• Too short to withstand with brute-force attack
– S-boxes were classified.
• Weak points enable NSA to decipher without key.
• 56-bit keys have 256 = 7.2 x 1016 values
– Brute force search looks hard.
– A machine performing one DES encryption per
microsecond would take more than a thousand year to
break the cipher.
Embedded Cryptography 2 29
DES – Data Encryption Standard
Strength of DES (cont.)
Embedded Cryptography 2 30
DES – Data Encryption Standard
Embedded Cryptography 2 31
DES – Data Encryption Standard
Linear Cryptanalysis
https://www.tutorialspoint.com/cryptography/advanced_encryption_standard.htm
Embedded Cryptography 2 36
AES Advanced Encryption Standard
• AES is an iterative.
• It is based on ‘substitution–permutation network’. It comprises
of a series of linked operations, some of which involve replacing
inputs by specific outputs (substitutions) and others involve
shuffling bits around (permutations).
• Interestingly, AES performs all its computations on bytes rather
than bits.
• Hence, AES treats the 128 bits of a plaintext block as 16 bytes.
• These 16 bytes are arranged in four columns and four rows for
processing as a matrix −
• Unlike DES, the number of rounds in AES is variable and
depends on the length of the key.
• AES uses 10 rounds for 128-bit keys, 12 rounds for 192-bit keys
and 14 rounds for 256-bit keys. Each of these rounds uses a
different 128-bit round key, which is calculated from the original
AES key.
Embedded Cryptography 2 37
AES Advanced Encryption Standard
The schematic of AES structure is given in the following illustration:
Embedded Cryptography 2 38
AES Advanced Encryption Standard
Encryption Process
Each round comprise of four sub-processes. The first round process is depicted below:
Byte Substitution (SubBytes)
The 16 input bytes are substituted by looking up
a fixed table (S-box) given in design. The result
is in a matrix of four rows and four columns.
Shiftrows
Each of the four rows of the matrix is shifted to the
left. Any entries that ‘fall off’ are re-inserted on the
right side of row. Shift is carried out as follows −
•First row is not shifted.
•Second row is shifted one (byte) position to the left.
•Third row is shifted two positions to the left.
•Fourth row is shifted three positions to the left.
•The result is a new matrix consisting of the same 16
bytes but shifted with respect to each other.
MixColumns
Each column of four bytes is now transformed using a special mathematical function. This function
takes as input the four bytes of one column and outputs four completely new bytes, which replace
the original column. The result is another new matrix consisting of 16 new bytes. It should be
noted that this step is not performed in the last round.
Addroundkey
The 16 bytes of the matrix are now considered as 128 bits and are XORed to the 128 bits of the
round key. If this is the last round then the output is the ciphertext. Otherwise, the resulting 128
bits are interpreted as 16 bytes and we begin another
Embedded similar
Cryptography 2 round. 39
AES Advanced Encryption Standard
Decryption Process
Embedded Cryptography 2 41
Cryptographic Attacks
Embedded Cryptography 2 42
Cryptographic Attacks
Embedded Cryptography 2 43
Cryptographic Attacks
Main weakness of DES – Key Size
$300K 60
Embedded Cryptography 2 46
Cryptographic Attacks
• Ciphertext Only Attacks (COA) − In this method, the attacker has
access to a set of ciphertext(s). He does not have access to
corresponding plaintext. COA is said to be successful when the
corresponding plaintext can be determined from a given set of
ciphertext. Occasionally, the encryption key can be determined from
this attack. Modern cryptosystems are guarded against ciphertext-
only attacks.
Embedded Cryptography 2 47
Cryptographic Attacks
• Known Plaintext Attack (KPA) − In this method, the attacker knows
the plaintext for some parts of the ciphertext. The task is to decrypt the
rest of the ciphertext using this information. This may be done by
determining the key or via some other method. The best example of this
attack is linear cryptanalysis against block ciphers.
Embedded Cryptography 2 48
Cryptographic Attacks
• Chosen Plaintext Attack (CPA) − In this method, the attacker has the
text of his choice encrypted. So he has the ciphertext-plaintext pair of his
choice. This simplifies his task of determining the encryption key. An
example of this attack is differential cryptanalysis applied against block
ciphers as well as hash functions. A popular public key cryptosystem,
RSA is also vulnerable to chosen-plaintext attacks.
Embedded Cryptography 2 49
Cryptographic Attacks
• Dictionary Attack − This attack has many variants, all of which involve
compiling a ‘dictionary’. In simplest method of this attack, attacker builds a
dictionary of ciphertexts and corresponding plaintexts that he has learnt over a
period of time. In future, when an attacker gets the ciphertext, he refers the
dictionary to find the corresponding plaintext.
Embedded Cryptography 2 50
Cryptographic Attacks
• Brute Force Attack (BFA) − In this method, the attacker tries to determine
the key by attempting all possible keys. If the key is 8 bits long, then the
number of possible keys is 28 = 256. The attacker knows the ciphertext and the
algorithm, now he attempts all the 256 keys one by one for decryption. The
time to complete the attack would be very high if the key is long.
Embedded Cryptography 2 51
Cryptographic Attacks
Embedded Cryptography 2 52
Cryptographic Attacks
• Man in Middle Attack (MIM) − The targets of this attack are mostly
public key cryptosystems where key exchange is involved before
communication takes place.
• Host A wants to communicate to host B, hence requests public key
of B.
• An attacker intercepts this request and sends his public key instead.
• Thus, whatever host A sends to host B, the attacker is able to read.
• In order to maintain communication, the attacker re-encrypts the
data after reading with his public key and sends to B.
• The attacker sends his public key as A’s public key so that B takes it
as if it is taking it from A.
Embedded Cryptography 2 53
Cryptographic Attacks
• Side Channel Attack (SCA) − This type of attack is not against any
particular type of cryptosystem or algorithm. Instead, it is launched to
exploit the weakness in physical implementation of the cryptosystem.
Embedded Cryptography 2 54
Cryptographic Attacks
• Timing Attacks − They exploit the fact that different computations
take different times to compute on processor. By measuring such
timings, it is be possible to know about a particular computation the
processor is carrying out. For example, if the encryption takes a longer
time, it indicates that the secret key is long.
Embedded Cryptography 2 55
Cryptographic Attacks
• Power Analysis Attacks − These attacks are similar to timing attacks
except that the amount of power consumption is used to obtain
information about the nature of the underlying computations.
Embedded Cryptography 2 56
Cryptographic Attacks
• Fault analysis Attacks − In these attacks, errors are induced in the
cryptosystem and the attacker studies the resulting output for useful
information.
Embedded Cryptography 2 57