MODULE 2_ Cryptography_ Key Management, Distribution and User Authentication-1
MODULE 2_ Cryptography_ Key Management, Distribution and User Authentication-1
■ 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.
■ Encryption algorithm: The encryption algorithm performs various transformations on the plaintext.
■ 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)
MESSAGE AUTHENTICATION FUNCTIONS
These may be grouped into three classes:
● 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 Signature Scheme
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.
● As we have previously noted, in order for Bob to sign a message m, he raises m
to his private decryption exponent mod n. This is the signature algorithm.
● Anyone can verify this signature by raising md to Bob's public encryption
exponent mod n. This is the verification algorithm.
● Application of the verification algorithm to a valid signature yields the message
m.
● The verifier must know the message m in order to be sure that this is the
message that Bob signed, so in this application Bob must send the ordered pair
(m, md mod n).
● Some care must be taken in the construction of the message to be signed in this
way. For instance, if m is the instruction to Bob's bank to issue a check to Alice,
then if Alice intercepts the ordered pair, she can send the same pair to Bob's
bank whenever she is a little low on cash.
● To prevent this kind of abuse, when it matters, messages should include dates
and other such items which prevent the message from being reused.
KERBEROS
● Kerberos is a protocol for authenticating service requests between trusted hosts across an untrusted network, such as the internet.
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 Kerberos
2. the network resource, which is the application server that provides access to the network resource;
3. a key distribution center (KDC), which acts as Kerberos' trusted third-party authentication service
When a user requests access to a service through the authentication service, they enter their username and password locally, and send the
following information:
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.