Unit II CNS
Unit II CNS
Syllabus: Introduction to Secret key and cryptography, Encrypt given messages using DES, AES, IDEA,
Problems on cryptography algorithms, Principles, finite fields, stream cipher, block cipher modes of operation,
DES, Triple DES, AES, IDEA, RC5, key distribution.
Definition
In cryptography, a private or secret key is an encryption/decryption key known only to the that
exchange secret messages.
In traditional secret key cryptography, a key would be shared by the communicators so that each could
encrypt and decrypt messages.
Given a message (called plaintext) and the key, encryption produces unintelligible data “ciphertext”,
which is about the same length as the plaintext was. Decryption is the reverse of encryption, and uses
the same key as encryption
Secret key cryptography involves the use of a single key.
The risk in this system is that if either party loses the key or it is stolen, the system is broken.
Secret key cryptography is sometimes referred to as conventional cryptography or symmetric
cryptography.
1. In symmetric encryption - the two parties to an exchange must share the same key, and that key
must be protected from access by others.
2. Frequent key changes are usually desirable to limit the amount of data compromised if an attacker
learns the key.
3. Therefore, the strength of any cryptographic system rests with the key distribution technique, a term
that refers to the means of delivering a key to two parties who wish to exchange data without
allowing others to see the key.
4. For two parties A and B, key distribution can be achieved in a number of ways, as follows -
i. A can select a key and physically deliver it to B.
ii. A third party can select the key and physically deliver it to A and B.
iii. If A and B have previously and recently used a key, one party can transmit the new
key to the other, encrypted using the old key.
iv. If A and B each has an encrypted connection to a third party C, C can deliver a key on
the encrypted links to A and B.
• Options (i) and (ii) call for manual delivery of a key. For link encryption, this is a reasonable
requirement, because each link encryption device is going to be exchanging data only with its partner
on the other end of the link.
• For end-to-end encryption over a network, manual delivery is not desirable. In a distributed
system, any given host or terminal may need to engage in exchanges with many other hosts and
terminals over time.
Thus, each device needs a number of keys supplied dynamically.
• If end-to-end encryption is done at a network or IP level, then a key is needed for each pair of hosts
on the network that wish to communicate.
• Option (iii) is a possibility for either link encryption or end-to- end encryption, but if an attacker ever
succeeds in gaining access to one key, then all subsequent keys will be revealed.
• Option (iv) refers to a scenario where a key distribution center is responsible for distributing keys
to pairs of users (hosts, processes, applications) as needed. Each user must share a unique key with
the key distribution center for purposes of key distribution
Groups
❑ A group is denoted by -
❑ Group is a set of elements with a binary operation denoted by “.”that associates to each
ordered pair (a, b) of elements in an element (a .b) in G, such that the following axioms are
obeyed
❑ The order of the group is equal to the number of elements in the group.
❑ When the group operation is addition, the identity element is 0; the inverse element of a is – a;
and subtraction is defined with the following rule
Fields
❑ A field is denoted by –
❑ Field is a set of elements with two binary operations, called addition and multiplication, such
that for all a,b,c in F the following axioms are obeyed –
❑ A field is a set in which we can do addition, subtraction, multiplication, and division without
leaving the set. Division is defined with the following rule a/b = a(b-1)
Stream Cipher
• A stream cipher is one that encrypts a digital data stream one bit or one byte at a time.
• A stream cipher is a symmetric encryption algorithm in which ciphertext output is produced bit-
by-bit or byte-by-byte from a stream of plaintext input. The most widely used such cipher is
RC4.
• Figure above is a diagram of stream cipher structure using pseudorandom number generator.
• In this structure, a key is input to a pseudorandom bit generator that produces a stream of 8-bit
numbers that are apparently random. The output of the generator, called a keystream, is
combined one byte at a time with the plaintext stream using the bitwise exclusive-OR (XOR)
operation.
• Following are the important design considerations for a stream cipher –
– The encryption sequence should have a large period. A pseudorandom number generator
uses a function that produces a deterministic stream of bits that eventually repeats.
Thelonger the period of repeat the more difficult it will be to do cryptanalysis.
– The keystream should have the properties of a true random number stream. For
example, there should be an approximately equal number of 1s and 0s.
Block Cipher
• A block cipher is one in which a block of plaintext is treated as a whole and used to produce a
ciphertext block of equal length. Typically, a block size of 64 or 128 bits is used.
• When multiple blocks of plaintext are encrypted using the same key, a number of security issues
arise.
• A mode of operation is a technique for enhancing the effect of a cryptographic algorithm or
adapting the algorithm for an application, such as applying a block cipher to a sequence of data
blocks or a data stream.
• To apply a block cipher in a variety of applications, five modes of operation have been defined –
❑ The Data Encryption Standard (DES) is a symmetric-key block cipher published by the National
Institute of Standards and Technology (NIST).
❑ S-DES encryption (decryption) algorithm takes 8-bit block of plaintext (ciphertext) and a 10-bit
key, and produces 8-bit ciphertext (plaintext) block.
❑ Encryption algorithm involves 5 functions
– an initial permutation (IP);
– a complex function fK, which involves both permutation and substitution and depends on
a key input;
– a simple permutation function that switches (SW) the 2 halves of the data;
– the function fK again;
– a permutation function that is the inverse of the initial permutation (IP-1).
The algorithm begins with an Add round key stage followed by 9 rounds of four stages and a
tenth round of three stages. This applies for both encryption and decryption with the exception
that each stage of a round the decryption algorithm is the inverse of it’s counterpart in the
encryption algorithm.
❑ takes 128-bit (16-byte) key and expands into array of 44/52/60 32-bits words
❑ The AES key expansion algorithm takes as input a 4-word key. Each word contains 32 bits
which means each subkey is 128 bits long.
❑ The key is copied into the first four words of the expanded key.
❑ Each added word w[i] depends on the immediately preceding word, w[i − 1], and the word four
positions back w[i − 4].
❑ In three out of four cases, a simple XOR is used. For a word whose position in the w array is a
multiple of 4, a more complex function is used. The function g consists of the following
subfunctions -
RotWord performs a one-byte circular left shift on a word. This means that an input word
[b0, b1, b2, b3] is transformed into [b1, b2, b3, b0].
❑ The block cipher IDEA encrypts a 64-bit block of plain text and a 64-bit of cipher text, and a
128-bit key controls it. The algorithm consists of eight identical rounds plus a half round
for output transformation.
❑ The fundamental design in IDEA is the use of the mixing of three in compatible algebraic
groups: bit-by-bit XOR, addition modulo 216, and multiplication modulo 216+1.
❑ The plain text is a fixed size (64-bit block) that is divided into four 16-bit blocks (X1|| X2|| X3||
X4). The key is a 128-bit block that is divided into eight 16-bit sub keys.
❑ The division into 16 bits is because all of the algebraic operations used in the encryption and
decryption process operate at 16-bit numbers. The last output round is four 16- bit sub keys.
❑ Each round uses six 16-bit sub keys and the remaining two sub keys are used in the next round
by implementing left shifting by 25 positions. The total sub keys is 52 {52=8 rounds*6 sub keys
+ (4 sub keys “output transformation”)}.
❑ The decryption process is an essential process that is applied on cipher text to transform it into
the original message (plaintext). The computational process for the decryption is the same as that
used for the encryption of the plain text. The difference compared to the encryption is that the
16-bit subkeys are generated in reverse order.
RC5 Ciphers
❑ using 12 rounds
❑ Three main operations: + mod 2w, XOR, circular left shift <<<, and there inverses used.
❑ L0 = A + S[0];
❑ R0 = B + S[1];
❑ for i = 1 to r do
❑ RC5-CBC-PAD, is CBC with padding by bytes with value being the number of
padded bytes
❑ RC5-CTS, a variant of CBC which is the same size as the original message, uses
ciphertext stealing to keep size same as original