mod 2
mod 2
Disadvantages of CBC –
● Parallel encryption is not possible since every encryption requires a previous cipher.
.
Cipher Feedback Mode
● In this mode the cipher is given as feedback to the next block of encryption with some new
specifications: first, an initial vector IV is used for first encryption and output bits are divided as a set
of s and b-s bits.
● The left-hand side s bits are selected along with plaintext bits to which an XOR operation is applied.
● The result is given as input to a shift register having b-s bits to lhs,s bits to rhs and the process
continues.
● The encryption and decryption process for the same is shown below, both of them use encryption
algorithms.
● Advantages of CFB –
○ Since, there is some data loss due to the use of shift register, thus it is difficult for applying
cryptanalysis.
● Disadvantages of using CFB –
○ The drawbacks of CFB are the same as those of CBC mode. Both block losses and concurrent
encryption of several blocks are not supported by the encryption. Decryption, however, is
parallelizable and loss-tolerant.
Output Feedback Mode
● The output feedback mode follows nearly the same process as the Cipher Feedback mode
except that it sends the encrypted output as feedback instead of the actual cipher which is
XOR output.
● In this output feedback mode, all bits of the block are sent instead of sending selected s
bits.
● The Output Feedback mode of block cipher holds great resistance towards bit transmission
errors. It also decreases the dependency or relationship of the cipher on the plaintext.
Advantages of OFB –
● In the case of CFB, a single bit error in a block is propagated to all subsequent blocks.
This problem is solved by OFB as it is free from bit errors in the plaintext block.
Disadvantages of OFB-
● The drawback of OFB is that, because to its operational modes, it is more susceptible to a
message stream modification attack than CFB.
Counter Feedback Mode
● The Counter Mode or CTR is a simple counter-based block cipher implementation.
● Every time a counter-initiated value is encrypted and given as input to XOR with plaintext which
results in ciphertext block.
● The CTR mode is independent of feedback use and thus can be implemented in parallel.
Advantages of Counter –
● Since there is a different counter value for each block, the direct plaintext and ciphertext
relationship is avoided. This means that the same plain text can map to different ciphertext.
● Parallel execution of encryption is possible as outputs from previous stages are not chained as
in the case of CBC.
Disadvantages of Counter-
● The fact that CTR mode requires a synchronous counter at both the transmitter and the receiver
is a severe drawback. The recovery of plaintext is erroneous when synchronisation is lost.
ADVANCED ENCRYPTION STANDARD
● The Advanced Encryption Standard (AES) was published by the National
Institute of Standards and Technology (NIST) in 2001.
● AES is a symmetric block cipher that is intended to replace DES.
● It can work with three key sizes-128,192,256 bits,
● AES is considered highly secure due to its long key sizes and is still used in
industries.
● Based on the key length i.e 16, 24, or 32 bytes (128, 192, or 256 bits),the
algorithm is referred to as AES-128, AES-192, or AES-256.
ADVANCED ENCRYPTION STANDARD
● Figure 6.1 shows the overall structure of the AES encryption process. The
cipher takes a plaintext block size of 128 bits, or 16 bytes.
● The input to the encryption and decryption algorithms is a single 128-bit block.
● This block is depicted as a 4 * 4 square matrix of bytes. This block is copied
into the State array, which is modified at each stage of encryption or
decryption.
● After the final stage, State is copied to an output matrix. These operations are
depicted in Figure 6.2a.
● Similarly, the key is depicted as a square matrix of bytes. This key is then
expanded into an array of key schedule words. Figure 6.2b shows the
expansion for the 128-bit key. Each word is four bytes, and the total key
schedule is 44 words for the 128-bit key.
ADVANCED ENCRYPTION STANDARD
● The cipher consists of N rounds, where the number of rounds depends on the key
length: 10 rounds for a 16-byte key, 12 rounds for a 24-byte key, and 14 rounds for
a 32-byte key.
● The first N - 1 rounds consist of four distinct transformation functions: SubBytes,
ShiftRows, MixColumns, and AddRoundKey, which are described subsequently.
● The final round contains only three transformations, and there is a initial single
transformation (AddRoundKey) before the first round, which can be considered
Round 0.
ADVANCED ENCRYPTION STANDARD
● Four different stages are used, one of permutation and three of
substitution:
● Substitute bytes: Uses an S-box to perform a byte-by-byte substitution of
the block.
● ShiftRows: A simple permutation.
● MixColumns: A substitution that makes use of arithmetic over GF(28 ).
● AddRoundKey: A simple bitwise XOR of the current block with a portion of
the expanded key.
SUBSTITUTE BYTES TRANSFORMATION
● AES defines a 16 * 16 matrix of byte values, called
an S-box (Table 6.2a), that contains a permutation
of all possible 256 8-bit values.
● Each individual byte of State is mapped into a new
byte in the following way: The leftmost 4 bits of the
byte are used as a row value and the rightmost 4
bits are used as a column value.
● These row and column values serve as indexes into
the S-box to select a unique 8-bit output value.
● For example, the hexadecimal value {95}
references row 9, column 5 of the S-box, which
contains the value {2A}. Accordingly, the value {95}
is mapped into the value {2A}.
SHIFT ROWS TRANSFORMATION
● The first row of State is
not altered. For the
second row, a 1-byte
circular left shift is
performed. For the
third row, a 2-byte
circular left shift is
performed. For the
fourth row, a 3-byte
circular left shift is
performed. The
following is an example
of ShiftRows
MIX COLUMN TRANSFORMATION
Each byte of a column is
mapped into a new value
that is a function of all four
bytes in that column. The
transformation can be
defined by the following
matrix multiplication on
State
S-Box in AES
RC5 (RIVEST CIPHER 5)
● RC5 is a Block Cipher with a variety of parameters: block size, key size, and number of
rounds.
● It was invented by Ron Rivest and analyzed by RSA Laboratories.
● There are three operations: XOR, addition, and rotations.
● RC5 has a variable-length block.
● Once w, r, k (word size, number of rounds, number of keys) are finalized then they remain
same for all the rounds.
● Plain text block/word size (bits) can be16, 32, 64
● Number of rounds can be between 0-255
● Key size can be between 0 to 255 bytes.
● The main feature of RC5 is that it is quite fast as it only uses primitive computer
operations (addition, XOR,shift).
● Another important feature of RC5 is that it requires less memory for execution and is
therefore suitable for desktop computers, smart cards and other devices that have small
memory capacity.
● We initialize the counter to 1 and perform some permutation and combination using addition and XOR
■ Either of the two related keys can be used for encryption, with the other
used for decryption.
PUBLIC KEY CRYPTOGRAPHY
A public-key encryption scheme has six ingredients (Figure 9.1a; compare with Figure 3.1).
■ Plaintext: This is the readable message or data that is fed into the algorithm as input.
■ Public and private keys: This is a pair of keys that have been 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: This is the encrypted 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: This algorithm accepts the ciphertext and the matching key and produces
the original plaintext.
PUBLIC KEY CRYPTOGRAPHY
The essential steps are the following.
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 Figure 9.1a suggests, each user maintains a collection of public keys obtained from others.
3. If Bob wishes to send a confidential message to Alice, Bob encrypts the message using Alice’s public key.
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’s private key.
With this approach, all participants have access to public keys, and private keys are generated locally by each participant and
therefore need never be distributed. As long as a user’s private key remains protected and secret, incoming communication is
secure
To discriminate between the two, we refer to the key used in symmetric encryption as a secret key. The two keys used for
asymmetric encryption are referred to as the public key and the private key. 2 Invariably, the private key is kept secret, but it
is referred to as a private key rather than a secret key to avoid confusion with symmetric encryption
CONVENTIONAL and PUBLIC KEY CRYPTOGRAPHY
APPLICATIONS OF PUBLIC KEY CRYPTOGRAPHY
In broad terms, we can classify the use of public-key cryptosystems into three
categories
■ Encryption/decryption: The sender encrypts a message with the recipient’s public
key, and the recipient decrypts the message with the recipient’s private key.
■ Digital signature: The sender “signs” a message with its private key. Signing is
achieved by a cryptographic algorithm applied to the message or to a small block
of data that is a function of the message.
■ Key exchange: Two sides cooperate to exchange a session key, which is a secret
key for symmetric encryption generated for use for a particular transaction (or
session) and valid for a short period of time. Several different approaches are
possible, involving the private key(s) of one or both parties;
RSA Algorithm
● One of the first successful responses to the challenge was developed in
1977 by Ron Rivest, Adi Shamir, and Len Adleman at MIT and first
published in 1978.
● The Rivest-Shamir-Adleman (RSA) scheme has since that time reigned
supreme as the most widely accepted and implemented general-purpose
approach to public-key encryption.
● The RSA scheme is a cipher in which the plaintext and ciphertext are
integers between 0 and n - 1 for some n. A typical size for n is 1024 bits, or
309 decimal digits. That is, n is less than 21024.
● RSA makes use of an expression with exponentials.
RSA Algorithm
b= a x b = 1 mod Φ(n)
RSA Algorithm
SECURITY OF RSA
Five possible approaches to attacking the RSA algorithm are
■ Brute force: This involves trying all possible private keys.
■ Mathematical attacks: There are several approaches, all equivalent in effort to
factoring the product of two primes.
■ Timing attacks: These depend on the running time of the decryption algorithm.
■ Chosen ciphertext attacks: This type of attack exploits properties of the RSA
algorithm
■ Hardware fault-based attack: This involves inducing hardware faults in the
processor that is generating digital signatures.
SECURITY OF RSA
● The defense against the brute-force approach is the same for RSA as for other
cryptosystems, namely, to use a large key space. Thus, the larger the number of bits in d,
the better. However, because the calculations involved, both in key generation and in
encryption/decryption, are complex, the larger the size of the key, the slower the system
will run.
● THE FACTORING PROBLEM We can identify three approaches to attacking RSA
mathematically.
1. Factor n into its two prime factors. This enables calculation of f(n) = (p - 1) * (q - 1), which in
turn enables determination of d K e-1 (mod f(n)).
2. Determine f(n) directly, without first determining p and q. Again, this enables determination
of d K e-1 (mod f(n)).
3. Determine d directly, without first determining f(n).
SECURITY OF RSA
● A timing attack is somewhat analogous to a burglar guessing the combination of a safe by
observing how long it takes for someone to turn the dial from number to number.
● Countermeasures:
■ Constant exponentiation time: Ensure that all exponentiations take the same amount of time
before returning a result. This is a simple fix but does degrade performance.
■ Random delay: Better performance could be achieved by adding a random delay to the
exponentiation algorithm to confuse the timing attack. Kocher points out that if defenders don’t add
enough noise, attackers could still succeed by collecting additional measurements to compensate for
the random delays.
■ Blinding: Multiply the ciphertext by a random number before performing exponentiation. This
process prevents the attacker from knowing what ciphertext bits are being processed inside the
computer and therefore prevents the bit-by-bit analysis essential to the timing attack.
SECURITY OF RSA
● The basic RSA algorithm is vulnerable to a chosen ciphertext attack (CCA).
CCA is defined as an attack in which the adversary chooses a number of
ciphertexts and is then given the corresponding plaintexts, decrypted with
the target’s private key.
● Thus, the adversary could select a plaintext, encrypt it with the target’s
public key, and then be able to get the plaintext back by having it
decrypted with the private key.
● A solution can be optimal asymmetric encryption padding (OAEP)
HASHING
● Hash functions are extremely useful and appear in almost all information security applications.
● A hash function is a mathematical function that converts a numerical input value into another
compressed numerical value. The input to the hash function is of arbitrary length but output is
always of fixed length.
● A cryptographic hash function is an algorithm that takes an arbitrary amount of data input—a
credential—and produces a fixed-size output of enciphered text called a hash value, or just
“hash.”
● Values returned by a hash function are called message digest or simply hash values.
● A hash function is a versatile one-way cryptographic algorithm that maps an input of any size to
a unique output of a fixed length of bits.
● When you hash data, the resulting digest is typically smaller than the input that it started with.
● With hashing, it doesn’t matter if you have a one-sentence message or an entire book — the
result will still be a fixed-length chunk of bits
Process of Hashing
1. Create Information
2. Calculate the Hash Value
3. Encrypt the message
4. Send the Encrypted message and the Hash Value
5. Receive the Encrypted message and the Hash Value
6. Decrypt the message
7. Calculate its hash value at the receiving end
8. Compare the hashes
9. If matched, Process the information, else reject.
Properties of Hashing
The typical features of hash functions are −
● Fixed Length Output Hash Value: Hash function converts data of arbitrary
length to a fixed length. This process is often referred to as hashing the data.
In general, the hash is much smaller than the input data, hence hash functions
are sometimes called compression functions. Since a hash is a smaller
representation of a larger data, it is also referred to as a digest. Hash function
with n bit output is referred to as an n-bit hash function. Popular hash
functions generate values between 160 and 512 bits.
● Efficiency of Operation: Generally for any hash function h with input x,
computation of hx is a fast operation. Computationally hash functions are
much faster than a symmetric encryption.
● Pseudorandomness
Properties of Hashing
● Pre-Image Resistance(One way Function): This property means that it should be
computationally hard to reverse a hash function. In other words, if a hash function h
produced a hash value z, then it should be a difficult process to find any input value x
that hashes to z. This property protects against an attacker who only has a hash value
and is trying to find the input.
● Second Pre-Image Resistance: This property means given an input and its hash, it should
be hard to find a different input with the same hash. In other words, if a hash function h
for an input x produces hash value hx, then it should be difficult to find any other input
value y such that hy = hx. This property of hash function protects against an attacker
who has an input value and its hash, and wants to substitute different value as legitimate
value in place of original input value.
● Collision Resistance This property means it should be hard to find two different inputs of
any length that result in the same hash. This property is also referred to as collision free
hash function. In other words, for a hash function h, it is hard to find any two different
inputs x and y such that hx = hy. Since, hash function is compressing function with fixed
hash length, it is impossible for a hash function not to have collisions. This property of
collision free only confirms that these collisions should be hard to find. This property
makes it very difficult for an attacker to find two input values with the same hash.
SHA
● SHA was developed by the National Institute of Standards and Technology (NIST) and
published as a federal information processing standard (FIPS 180) in 1993.
● When weaknesses were discovered in SHA, now known as SHA-0, a revised version was
issued as FIPS 180-1 in 1995 and is referred to as SHA-1.
● The actual standards document is entitled “Secure Hash Standard.” SHA is based on the
hash function MD4, and its design closely models MD4.
● SHA-1 produces a hash value of 160 bits. In 2002, NIST produced a revised version of the
standard, FIPS 180-2, that defined three new versions of SHA, with hash value lengths of
256, 384, and 512 bits, known as SHA-256, SHA-384, and SHA-512, respectively.
Collectively, these hash algorithms are known as SHA-2.
SHA
SHA 256
● SHA-256, which stands for secure hash algorithm 256, is a cryptographic hashing algorithm (or
function) that’s used for message, file, and data integrity verification.
● Published in 2001, it was a joint effort between the NSA and NIST to introduce a successor to the
SHA 1 family, which was slowly losing strength against brute force attacks.
● It’s part of the SHA-2 family of hash functions and uses a 256-bit key to take a piece of data and
convert it into a new, unrecognizable data string of a fixed length.
● This string of random characters and numbers, called a hash value, is also 256 bits in size.
SHA 256
Some of the standout features of the SHA algorithm are as follows:
● Message Length: The length of the cleartext should be less than 264 bits. The size needs to be in the
comparison area to keep the digest as random as possible.
● Digest Length: The length of the hash digest should be 256 bits in SHA 256 algorithm, 512 bits in SHA-
512, and so on. Bigger digests usually suggest significantly more calculations at the cost of speed and
space.
● Irreversible: By design, all hash functions such as the SHA 256 are irreversible. You should neither get a
plaintext when you have the digest beforehand nor should the digest provide its original value when you
pass it through the hash function again.
SHA 256
SHA 256 follows the steps given below:
1. First, data is converted into binary. Binary code uses 0s and 1s to store information. For example,
the letter ‘a’ is written as ‘01000001’ in this basic computer language.
2. The binary data is divided into blocks of 512 bits. If the block is smaller than 512, it’ll be expanded to
that size by adding bits of “padding.” If it’s larger, it’ll be broken into blocks of 512 bits. (If the last
block isn’t exactly 512 bits, padding is added to the last block to make it 512 bits.)
3. The message is further divided into smaller blocks that are 32 bits each.
4. Sixty-four iterations (rounds) of compression functions are performed, wherein the hash values
generated above are rotated in a specific pattern and additional data gets added.
5. New hash values are created from the output of the previous operations.
6. In the last round, one final 256-bit hash value is produced — this hash digest is the end product of
SHA 256.
SHA 256
Padding Bits: It adds some extra bits to the message, such that the length
is exactly 64 bits short of a multiple of 512. During the addition, the first bit
should be one, and the rest of it should be filled with zeroes.
Padding Length: You can add 64 bits of data now to make the final
plaintext a multiple of 512. You can calculate these 64 bits of characters by
applying the modulus to your original cleartext without the padding.
Initialising the Buffers: You need to initialize the default values for eight
buffers to be used in the rounds as follows:
You also need to store 64 different keys in an array, ranging from K[0] to
K[63]. They are initialized as follows:
SHA 256
Compression Functions: The entire message gets broken down into multiple blocks of 512 bits each. It puts each block
through 64 rounds of operation, with the output of each block serving as the input for the following block. The entire
process is as follows:
SHA 512
● SHA-512, or Secure Hash Algorithm 512, is a hashing algorithm used to convert text of any length into a fixed-size
string. Each output produces a SHA-512 length of 512 bits (64 bytes).
● This algorithm is commonly used for email addresses hashing, password hashing, and digital record verification.
SHA-512 is also used in blockchain technology.
● The algorithm takes as input a message with a maximum length of less than 128 bits and produces as output a 512-
bit message digest. The input is processed in 1024-bit blocks. Figure 11.9 depicts the overall processing of a
message to produce a digest.
● Step 1: Append padding bits: The message is padded so that its length is congruent to 896 modulo 1024 [length K
896(mod 1024)]. Padding is always added, even if the message is already of the desired length. Thus, the number of
padding bits is in the range of 1 to 1024. The padding consists of a single 1 bit followed by the necessary number of
0 bits.
● STEP 2: Append length. A block of 128 bits is appended to the message. This block is treated as an unsigned 128-
bit integer (most significant byte first) and contains the length of the original message (before the padding).
● The outcome of the first two steps yields a message that is an integer multiple of 1024 bits in length. In Figure 11.9,
the expanded message is represented as the sequence of 1024-bit blocks M1, M2, c, MN, so that the total length of
the expanded message is N * 1024bits.
Step 4:Process message in 1024-bit (128-word) blocks: The heart of the algorithm is a module that consists of 80
rounds; this module is labeled F in Figure.
Each round takes as input the 512-bit buffer value, abcdefgh, and updates the contents of the buffer. At input to the
first round, the buffer has the value of the intermediate hash value, Hi-1.
Each round t makes use of a 64-bit value Wt, derived from the current 1024-bit block being processed (Mi ). These
values are derived using a message schedule described subsequently. Each round also makes use of an additive
constant Kt, where 0 … t … 79 indicates one of the 80 rounds.
Step 5 Output. After all N 1024-bit blocks have been processed, the output from the Nth stage is the 512-bit
message digest.
Digital Signatures
Digital Signature Security Requirement
How it Works?
● A Digital Signature Scheme will have two components, a private signing
algorithm which permits a user to securely sign a message and a public
verification algorithm which permits anyone to verify that the signature is
authentic.
● The signing algorithm needs to "bind" a signature to a message in such a
way that the signature cannot be pulled out and used to sign another
document, or have the original message modified and the signature
remain valid.
● For practical reasons it would be necessary for both algorithms to be
relatively fast and if small computers such as smart cards are to be used,
the algorithms can not be too computationally complex.
RSA Digital Signature Scheme
It is the most popular asymmetric cryptographic algorithm. It
is primarily used for encrypting messages but can also be
used for performing digital signature over a message. Let us
understand how RSA can be used for performing digital
signatures step-by-step. Assume that there is a sender (A) and
a receiver (B). A wants to send a message (M) to B along
with the digital signature (DS) calculated over the message.
Step-3 : Now sender A sends the digital signature (DS) along with the original message (M) to B.
RSA Digital Signature Scheme
Step-4 : When B receives the Original Message(M) and the
Digital Signature(DS) from A, it first uses the same message-
digest algorithm as was used by A and calculates its own
Message Digest (MD2) for M.
Kerberos support is built in to all major computer operating systems, including Microsoft Windows, Apple macOS, FreeBSD
and Linux.
● Since Windows 2000, Microsoft has used the Kerberos protocol as the default authentication method in Windows, and it is an
integral part of the Windows Active Directory (AD) service. Broadband service providers also use the protocol to authenticate
● Kerberos was developed for Project Athena at the Massachusetts Institute of Technology (MIT). The name was taken from
Greek mythology; Kerberos (Cerberus) was a three-headed dog who guarded the gates of Hades. The three heads of the
4. Desired lifetime of the Ticket granting ticket (TGT). The default is 10 hours and can be changed via Group
Policy. Authentication service issues a ticket granting ticket (TGT) if the user exists in the database. The
first message sent back to the user contains:
5. Security identifier (SID)
6. TGS ID
7. Timestamp
8. User's IP address
9. TGT lifetime
10. TGT
11. Session key
After this message, another message will be sent containing:
1. TGS ID
2. Timestamp
3. Session key
The user sends the TGT to the TGS along with the Kerberos ID of the requested
services. Another message is sent containing the "Authenticator", which is composed of
the User ID and timestamp, encrypted with the user's session key.
PKI
● Public key infrastructure (PKI) is a catch-all term for everything used to establish and manage public
key encryption, one of the most common forms of internet encryption.
● It is baked into every web browser in use today to secure traffic across the public internet, but
organizations can also deploy it to secure their internal communications and access to connected
devices.
● Public Key Infrastructure (PKI) is a technology for authenticating users and devices in the digital world. The basic
idea is to have one or more trusted parties digitally sign documents certifying that a particular cryptographic key
belongs to a particular user or device. The key can then be used as an identity for the user in digital networks.
● A public key infrastructure relies on digital signature technology, which uses public key cryptography. The basic
idea is that the secret key of each entity is only known by that entity and is used for signing. This key is called the
private key. There is another key derived from it, called the public key, which is used for verifying signatures but
cannot be used to sign. This public key is made available to anyone, and is typically included in the certificate
document.
HOW IT WORKS
● PKI certificates are documents that act as digital
passports, assigned to any entity that wants to
participate in a PKI-secured conversation.
● They can include quite a bit of data. One of the
most important pieces of information a
certificate includes is the entity's public key: the
certificate is the mechanism by which that key is
shared. But there's also the authentication
piece.
● A certificate includes an attestation from a
trusted source that the entity is who they claim
to be. That trusted source is generally known as
a certificate authority (CA).
X.509
● X.509 is a digital certificate that is built on top of a widely trusted standard known as ITU or
International Telecommunication Union X.509 standard, in which the format of PKI certificates is
defined.
● X.509 digital certificate is a certificate-based authentication security framework that can be used for
providing secure transaction processing and private information. These are primarily used for handling
the security and identity in computer networking and internet-based communications.
● The core of the X.509 authentication service is the public key certificate connected to each user. These
user certificates are assumed to be produced by some trusted certification authority and positioned in
the directory by the user or the certified authority.
● Once an X.509 certificate is provided to a user by the certified authority, that certificate is attached to it
like an identity card. The chances of someone stealing it or losing it are less, unlike other unsecured
passwords. With the help of this analogy, it is easier to imagine how this authentication works: the
certificate is basically presented like an identity at the resource that requires authentication.