unit-2 (1)
unit-2 (1)
Cryptography is essential for securing data transmission. It ensures that data sent over networks
remains confidential and unaltered. This is achieved through various cryptographic algorithms
and protocols.
Error detecting and correcting codes are crucial for maintaining data integrity. They help identify
and correct errors that occur during data transmission. Common techniques include:
Types of Cryptography
There are three main types of cryptography:
Symmetric key Cryptography: With the encryption technique, the sender and the recipient use
the same shared key to encrypt and decrypt messages.
Although symmetric key systems are quicker and easier to use, they have the drawback of
requiring a secure key exchange between the sender and the receiver. Data Encryption System
(DES) is the most widely used symmetric key encryption method.
Hash Functions: In this algorithm, no key is used. The plain text is used to produce a hash value
that has a fixed length, making it challenging to retrieve the plain text's information. Hash
functions are widely used by operating systems to encrypt passwords.
Asymmetric Key Cryptography: This approach uses a set of keys to encrypt and decrypt data.
Public keys are used for encryption, whereas private keys are used for decryption.
The Public Key and Private Key are different from one another. Even if everyone knows the
public key, only the intended recipient may decode the message since only he can access the
private key.
Features of Cryptography
Cryptography has the following features:
○ Confidentiality: The only person who can access information is the one it is intended
for, which is the primary feature of cryptography.
○ Integrity: Information cannot be altered while it is being stored or sent from the sender
to the intended destination without the recipient spotting the addition of new information
in Cryptography.
○ Non-repudiation: The creator/sender of a message cannot deny his intent to send
information at a future point.
○ Authentication: The identities of the sender and the recipient have been confirmed.
Furthermore, the information's source and final destination are confirmed.
○ Availability: It also ensures that the required information is available to authorized users
at the appropriate time.
○ Key Management: The creation, distribution, storage, and alteration of cryptographic
keys take place in this process.
○ Algorithm: Mathematical formulae are used in cryptography to encrypt and decrypt
messages.
○ Digital Signatures: A signature that can be applied to messages to protect the message's
authenticity and sender identification.
Encryption uses a cipher to encrypt and transform the plaintext into ciphertext. On the other
hand, decryption transforms the ciphertext into plaintext by employing the same cipher.
The most popular application of cryptography when sending electronic data is encrypting and
decrypting emails and other plaintext messages. The simplest method is the "secret key" or
symmetric approach.
The secret key is used to encrypt data, and after decoding, the secret key and encoded message
are sent to the recipient. What is the problem, then? A third party is all they need to decode and
analyze the message if it is intercepted.
Cryptologists developed the asymmetric or "public key" approach to solve this issue. Each user,
in this case, has two keys: a private key and a public key. Senders request the recipient's public
key before encrypting and sending the message.
Cryptographic Algorithms
Cryptosystems encrypt and decrypt information using cryptographic algorithms, or ciphers, to
secure communications between computer systems, devices, and applications.
A cipher suite uses three different algorithms: one for encryption, message authentication, and
key exchange. This process, integrated into protocols and developed using software that runs on
operating systems (OS) and networked computer systems, involves:
○ Data encryption and decryption using the production of public and private keys
○ To authenticate messages, use digital signature and verification
○ Key exchange
Advantages
Access Management: Access control can use cryptography to guarantee that only individuals
with the appropriate authorizations are granted access to a resource. The resource is encrypted
and can only be accessed by those with the proper decryption key.
Secure Communication: Cryptography is essential for private communication over the Internet.
It provides safe methods for sending sensitive data like bank account numbers, passwords, and
other private information over the Internet.
Protection against attacks: Attacks like replay and man-in-the-middle attacks can be defended
against with the help of cryptography. It provides techniques for identifying and preventing these
assaults.
Compliance with legal requirements: Businesses can use cryptography to help them deal with
several legal obligations, such as data protection and privacy laws.
Applications of Cryptography
Computer passwords: Cryptography is frequently used in computer security, especially when
creating and managing passwords. When users log in, their password is hashed and contrasted
with the previously saved hash. To store them, passwords are first hashed and encrypted. This
method encrypts the passwords so that even if hackers can access the password database, they
can't comprehend the passwords.
Digital Currencies: Cryptography is also used by digital currencies like Bitcoin to secure
transactions and prevent fraud. Since advanced algorithms and cryptographic keys safeguard
transactions, tampering with or creating fake transactions is practically impossible.
Digital signatures: Digital signatures are used to sign papers and act as the handwritten
signature's digital copy. Cryptography is used to create digital signatures, and public key
cryptography is used to verify them. Digital signatures are becoming more widely used, and
many countries have laws that make them legally binding.
● Protect Confidentiality: Ensures that only authorized parties can access the information.
● Ensure Integrity: Verifies that the data has not been altered.
● Authenticate Users: Confirms the identity of the parties involved in communication.
● Non-repudiation: Prevents denial of sending or receiving the message.
Cryptology Fundamentals
● Symmetric Cryptography: Uses the same key for both encryption and decryption.
Examples include AES and DES.
● Asymmetric Cryptography: Uses a pair of keys (public and private). Examples include
RSA and ECC.
Cryptographic Algorithms
● Symmetric Algorithms: Fast and efficient for large data. Examples: AES, DES.
● Asymmetric Algorithms: More secure for key exchange and digital signatures.
Examples: RSA, ECC.
● Hash Functions: Provide data integrity by producing a fixed-size hash value from input
data. Examples: SHA-256, MD5.
Key management refers to the processes and procedures involved in generating, storing,
distributing, and managing cryptographic keys used in cryptographic algorithms to protect
sensitive data. It ensures that keys used to protect sensitive data are kept safe from unauthorized
access or loss. Good key management helps maintain the security of encrypted information and
is important for protecting digital assets from cyber threats. Effective key management is crucial
for ensuring the confidentiality, integrity, and availability of encrypted information by securing
cryptographic keys from unauthorized access, loss, or compromise.
Cryptographic keys are special codes that protect information by locking (encrypting) and
unlocking (decrypting) it. In symmetric key cryptography, a single shared key does both jobs,
so the same key must be kept secret between users. In asymmetric key cryptography, there are
two keys: a public key that anyone can use to encrypt messages or verify signatures, and a
private key that only the owner uses to decrypt messages or create signatures. This makes it
easier to share the public key openly while keeping the private key secret. These keys are crucial
for secure communication, like when you visit a secure website (HTTPS), where they help
encrypt your data and keep it safe from eavesdroppers and criminals. So, to manage these keys
properly is vital to keep digital information secure and dependable.
1. Public announcement
2. Publicly available directory
3. Public-key authority
4. Public-key certificates.
2. Publicly Available Directory: In this type, the public key is stored in a public directory.
Directories are trusted here, with properties like Participant Registration, access and allow to
modify values at any time, contains entries like {name, public-key}. Directories can be accessed
electronically still vulnerable to forgery or tampering.
3. Public Key Authority: It is similar to the directory but, improves security by tightening
control over the distribution of keys from the directory. It requires users to know the public key
for the directory. Whenever the keys are needed, real-time access to the directory is made by the
user to obtain any desired public key securely.
4. Public Certification: This time authority provides a certificate (which binds an identity to the
public key) to allow key exchange without real-time access to the public authority each time. The
certificate is accompanied by some other info such as period of validity, rights of use, etc. All of
this content is signed by the private key of the certificate authority and it can be verified by
anyone possessing the authority’s public key.
First sender and receiver both request CA for a certificate which contains a public key and other
information and then they can exchange these certificates and can start communication.
The key management lifecycle outlines the stages through which cryptographic keys are
generated, used, and eventually retired or destroyed. Proper management of these keys is critical
to ensuring the security of cryptographic systems. Here’s an overview of each stage:
1. Key Generation:
● Creation: Keys are created using secure algorithms to ensure randomness and
strength.
● Initialization: Keys are initialized with specific parameters required for their
intended use (e.g., length, algorithm).
2. Key Distribution:
● Sharing: For symmetric keys, secure methods must be used to share the key between
parties.
● Publication: For asymmetric keys, the public key is shared openly, while the private
key remains confidential.
3. Key Storage:
4. Key Usage:
● Application: Keys are used for their intended cryptographic functions, such as
encrypting/decrypting data or signing/verifying messages.
● Monitoring: Usage is monitored to detect any unusual or unauthorized activities.
Key Management in Cryptography
5. Key Rotation:
6. Key Revocation:
7. Key Archival:
● Storage: Old keys are securely archived for future reference or compliance purposes.
● Access Restrictions: Archived keys are kept in a secure location with restricted
access.
8. Key Destruction:
● Erasure: When keys are no longer needed, they are securely destroyed to prevent any
possibility of recovery.
● Verification: The destruction process is verified to ensure that no copies remain.
Public key cryptography is a method of secure communication that uses a pair of keys, a public
key, which anyone can use to encrypt messages or verify signatures, and a private key, which is
kept secret and used to decrypt messages or sign documents. This system ensures that only the
intended recipient can read an encrypted message and that a signed message truly comes from
the claimed sender. Public key cryptography is essential for secure internet communications,
allowing for confidential messaging, authentication of identities, and verification of data
integrity.
Encryption
The process of changing the plaintext into the ciphertext is referred to as encryption.
The encryption process consists of an algorithm and a key. The key is a value independent of the
plaintext.
Decryption
The process of changing the ciphertext to the plaintext that process is known as decryption.
Public-Key
Basis Encryption
Encryption
● Same algorithm
● One algorithm is used for
with the same key
encryption and a related
is used for
algorithm decryption with
encryption and
Required pair of keys, one for
for Work decryption.
encryption and other for
● The sender and
decryption.
receiver must share
● Receiver and Sender must
the algorithm and
each have one of the
key.
matched pair of keys (not
identical) .
Example:
Public keys of every user are present in the Public key Register. If B wants to send a confidential
message to C, then B encrypt the message using C Public key. When C receives the message
from B then C can decrypt it using its own Private key. No other recipient other than C can
decrypt the message because only C know C’s private key.
● Plain Text: This is the message which is readable or understandable. This message is
given to the Encryption algorithm as an input.
● Cipher Text: The cipher text is produced as an output of Encryption algorithm. We
cannot simply understand this message.
● Encryption Algorithm: The encryption algorithm is used to convert plain text into
cipher text.
● Decryption Algorithm: It accepts the cipher text as input and the matching key
(Private Key or Public key) and produces the original plain text
● Public and Private Key: One key either Private key (Secret key) or Public Key
(known to everyone) is used for encryption and other is used for decryption
In this, the same key (secret key) and In public-key cryptography, two keys are
algorithm are used to encrypt and decrypt used, one key is used for encryption, and
the message. the other is used for decryption.
The private key is Symmetrical because The public key is Asymmetrical because
there is only one key that is called a there are two types of keys: private and
secret key. public keys.
It is used for large amounts of text. It is used for only short messages.
There is the possibility of losing the key There is less possibility of key loss, as the
that renders the systems void. key is held publicly.
The private key is kept secret. The public key is widely distributed.
It is used to protect disk drives and other It is used to secure web sessions and
data storage devices. emails.
The recipient’s private key decrypts the The recipient’s public key encrypts the
message. message.
key storage,
In cryptography, key storage refers to the methods and practices used to securely store
cryptographic keys, which are essential for encrypting and decrypting data. Here are some key
points:
1. Hardware Security Modules (HSMs): These are physical devices that manage and store
cryptographic keys. They provide a high level of security by protecting keys from
unauthorized access and physical tampering1.
2. Key Management Services (KMS): Cloud providers like AWS, Azure, and Google
Cloud offer KMS to manage cryptographic keys. These services handle key generation,
storage, and lifecycle management, ensuring keys are securely stored and easily
accessible when needed2.
3. Software-Based Key Storage: This involves storing keys in software applications, often
using secure storage mechanisms like encrypted databases or secure enclaves within
processors3.
4. Key Encryption Keys (KEKs): KEKs are used to encrypt other keys (Data Encryption
Keys or DEKs). The KEK is stored separately from the DEK, adding an extra layer of
security1.
5. Best Practices:
○ Minimize Key Storage: Only store keys when absolutely necessary.
○ Use Strong Encryption: Ensure keys are encrypted using strong algorithms like
AES-256.
○ Regularly Rotate Keys: Periodically change keys to limit the impact of a
potential compromise.
○ Access Controls: Implement strict access controls to ensure only authorized users
can access keys2.
What is DES?
Data Encryption Standard (DES) is a block cipher with a 56-bit key length that has played a
significant role in data security. Data encryption standard (DES) has been found vulnerable to
very powerful attacks therefore, the popularity of DES has been found slightly on the decline.
DES is a block cipher and encrypts data in blocks of size of 64 bits each, which means 64 bits of
plain text go as the input to DES, which produces 64 bits of ciphertext. The same algorithm and
key are used for encryption and decryption, with minor differences. The key length is 56 bits.
The basic idea is shown below:
We have mentioned that DES uses a 56-bit key. Actually, The initial key consists of 64 bits.
However, before the DES process even starts, every 8th bit of the key is discarded to produce a
56-bit key. That is bit positions 8, 16, 24, 32, 40, 48, 56, and 64 are discarded.
Thus, the discarding of every 8th bit of the key produces a 56-bit key from the original 64-bit
key.
DES is based on the two fundamental attributes of cryptography: substitution (also called
confusion) and transposition (also called diffusion). DES consists of 16 steps, each of which is
called a round. Each round performs the steps of substitution and transposition. Let us now
discuss the broad-level steps in DES.
● In the first step, the 64-bit plain text block is handed over to an initial Permutation
(IP) function.
● The initial permutation is performed on plain text.
● Next, the initial permutation (IP) produces two halves of the permuted block; saying
Left Plain Text (LPT) and Right Plain Text (RPT).
● Now each LPT and RPT go through 16 rounds of the encryption process.
● In the end, LPT and RPT are rejoined and a Final Permutation (FP) is performed on
the combined block
● The result of this process produces 64-bit ciphertext.
As we have noted after IP is done, the resulting 64-bit permuted text block is divided into two
half blocks. Each half-block consists of 32 bits, and each of the 16 rounds, in turn, consists of the
broad-level steps outlined in the figure.
Step 1: Key transformation
We have noted initial 64-bit key is transformed into a 56-bit key by discarding every 8th bit of
the initial key. Thus, for each a 56-bit key is available. From this 56-bit key, a different 48-bit
Sub Key is generated during each round using a process called key transformation. For this, the
56-bit key is divided into two halves, each of 28 bits. These halves are circularly shifted left by
one or two positions, depending on the round.
For example: if the round numbers 1, 2, 9, or 16 the shift is done by only one position for other
rounds, the circular shift is done by two positions. The number of key bits shifted per round is
shown in the figure.
After an appropriate shift, 48 of the 56 bits are selected. From the 48 we might obtain 64 or 56
bits based on requirement which helps us to recognize that this model is very versatile and can
handle any range of requirements needed or provided. for selecting 48 of the 56 bits the table is
shown in the figure given below. For instance, after the shift, bit number 14 moves to the first
position, bit number 17 moves to the second position, and so on. If we observe the table , we will
realize that it contains only 48-bit positions. Bit number 18 is discarded (we will not find it in the
table), like 7 others, to reduce a 56-bit key to a 48-bit key. Since the key transformation process
involves permutation as well as a selection of a 48-bit subset of the original 56-bit key it is called
Compression Permutation.
Because of this compression permutation technique, a different subset of key bits is used in each
round. That makes DES not easy to crack.
Recall that after the initial permutation, we had two 32-bit plain text areas called Left Plain
Text(LPT) and Right Plain Text(RPT). During the expansion permutation, the RPT is expanded
from 32 bits to 48 bits. Bits are permuted as well hence called expansion permutation. This
happens as the 32-bit RPT is divided into 8 blocks, with each block consisting of 4 bits. Then,
each 4-bit block of the previous step is then expanded to a corresponding 6-bit block, i.e., per
4-bit block, 2 more bits are added.
Double DES and Triple DES
Double DES:
Double DES is a encryption technique which uses two instance of DES on same plain text. In
both instances it uses different keys to encrypt the plain text. Both keys are required at the time
of decryption. The 64 bit plain text goes into first DES instance which then converted into a 64
bit middle text using the first key and then it goes to second DES instance which gives 64 bit
cipher text by using second key.
However double DES uses 112 bit key but gives security level of 2^56 not 2^112 and this is
because of meet-in-the middle attack which can be used to break through double DES.
Triple DES:
Triple DES is a encryption technique which uses three instance of DES on same plain text. It
uses there different types of key choosing technique in first all used keys are different and in
second two keys are same and one is different and in third all keys are same.
Triple DES is also vulnerable to meet-in-the middle attack because of which it give total security
level of 2^112 instead of using 168 bit of key. The block collision attack can also be done
because of short block size and using same key to encrypt large size of text. It is also vulnerable
to sweet32 attack.
Introduction :
The International Data Encryption Algorithm (IDEA) is a symmetric-key block cipher that was
first introduced in 1991. It was designed to provide secure encryption for digital data and is used
in a variety of applications, such as secure communications, financial transactions, and electronic
voting systems.
IDEA uses a block cipher with a block size of 64 bits and a key size of 128 bits. It uses a series
of mathematical operations, including modular arithmetic, bit shifting, and exclusive OR (XOR)
operations, to transform the plaintext into ciphertext. The cipher is designed to be highly secure
and resistant to various types of attacks, including differential and linear cryptanalysis.
One of the strengths of IDEA is its efficient implementation in software and hardware. The
algorithm is relatively fast and requires only a small amount of memory and processing power.
This makes it a popular choice for use in embedded systems and other applications where
resources are limited.
IDEA has been widely used in various encryption applications, although it has been largely
replaced by newer encryption algorithms such as AES (Advanced Encryption Standard) in recent
years. However, IDEA is still considered to be a highly secure and effective encryption
algorithm, and it continues to be used in some legacy systems and applications.
In cryptography, block ciphers are very important in the designing of many cryptographic
algorithms and are widely used to encrypt the bulk of data in chunks. By chunks, it means that
the cipher takes a fixed size of the plaintext in the encryption process and generates a fixed size
ciphertext using a fixed-length key. An algorithm’s strength is determined by its key length.
The Simplified International Data Encryption Algorithm (IDEA) is a symmetric key block
cipher that:
This algorithm involves a series of 4 identical complete rounds and 1 half-round. Each complete
round involves a series of 14 steps that includes operations like:
● Bitwise XOR
● Addition modulo
● Multiplication modulo +1
After 4 complete rounds, the final “half-round” consists of only the first 4 out of the
14 steps previously used in the full rounds. To perform these rounds, each binary
notation must be converted to its equivalent decimal notation, perform the operation
and the result obtained should be converted back to the binary representation for the
final result of that particular step.
Key Schedule: 6 subkeys of 4 bits out of the 8 subkeys are used in each complete
round, while 4 are used in the half-round. So, 4.5 rounds require 28 subkeys. The
given key, ‘K’, directly gives the first 8 subkeys. By rotating the main key left by 6
bits between each group of 8, further groups of 8 subkeys are created, implying less
than one rotation per round for the key (3 rotations).
K1 K2 K3 K4 K5 K6
Symbol Operation
Multiplication modulo
*
+1
+
Addition modulo
^ Bitwise XOR
The 16-bit plaintext can be represented as X1 || X2 || X3 || X4, each of size 4 bits. The 32-bit key
is broken into 8 subkeys denoted as K1 || K2 || K3 || K4 || K5 || K6 || K7 || K8, again of size 4 bits
each. Each round of 14 steps uses the three algebraic operation-Addition modulo (2^4),
Multiplication modulo (2^4)+1 and Bitwise XOR. The steps involved are as follows:
1. X1 * K1
2. X2 + K2
3. X3 + K3
4. X4 * K4
5. Step 1 ^ Step 3
6. Step 2 ^ Step 4
7. Step 5 * K5
8. Step 6 + Step 7
9. Step 8 * K6
10. Step 7 + Step 9
11. Step 1 ^ Step 9
12. Step 3 ^ Step 9
13. Step 2 ^ Step 10
14. Step 4 ^ Step 10
The input to the next round is Step 11 || Step 13 || Step 12 || Step 14, which becomes
X1 || X2 || X3 || X4. This swap between 12 and 13 takes place after each complete
round, except the last complete round (4th round), where the input to the final half
round is Step 11 || Step 12 || Step 13 || Step 14.
After last complete round, the half-round is as follows:
1. X1 * K1
2. X2 + K2
3. X3 + K3
4. X4 * K4
Example:
Explanation:
The explanation is only for 1st complete round (the remaining can be implemented similarly) and
the last half-round.
● Round 1:
○ From the plaintext: X1 – 1001, X2 – 1100, X3 – 1010, X4 – 1100
○ From the table above: K1 – 1101, K2 – 1100, K3 – 0110, K4 –
1111, K5 – 0011, K6 – 1111
● Round 1 Output: 0111 1011 1000 1001 (Step 12 and Step 13 results are
interchanged)
● Round 2:
○ From Round 1 output: X1 – 0111, X2 – 1011, X3 – 1000, X4 –
1001
○ From the table above: K1 – 0101, K2 – 1001, K3 – 0001, K4 –
1011, K5 – 1100, K6 – 1111
○ Round 2 Output: 0110 0110 1110 1100 (Step 12 and Step 13
results are interchanged)
● Round 3:
○ From Round 2 Output: X1 – 0110, X2 – 0110, X3 – 1110, X4 –
1100
○ From the table above: K1 – 1101, K2 – 0110, K3 – 0111, K4 –
0111, K5 – 1111, K6 – 0011
○ Round 3 Output: 0100 1110 1011 0010 (Step 12 and Step 13
results are interchanged)
● Round 4:
○ From Round 3 Output: X1 – 0100, X2 – 1110, X3 – 1011, X4 –
0010
○ From the table above: K1 – 1111, K2 – 0101, K3 – 1001, K4 –
1101, K5 – 1100, K6 – 0110
○ Round 4 Output: 0011 1110 1110 0100 (Step 12 and Step 13
results are interchanged)
● Round 4.5:
RC5 is a symmetric key block encryption algorithm designed by Ron Rivest in 1994. It is
notable for being simple, fast (on account of using only primitive computer operations like XOR,
shift, etc.) and consumes less memory. Example:
Key : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
RC5 is a block cipher and addresses two word blocks at a time. Depending on input plain text
block size, number of rounds and key size, various instances of RC5 can be defined and each
instance is denoted as RC5-w/r/b where w=word size in bits, r=number of rounds and b=key size
in bytes. Allowed values are:
Note – Since at a time, RC5 uses 2 word blocks, the plain text block size can be 32, 64 or 128
bits. Notation used in the algorithm:
Symbol Operation
2w
+
2
w
^ Bit wise Exclusive-OR
Step-1: Initialization of constants P and Q. RC5 makes use of 2 magic constants P and Q whose
value is defined by the word size w.
16 b7e1 9e37
32 b7e15163 9e3779b9
64 b7e151628aed2a6b 9e3779b97f4a7c15
P = Odd((e-2)
2w
) Q = Odd((
ϕ
ϕ-2)
2w
Here, Odd(x) is the odd integer nearest to x, e is the base of natural logarithms and
[Tex]\phi [/Tex]is the golden ratio. Step-2: Converting secret key K from bytes to
words. Secret key K of size b bytes is used to initialize array L consisting of c words where c =
b/u, u = w/8 and w = word size used for that particular instance of RC5. For example, if we
choose w=32 bits and Key k is of size 96 bytes then, u=32/8=4, c=b/u=96/4=24. L is pre
initialized to 0 value before adding secret key K to it.
for i=b-1 to 0
Step-3: Initializing sub-key S. Sub-key S of size t=2(r+1) is initialized using magic constants P
and Q.
S[0] = P
for i = 1 to 2(r+1)-1
S[i] = S[i-1] + Q)
Step-4: Sub-key mixing. The RC5 encryption algorithm uses Sub key S. L is merely, a
temporary array formed on the basis of user entered secret key. Mix in user’s secret key with S
and L.
i=j=0
A=B=0
do 3 * max(t, c) times:
A = S[i] = (S[i] + A + B) <<< 3
i = (i + 1) % t
j = (j + 1) % c
Step-5: Encryption. We divide the input plain text block into two registers A and B each of size
w bits. After undergoing the encryption process the result of A and B together forms the cipher
text block. RC5 Encryption Algorithm:
1. One time initialization of plain text blocks A and B by adding S[0] and S[1] to A and
B respectively. These operations are mod[Tex]2^w [/Tex].
2. XOR A and B. A=A^B
3. Cyclic left shift new value of A by B bits.
4. Add S[2*i] to the output of previous step. This is the new value of A.
5. XOR B with new value of A and store in B.
6. Cyclic left shift new value of B by A bits.
7. Add S[2*i+1] to the output of previous step. This is the new value of B.
8. Repeat entire procedure (except one time initialization) r times.
A = A + S[0]
B = B + S[1]
for i = 1 to r do:
return A, B
B = B - S[1]
A = A - S[0]
return A, B
Points to Remember
That means it takes 128 bits as input and outputs 128 bits of encrypted cipher text. AES relies on
the substitution-permutation network principle, which is performed using a series of linked
operations that involve replacing and shuffling the input data.
A Key Schedule algorithm calculates all the round keys from the key. So the initial key is used to
create many different round keys which will be used in the corresponding round of the
encryption.
Encryption
AES considers each block as a 16-byte (4 byte x 4 byte = 128 ) grid in a column-major
arrangement.
[ b0 | b4 | b8 | b12 |
| b1 | b5 | b9 | b13 |
| b2 | b6 | b10| b14 |
| b3 | b7 | b11| b15 ]
● SubBytes
● ShiftRows
● MixColumns
● Add Round Key
The SubBytes does the substitution and ShiftRows and MixColumns perform the permutation in
the algorithm.
Sub Bytes
In this step, each byte is substituted by another byte. It is performed using a lookup table also
called the S-box. This substitution is done in a way that a byte is never substituted by itself and
also not substituted by another byte which is a compliment of the current byte. The result of this
step is a 16-byte (4 x 4 ) matrix like before.
Shift Rows
This step is just as it sounds. Each row is shifted a particular number of times.
[ b0 | b1 | b2 | b3 ] [ b0 | b1 | b2 | b3 ]
| b4 | b5 | b6 | b7 | -> | b5 | b6 | b7 | b4 |
Mix Columns
This step is a matrix multiplication. Each column is multiplied with a specific matrix and thus
the position of each byte in the column is changed as a result.
[ c0 ] [ 2 3 1 1 ] [ b0 ]
| c1 | = |1 2 3 1| | b1 |
| c2 | |1 1 2 3| | b2 |
[ c3 ] [3 1 1 2] [ b3 ]
Now the resultant output of the previous stage is XOR-ed with the corresponding round key.
Here, the 16 bytes are not considered as a grid but just as 128 bits of data.
Added Round Keys (AES)
After all these rounds 128 bits of encrypted data are given back as output. This process is
repeated until all the data to be encrypted undergoes this process.
Decryption
The stages in the rounds can be easily undone as these stages have an opposite to it which when
performed reverts the changes. Each 128 blocks goes through the 10,12 or 14 rounds depending
on the key size.
The decryption process is the encryption process done in reverse so I will explain the steps with
notable differences.
Inverse MixColumns
This step is similar to the Mix Columns step in encryption but differs in the matrix used to carry
out the operation.
Matrix multiplication is used. The output of this step is the matrix multiplication of the old
values and a
constant matrix
[b0] = [ 14 11 13 9] [ c0 ]
[b1]=[ 9 14 11 13 ] [ c1 ]
[b2] =[ 13 9 14 11] [ c2 ]
[ b3 ]=[ 11 13 9 14 ] [ c3 ]
Inverse SubBytes
Inverse S-box is used as a lookup table and using which the bytes are substituted during
decryption.
Function Substitute performs a byte substitution on each byte of the input word. For this purpose,
it uses an S-box.
Applications
AES is widely used in many applications which require secure data storage and transmission.
Some common use cases include:
1. A client (for example browser) sends its public key to the server and
requests some data.
2. The server encrypts the data using the client’s public key and sends the
encrypted data.
3. The client receives this data and decrypts it.
Since this is asymmetric, nobody else except the browser can decrypt the data even if
a third party has the public key of the browser.
The idea! The idea of RSA is based on the fact that it is difficult to factorize a large
integer. The public key consists of two numbers where one number is a multiplication
of two large prime numbers. And private key is also derived from the same two prime
numbers. So if somebody can factorize the large number, the private key is
compromised. Therefore encryption strength lies in the key size and if we double or
triple the key size, the strength of encryption increases exponentially. RSA keys can
be typically 1024 or 2048 bits long, but experts believe that 1024-bit keys could be
broken shortly. But till now it seems to be an infeasible task.
Let us learn the mechanism behind the RSA algorithm : >> Generating Public
Key:
But e Must be
An integer.
Not be a factor of Φ(n).
Now we are ready with our – Public Key ( n = 3127 and e = 3) and Private Key(d =
2011) Now we will encrypt “HI”:
RSA algorithm uses the following procedure to generate public and private keys:
○ Select two large prime numbers, p and q.
○ Multiply these numbers to find n = p x q, where n is called the modulus for
encryption and decryption.
○ Choose a number e less than n, such that n is relatively prime to (p - 1) x (q -1). It
means that e and (p - 1) x (q - 1) have no common factor except 1. Choose "e" such
that 1<e < φ (n), e is prime to φ (n),
gcd (e,d(n)) =1
○ If n = p x q, then the public key is <e, n>. A plaintext message m is encrypted using
public key <e, n>. To find ciphertext from the plain text following formula is used to
get ciphertext C.
C = me mod n
Here, m must be less than n. A larger message (>n) is treated as a concatenation of
messages, each of which is encrypted separately.
○ To determine the private key, we use the following formula to calculate the d such
that:
De mod {(p - 1) x (q - 1)} = 1
Or
De mod φ (n) = 1
○ The private key is <d, n>. A ciphertext message c is decrypted using private key <d,
n>. To calculate plain text m from the ciphertext c following formula is used to get
plain text m.
m = cd mod n
Explanation:
Step 1: Select two large prime numbers, p, and q.
p=7
q = 11
Step 2: Multiply these numbers to find n = p x q, where n is called the modulus for encryption
and decryption.
First, we calculate
n=pxq
n = 7 x 11
n = 77
Step 3: Choose a number e less that n, such that n is relatively prime to (p - 1) x (q -1). It means
that e and (p - 1) x (q - 1) have no common factor except 1. Choose "e" such that 1<e < φ (n), e
is prime to φ (n), gcd (e, d (n)) =1.
Second, we calculate
φ (n) = (p - 1) x (q-1)
φ (n) = (7 - 1) x (11 - 1)
φ (n) = 6 x 10
Advertisement
φ (n) = 60
To find ciphertext from the plain text following formula is used to get ciphertext C.
C = me mod n
C = 97 mod 77
C = 37
Diffie-Hellman algorithm:
The Diffie-Hellman algorithm is being used to establish a shared secret that can be
used for secret communications while exchanging data over a public network using
the elliptic curve to generate points and get the secret key using the parameters.
1. Division Method.
2. Multiplication Method
3. Mid-Square Method
4. Folding Method
5. Cryptographic Hash Functions
6. Universal Hashing
7. Perfect Hashing
1. Division Method
The division method involves dividing the key by a prime number and using the
remainder as the hash value.
Advantages:
● Simple to implement.
● Works well when 𝑚m is a prime number.
Disadvantages:
2. Multiplication Method
In the multiplication method, a constant 𝐴A (0 < A < 1) is used to multiply the key.
The fractional part of the product is then multiplied by 𝑚m to get the hash value.
Advantages:
3. Mid-Square Method
In the mid-square method, the key is squared, and the middle digits of the result are
taken as the hash value.
Steps:
Advantages:
Disadvantages:
4. Folding Method
The folding method involves dividing the key into equal parts, summing the parts, and
then taking the modulo with respect to 𝑚m.
Steps:
Advantages:
● Simple and easy to implement.
Disadvantages:
Characteristics:
● Pre-image resistance.
● Second pre-image resistance.
● Collision resistance.
Advantages:
● High security.
Disadvantages:
● Computationally intensive.
6. Universal Hashing
Universal hashing uses a family of hash functions to minimize the chance of collision
for any given set of inputs.
Disadvantages:
7. Perfect Hashing
Perfect hashing aims to create a collision-free hash function for a static set of keys. It
guarantees that no two keys will hash to the same value.
Types:
● Minimal Perfect Hashing: Ensures that the range of the hash function is
equal to the number of keys.
● Non-minimal Perfect Hashing: The range may be larger than the number of
keys.
Advantages:
● No collisions.
Disadvantages:
● Complex to construct.
What is MD5?
MD5 is a cryptographic hash function algorithm that takes the message as input of
any length and changes it into a fixed-length message of 16 bytes. MD5 algorithm
stands for the message-digest algorithm. MD5 was developed in 1991 by Ronald
Rivest as an improvement of MD4, with advanced security purposes. The output of
MD5 (Digest size) is always 128 bits.
1. Append Padding Bits: In the first step, we add padding bits in the original
message in such a way that the total length of the message is 64 bits less than the
exact multiple of 512.
Suppose we are given a message of 1000 bits. Now we have to add padding bits to the
original message. Here we will add 472 padding bits to the original message. After
adding the padding bits the size of the original message/output of the first step will be
1472 i.e. 64 bits less than an exact multiple of 512 (i.e. 512*3 = 1536).
2. Append Length Bits: In this step, we add the length bit in the output of the first
step in such a way that the total number of the bits is the perfect multiple of 512.
Simply, here we add the 64-bit as a length bit in the output of the first step.
i.e. output of first step = 512 * n – 64
length bits = 64.
After adding both we will get 512 * n i.e. the exact multiple of 512.
3. Initialize MD buffer: Here, we use the 4 buffers i.e. A B, C, and D. The size of
each buffer is 32 bits.
- A = 0x67425301
- B = 0xEDFCBA45
- C= 0x98CBADFE
- D = 0x13DCE476
4. Process Each 512-bit Block: This is the most important step of the MD5
algorithm. Here, a total of 64 operations are performed in 4 rounds. In the 1st round,
16 operations will be performed, 2nd round 16 operations will be performed, 3rd
round 16 operations will be performed, and in the 4th round, 16 operations will be
performed. We apply a different function on each round i.e. for the 1st round we apply
the F function, for the 2nd G function, 3rd for the H function, and 4th for the I
function.
We perform OR, AND, XOR, and NOT (basically these are logic gates) for
calculating functions. We use 3 buffers for each function i.e. B, C, D.
Process P Operation
After applying the function now we perform an operation on each block. For
performing operations we need
● In the first step, Outputs of B, C, and D are taken and then the function F is
applied to them. We will add modulo 232 bits for the output of this with A.
● In the second step, we add the M[i] bit message with the output of the first
step.
● Then add 32 bits constant i.e. K[i] to the output of the second step.
● At last, we do left shift operation by n (can be any value of n) and addition
modulo by 232.
After all steps, the result of A will be fed into B. Now same steps will be used for all
functions G, H, and I. After performing all 64 operations we will get our message
digest.
SHA-1 Hash
SHA-1 or Secure Hash Algorithm 1 is a cryptographic algorithm that takes an input
and produces a 160-bit (20-byte) hash value. This hash value is known as a message
digest. This message digest is usually then rendered as a hexadecimal number which
is 40 digits long. It is a U.S. Federal Information Processing Standard and was
designed by the United States National Security Agency. SHA-1 is been considered
insecure since 2005. Major tech giants browsers like Microsoft, Google, Apple, and
Mozilla have stopped accepting SHA-1 SSL certificates by 2017.
SHA-1 Hash
The block diagram of the SHA-1 (Secure Hash Algorithm 1) algorithm. Here’s a
detailed description of each component and process in the diagram:
1. Message (M):
● After padding, the message is divided into blocks of 512 bits, and
each block is further divided into 16 words of 32 bits. These
words are then expanded into 80 32-bit words, which are used in
the subsequent rounds.
4. Round Initialize (A, B, C, D, and E):
● Combines the results from the final round addition to form the
final message digest.
Public key infrastructure (PKI) is a system that uses hardware, software, policies, and
procedures to create, manage, and distribute digital certificates and public-key
encryption. PKI is used to secure data transfers, authenticate users and devices, and
ensure that data is encrypted and can be decrypted by both parties
● Securing web traffic: PKI is built into web browsers and helps secure public internet
traffic.
● Securing internal communications: Organizations can use PKI to secure internal
communications and ensure that connected devices can connect securely.
● Authenticating users and devices: PKI helps users confirm the validity of devices and
websites, ensuring that users are connecting to the right website.
● Encrypting and decrypting files: PKI can be used to encrypt and decrypt files.
● Email encryption: PKI can be used to encrypt and authenticate email senders.
● Signing documents and software: PKI can be used to sign documents and software.
Digital Signature
which assure that the message was sent by a particular sender. While
performing digital transactions authenticity and integrity should be assured,
otherwise, the data can be altered or someone can also act as if he was the
sender and expect a reply.
2. Signing Algorithms: To create a digital signature, signing algorithms like
along with the data. It then uses Verification algorithm to process on the
digital signature and the public key (verification key) and generates some
value. It also applies the same hash function on the received data and
generates a hash value. If they both are equal, then the digital signature is
valid else it is invalid.
The definitions and words that follow illustrate the kind of assurances that digital
signatures offer.
2. Integration: Since the content was digitally signed, it hasn’t been altered or
interfered with.
3. Non-repudiation: demonstrates the source of the signed content to all
parties. The act of a signer denying any affiliation with the signed material
is known as repudiation.
4. Notarization: Under some conditions, a signature in a Microsoft Word,
Digital Certificate
Digital certificate is issued by a trusted third party which proves sender’s identity to
the receiver and receiver’s identity to the sender.
A digital certificate is a certificate issued by a Certificate Authority (CA) to verify the
identity of the certificate holder. Digital certificate is used to attach public key with a
particular individual or an entity.
Digital certificate is also sent with the digital signature and the message.
X.500
X.500 is a series of standards developed by the International Telecommunication
Union (ITU) for directory services. It provides a framework for managing and
accessing directory information in a hierarchical manner, similar to an electronic
phone book. The idea is to have a centralized, organized directory that allows for
easy retrieval and management of information across large networks or
organizations.
Benefits of X.500
● Version number: It defines the X.509 version that concerns the certificate.
● Serial number: It is the unique number that the certified authority issues.
● Signature Algorithm Identifier: This is the algorithm that is used for
signing the certificate.
● Issuer name: Tells about the X.500 name of the certified authority which
signed and created the certificate.
● Period of Validity: It defines the period for which the certificate is valid.
● Subject Name: Tells about the name of the user to whom this certificate has
been issued.
● Subject’s public key information: It defines the subject’s public key along
with an identifier of the algorithm for which this key is supposed to be used.
● Extension block: This field contains additional standard information.
● Signature: This field contains the hash code of all other fields which is
encrypted by the certified authority private key.
Applications of X.509 Authentication Service Certificate:
Many protocols depend on X.509 and it has many applications, some of them are
given below: