NSC Full Notes
NSC Full Notes
A stream cipher is one that encrypts a digital data stream one bit or one byte at
a time.
Examples of classical stream ciphers are the autokeyed Vigenère cipher and the
Vernam cipher.
In the ideal case, a one-time pad version of the Vernam cipher wouldbe used, in
which the keystream (Ki) is as long as the plaintext bit stream (Pi). If the
cryptographic keystream is random, then this cipher is unbreakable by anymeans
other than acquiring the keystream.
The logic of a general substitution cipher for A 4-bit input produces one of 16
possible input states, which is mapped by thesubstitution cipher into a unique
one of 16 possible output states, each of which isrepresented by 4 ciphertext
bits.
A block cipher is designed by considering its three critical aspects which are
listed as below:
1. Number of Rounds
2. Design of Function F
3. Key Schedule Algorithm
1. Number of Rounds
The number of rounds judges the strength of the block cipher algorithm. It is
considered that more is the number of rounds, difficult is for cryptanalysis to
break the algorithm.
2. Design of Function F
The function F of the block cipher must be designed such that it must be
impossible for any cryptanalysis to unscramble the substitution. The criterion
that strengthens the function F is it non-linearity.
More the function F is nonlinear, more it would be difficult to crack it. Well,
while designing the function F it should be confirmed that it has a good
avalanche property which states that a change in one-bit of input must reflect
the change in many bits of output.
It is suggested that the key schedule should confirm the strict avalanche effect
and bit independence criterion.
BLOWFISH ALGORITHM
1. blockSize: 64-bits
2. keySize: 32-bits to 448-bits variable size
3. number of subkeys: 18 [P-array]
4. number of rounds: 16
5. number of substitution boxes: 4 [each having 512 entries of 32-bits each]
Now each of the subkey is changed with respect to the input key as:
The resultant P-array holds 18 subkeys that is used during the entire
encryption process
Step3: Encryption:
This mode is a most straightforward way of processing a series of sequentially listed message
blocks.
Operation
• The user takes the first block of plaintext and encrypts it with the key
to produce the first block of ciphertext.
• He then takes the second block of plaintext and follows the same process
with same key and so on so forth.
For example, if a ciphertext from the ECB mode is known to encrypt a salary
figure, then a small number of trials will allow an attacker to recover the figure.
In general, we do not wish to use a deterministic cipher, and hence the ECB
mode should not be used in most applications.
Operation
The operation of CBC mode is depicted in the following illustration. The steps
are as follows −
• Load the n-bit Initialization Vector (IV) in the top register. • XOR the
n-bit plaintext block with data value in top register. • Encrypt the result
of XOR operation with underlying block cipher with key K.
It is worth mentioning that CBC mode forms the basis for a well-known data
origin authentication mechanism. Thus, it has an advantage for those
applications that require both symmetric encryption and data origin
authentication.
In this mode, each ciphertext block gets ‘fed back’ into the encryption process
in order to encrypt the next plaintext block.
Operation
The operation of CFB mode is depicted in the following illustration. For example,
in the present system, a message block has a size ‘s’ bits where 1 < s < n. The CFB
mode requires an initialization vector (IV) as the initial random n-bit input block.
The IV need not be secret. Steps of operation are –
CFB has a very strange feature. In this mode, user decrypts the ciphertext
using only the encryption process of the block cipher. The decryption algorithm
of the underlying block cipher is never used.
Apparently, CFB mode is converting a block cipher into a type of stream cipher.
The encryption algorithm is used as a key-stream generator to produce key
stream that is placed in the bottom register. This key stream is then XORed
with the plaintext as in case of stream cipher.
By converting a block cipher into a stream cipher, CFB mode provides some of
the advantageous properties of a stream cipher while retaining the
advantageous properties of a block cipher.
It involves feeding the successive output blocks from the underlying block
cipher back to it. These feedback blocks provide string of bits to feed the
encryption algorithm which act as the key-stream generator as in case of CFB
mode.
The key stream generated is XOR-ed with the plaintext blocks. The OFB mode
requires an IV as the initial random n-bit input block. The IV need not be secret.
Operation
Both encryption and decryption in CTR mode are depicted in the following
illustration. Steps in operation are −
• Load the initial counter value in the top register is the same for both the
sender and the receiver. It plays the same role as the IV in CFB (and CBC)
mode.
• Encrypt the contents of the counter with the key and place the result in
the bottom register.
STREAM CIPHERS
A typical stream cipher encrypts plaintext one byte at a time, although a stream
cipher may be designed to operate on one bit at a time or on units larger than a
byteat a time. A key is input to a pseudorandom bit generator that produces a
stream of8-bit numbers that are apparently random. The output of the
generator, called akeystream, is combined one byte at a time with the plaintext
stream using the bit-wise exclusive-OR (XOR) operation. For example, if the
next byte generated by thegenerator is 01101100 and the next plaintext byte is
11001100, then the resultingciphertext byte is
sequence
RC4
RC4 is a stream cipher designed in 1987 by Ron Rivest for RSA Security. It is a
variable key size stream cipher with byte-oriented operations. The algorithm is
based onthe use of a random permutation. Analysis shows that the period of the
cipher is overwhelmingly likely to be greater than 10100. Eight to sixteen machine
operations are required per output byte, and the cipher can be expected to run
veryquickly in software. RC4 is used in the Secure Sockets Layer/Transport
Layer Security(SSL/TLS) standards that have been defined for communication
between Webbrowsers and servers.
The RC4 algorithm is remarkably simple and quite easy to explain. A variable
length key of from 1 to 256 bytes (8 to 2048 bits) is used to initialize a 256-
bytestate vector S, with elementsS[0],S[1],S[2],. . . . . S[255].
Initialization of S
To begin, the entries are set equal to the values from 0 through 255 in
ascendingorder; that is, S[0],S[1],S[2],. . . . . S[255]=255.
Cryptography and Network Security, Dept. of CSE, AITS 67
A temporary vector, T, is alsocreated. If the length of the key K is 256 bytes,
then T is transferred to T. Otherwise,for a key of length keylen bytes, the first
keylen elements of T are copied from K,and then K is repeated as many times as
necessary to fill out T. These preliminaryoperations can be summarized as
Stream Generation
Once the S vector is initialized, the input key is no longer used. Stream
generationinvolves cycling through all the elements of S[i] , and for each S[i],
swapping S[i] withanother byte in S according to a scheme dictated by the
current configuration of S.After S[255]is reached, the process continues,
starting over again at S[0].
/* Stream Generation */
i, j = 0;
while (true)
i = (i + 1) mod 256;
j = (j + S[i]) mod 256;
Swap (S[i], S[j]);
t = (S[i] + S[j]) mod 256;
k = S[t];
The most powerful and most common approach to securing the points of
vulnerability highlighted in the preceding section is encryption. If encryption is
to be used to counter these attacks, then we need to decide what to encrypt and
The second problem that Diffie pondered, and one that was apparentlyunrelated
to the first, was that of digital signatures.
A public key encryption scheme has the following ingredients which are as follows
1. Each user generates a pair of keys to be used for the encryption and
decryption of messages.
2. Each user places one of the two keys in a public register or other accessible
file. This is the public key.The companion key is kept private. As in Figure
suggests, each user maintains a collection of public keys obtained from others.
4. When Alice receives the message, she decrypts it using her private key. No
other recipient can decrypt the message because only Alice knows Alice’sprivate
key.
Cryptography and Network Security, Dept. of CSE, AITS 72
• The computation of the pair of keys i.e. private key and the public key must
be easy.
• Knowing the encryption algorithm and public key of the intended receiver,
computation of cipher text must be easy.
• For a receiver of the message, it should be computationally easy to decrypt
the obtained cipher text using his private key.
• It is also required that any opponent in the network knowing the public key
should be unable to determine its corresponding private key.
• Having the cipher text and public key an opponent should be unable to
determine the original message.
RSA ALGORITHM
In this algorithm two keys were used. One is private key and another one is
public key.
Cryptography and Network Security, Dept. of CSE, AITS 74
Diffie–Hellman Key Exchange/Agreement Algorithm
In this scheme the two parties, who want to communicatesecurely, can agree on
a symmetric key using this technique. This key can then be used for encryption/
decryption. However, we must note that Diffie–Hellman key exchange algorithm
can be used only forkey agreement, but not for encryption or decryption of
messages. Once both the parties agree on the keyto be used, they need to use
other symmetric key encryption algorithms for actual encryption or decryption
of messages.
Cryptography
and Network Security, Dept. of CSE, AITS 76
Example of the Algorithm
ELAGAMAL CRYPTOGRAPHY (ECC)
In this ECC we have three phases
1. Key generation
2. Encryption
3. Decryption