Unit-III Digital Signature and Authentication
Unit-III Digital Signature and Authentication
The above figure depicts the general operation of a cryptographic hash function.
Typically, the input is padded out to an integer multiple of some fixed length (e.g., 1024 bits), and the
padding includes the value of the length of the original message in bits.
The length field is a security measure to increase the difficulty for an attacker to produce an alternative
message with the same hash value.
More commonly, message authentication is achieved using a message authentication code (MAC), also
known as a keyed hash function.
Typically, MACs are used between two parties that share a secret key to authenticate information
exchanged between those parties.
A MAC function takes as input a secret key and a data block and produces a hash value, referred to as the
MAC, which is associated with the protected message.
If the integrity of the message needs to be checked, the MAC function can be applied to the message and
the result compared with the associated MAC value.
An attacker who alters the message will be unable to alter the associated MAC value without knowledge
of the secret key.
Message Authentication Requirements:
In the context of communications across a network, the following attacks can beidentified.
1. Disclosure: Release of message contents to any person or process not possessing
2. the appropriate cryptographic key.
3. Traffic analysis: Discovery of the pattern of traffic between parties. In a connection-oriented
application, the frequency and duration of connections could be determined. In either a connection-
oriented or connectionless environment, the number and length of messages between parties could be
determined.
4. Masquerade: Insertion of messages into the network from a fraudulent source. This includes the
creation of messages by an opponent that are purported to come from an authorized entity. Also
included are fraudulent acknowledgments of message receipt or nonreceipt by someone other than the
message recipient.
5. Content modification: Changes to the contents of a message, including insertion, deletion,
transposition, and modification.
6. Sequence modification: Any modification to a sequence of messages between parties, including
insertion, deletion, and reordering.
7. Timing modification: Delay or replay of messages. In a connection-oriented application, an entire
session or sequence of messages could be a replay of some previous valid session, or individual
messages in the sequence could be delayed or replayed. In a connectionless application, an individual
message (e.g., datagram) could be delayed or replayed.
8. Source repudiation: Denial of transmission of message by source.
9. Destination repudiation: Denial of receipt of message by destination.
Message Encryption:
Message encryption by itself can provide a measure of authentication. The analysis differs for
symmetric and public-key encryption schemes.
Symmetric Encryption:
Consider the straightforward use of symmetric encryption (Figure a).
A message M transmitted from source A to destination B is encrypted using a secret key K shared by
A and B. If no other party knows the key, then confidentiality is provided: No other party can recover
the plaintext of the message.
Measures to deal with the first two attacks are in the realm of message confidentiality and are dealt with
in Encryption techniques.
Measures to deal with items (3) through (6) in the foregoing list are generally regarded as message
authentication.
Mechanisms for dealing specifically with item (7) come under the heading of digital signatures.
Generally, a digital signature technique will also counter some or all of the attacks listed under items (3)
through (6). Dealing with item (8) may require a combination of the use of digital signatures and a
protocol designed to counter this attack.
In summary, message authentication is a procedure to verify that received messages come from the alleged
source and have not been altered.
Message authentication may also verify sequencing and timeliness.
A digital signature is an authentication technique that also includes measures to counter repudiation by
the source.
Public-Key Encryption:
The straightforward use of public-key encryption (Figure b) provides confidentiality but not
authentication.
The source (A) uses the public key PUb of the destination (B) to encrypt M. Because only B has the
corresponding private key PRb, only B can decrypt the message. This scheme provides no
authentication, because any opponent could also use B’s public key to encrypt a message and claim to
be A.
To provide authentication, A uses its private key to encrypt the message, and B uses A’s public key to
decrypt (Figure c). This provides authentication using the same type of reasoning as in the symmetric
encryption case: The message must have come from A because A is the only party that possesses PRa
and therefore the only party with the information necessary to construct ciphertext that can be decrypted
with PUa.
There must be some internal structure to the plaintext so that the receiver can distinguish between
well-formed plaintext and random bits.
Assuming there is such structure, then the scheme of Figure c does provide authentication. It also
provides what is known as digital signature.
Only A could have constructed the ciphertext because only A possesses PRa. Not even B, the recipient,
could have constructed the ciphertext. Therefore, if B is in possession of the ciphertext, B has the means
to prove that the message must have come from A.
In effect, A has “signed” the message by using its private key to encrypt.
Note that this scheme does not provide confidentiality. Anyone in possession of A’s public key can
decrypt the cipher text.
To provide both confidentiality and authentication, A can encrypt M first using its private key, which
provides the digital signature, and then using B’s public key, which provides confidentiality (Figure d).
The disadvantage of this approach is that the public-key algorithm, which is complex, must be exercised
four times rather than two in each communication.
The process depicted in Figure (a) provides authentication but not confidentiality, because the
message as a whole is transmitted in the clear.
Confidentiality can be provided by performing message encryption either after (Figure b) or before
(Figure c) the MAC algorithm.
In both these cases, two separate keys are needed, each of which is shared by the sender and the receiver.
In the first case, the MAC is calculated with the message as input and is then concatenated to the message.
The entire block is then encrypted. In the second case, the message is encrypted first.
Then the MAC is calculated using the resulting ciphertext and is concatenated to the ciphertext to form
the transmitted block.
Typically, it is preferable to tie the authentication directly to the plaintext, so the method of Figure b is
used.
MACs based on hash functions: HMAC
HMAC Design Objectives
RFC 2104 lists the following design objectives for HMAC.
• To use, without modifications, available hash functions. In particular, to use hash functions that perform
well in software and for which code is freely and widely available.
• To allow for easy replaceability of the embedded hash function in case faster or more secure hash
functions are found or required.
• To preserve the original performance of the hash function without incurring a significant degradation.
• To use and handle keys in a simple way.
• To have a well understood cryptographic analysis of the strength of the authentication mechanism based
on reasonable assumptions about the embedded hash function.
HMAC Algorithm
H = embedded hash function (e.g., MD5, SHA-1, RIPEMD-160)
IV = initial value input to hash function
M = message input to HMAC (including the padding specified in the embeddedhash function)
Yi _ i th block of M, 0 ≤i ≤(L – 1)
L _ number of blocks in M
b _ number of bits in a block
n _ length of hash code produced by embedded hash function
K _ secret key; recommended length is ≥n; if key length is greater than b,
the key is input to the hash functionto produce an n-bit key
K+ _ K padded with zeros on the left so that the result is b bits in length
ipad _ 00110110 (36 in hexadecimal) repeated b/8 times
opad _ 01011100 (5C in hexadecimal) repeated b/8 times
MD5 is a message digest algorithm developed by Ron Rivest. MD5 is quite fast and produces
128-bit message digests. Over the years, researchers have developed potential weaknesses in
MD5. However, so far, MD5 has been able to successfully defend itself against collisions.
This may not be guaranteed for too long, though.
After some initial processing, the input text is processed in 512-bit blocks (which are further
divided into 16 32-bit sub-blocks). The output of the algorithm is a set of four 32-bit blocks,
which make up the 128-bit message digest.
Step 1: Padding :The first step in MD5 is to add padding bits to the original message. The aim
of this step is to make the length of the original message equal to a value, which is 64bits
less than an exact multiple of 512. For example, if the length of the original message is 1000
bits, we add a padding of 472 bits to make the length of the message 1472 bits. This is
because, if we add 64 to 1472, we get 1536, which is a multiple of 512 (because 1536 = 512 x
3).
Thus, after padding, the original message will have a length of 448 bits (64 bits less than
512), 960 bits (64 bits less than 1024), 1472 bits (64 bits less than 1536), etc. The padding
consists of a single 1-bit, followed by as many 0-bits, as required. Note that padding is
always added, even if the message length is already 64 bits less than a multiple of 512. Thus,
if the message were already of length say 448 bits, we will add a padding of 512 bits to make
its length 960 bits. Thus, the padding length is any value between 1 and 512.
Step 2: Append length After padding bits are added, the next step is to calculate the original
length of the message and add it to the end of the message, after padding. The length of the
message is calculated, excluding the padding bits. This length of the original message is now
expressed as a 64-bit value and these 64 bits are appended to the end of the original message
+ padding.
Step 3: Divide the input into 512-bit blocks Now, we divide the input message into blocks, each
of length 512 bits. (Refer fig )
Step 4: Initialize chaining variables In this step, four variables (called as chaining variables) are
initialized. They are called as A, B, C and D. Each of these is a 32-bit number. The initial
hexadecimal values of these chaining variables are shown in Fig. below.
Fig 3.10: Chaining Variables
Copy the four chaining variables into four corresponding variables, a, b, c and d.
After all the initializations, the real algorithm begins. There is a loop that runs for as many
512-bit blocks as are in the message. Now, we have four rounds. In each round, we process
all the 16 sub-blocks belonging to a block. The inputs to each round are: (a) all the 16 sub-
blocks, (b) the variables a, b, c, d and (c) some constants, designated as t.
All the four rounds vary in one major way: Step 1 of the four rounds has different
processing. The other steps in all the four rounds are the same. • In each round, we have 16
input sub-blocks, named M[0], M[1], …, M[15] or in general, M[i], where i varies from 0 to
15. As we know, each sub-block consists of 32 bits.
Let us summarize these iterations of all the four rounds. In each case, the output
of the intermediate as well as the final iteration is copied into the register abcd. Note that we
have 16 such iterations in each round.
1. A process P is first performed on b, c and d. This process P is different in all the four
rounds.
2. The variable a is added to the output of the process P (i.e. to the register abcd).
3. The message sub-block M[i] is added to the output of Step 2 (i.e. to the register abcd).
4. The constant t[k] is added to the output of Step 3 (i.e. to the register abcd).
5. The output of Step 4 (i.e. the contents of register abcd) is circular-left shifted by s bits.
(The value of s keeps changing).
6. The variable b is added to the output of Step 5 (i.e. to the register abcd).
7. The output of Step 6 becomes the new abcd for the next step
Fig 3.11: One MD5 operation
The National Institute of Standards and Technology (NIST) along with NSA
developed the Secure Hash Algorithm (SHA). In 1993. SHA is a modified version of
MD5 and its design closely resembles MD5. SHA works with any input message that isless
than 2
64 bits in length. The output of SHA is a message digest, which is 160 bits in length (32bits
more than the message digest produced by MD5). The word Secure in SHA was
decided based on two features. SHA is designed to be computationally infeasible to:
(a) Obtain the original message, given its message digest and
Step1 to 3 MD5 and SHA are same. In step 4 and process SHA differs from MD5.
Step 4: Initialize chaining variables Now, five chaining variables A through E are initialized.
Remember that we had four chaining variables, each of 32 bits in MD5 (whichmade the
total length of the variables 4 x 32 = 128 bits). Recall that we stored the intermediate as
well as the final results into the combined register made up of these four
chaining variables, i.e. abcd. Since in the case of SHA, we want to produce a message digest
of length 160 bits, we need to have five chaining variables here (5x32 = 160 bits). In
SHA, the variables A through D have the same values as they had in MD5. Additionally,
E is initialized to Hex C3 D2 E1 F0.
Step 5: Process blocks Now the actual algorithm begins. Here also, the steps are quitesimilar
to those in MD5. SHA has four rounds, each round consisting of 20 steps. Each round
takes the current 512- bit block, the register abcde and a constant K[t] (wheret = 0 to 79)
as the three inputs. It then updates the contents of the register abcde using the SHA
algorithm steps. Also notable is the fact that we had 64 constants defined as t in MD5.
Here, we have only four constants defined for K[t], one used in each of the four rounds.
Other Applications:
Hash functions are commonly used to create a one-way password file.
Hash functions can be used for intrusion detection and virus detection.
A cryptographic hash function can be used to construct a pseudorandom function (PRF) or a
pseudorandom number generator (PRNG).
Confidentiality can be provided by encrypting the entire message plus signature with a shared secret key
(Symmetric encryption). Note that it is important to perform the signature function first and then an
outer confidentiality function.
In case of dispute, some third party must view the message and its signature. If the signature is
calculated on an encrypted message, then the third party also needs access to the decryption key to read the
original message. However, if the signature is the inner operation, then the recipient can store the plaintext
message and its signature for later use in dispute resolution.
The validity of the scheme just described depends on the security of the sender’s private key.
If a sender later wishes to deny sending a particular message, the sender can claim that the private key was
lost or stolen and that someone else forged his or her signature. Administrative controls relating to the
security of private keys can be employed to thwart or at least weaken this ploy, but the threat is still there,
at least to some degree. One example is to require every signed message to include a timestamp (date and
time) and to require prompt reporting of compromised keys to a central authority.
Another threat is that a private key might actually be stolen from X at time T. The opponent can then
send a message signed with X’s signature and stamped with a time before or equal to T.
Digital Signature Schemes
The Digital Signature Schemes are the mathematical cryptographic primitives used to
Achieve authentication, integrity and non-repudiation.
There are different types of Digital Signature schemes. They are
1.Elgamal Digital Signature Scheme
2.Schnorr Digital Signature Scheme
1. Choose a random integer K such that 1 … K … q - 1 and gcd(K, q - 1) = 1.That is, K is relatively prime to q - 1.
2. Compute S1 = aK mod q. Note that this is the same as the computation of C1 for Elgamal encryption.
3. Compute K-1 mod (q - 1). That is, compute the inverse of K modulo q - 1.
4. Compute S2 = K-1(m - XAS1) mod (q - 1).
5. The signature consists of the pair (S1, S2).
Step 3.Signature Verification
Any user B can verify the signature as follows.
1. Compute V1 = am mod q.
2. Compute V2 = (YA)S1(S1)S2 mod q.
The signature is valid if V1 = V2. Let us demonstrate that this is so. Assume that the equality is true.
2. Blind Signature
*Purpose: To get a signature without revealing the message content.
*Use Case: When the sender and signer are different parties.
*Example Schemes: RSA and DSS
The signature generation and verification process involves the following steps
1.Key Generation
The signer generates a pair of keys, a private key and a public key. The private key is kept secret and user for
signing messages,While the public key is shared with others for verifying signatures.
2.Hashing
The signer calculates a hash value of the message to be signed using a cryptographic hash function. This creates
a fixed length digest of the message that is unique to that message.
3.Signature Generation
The signer generates a signature using their private key and the hash value of the message. The signature consists of
two components r and s, which are derived from the private key, the value of the message, and a random number is called
“ephemeral key”
4.Signature verification
The recipient of the message calculates the hash value of the message using the cryptographic hash function used by
the signer. The signer public key and the signature components r and s to verify the signature.
1.Rivest-Shamir-Adleman (RSA)
2.Digital Signature Algorithm (DSA)
M = Message or Plaintext
H = Hash Function
|| = bundle the plantext and hash function (hash digest)
E = Encryption Algorithm
D = Decryption Algorithm
PUa = Public key of sender
PRa = Private key of sender
The verification function depends on the global public key as well as the sender’s public key (PUa) which is
paired with the sender’s private key. The output of the verification function returns a value equal to the signature’s
component r, if the signature is valid. The signature function is designed in such a way that only the sender, with
knowledge of the private key, can produce a valid signature.
DIGITAL SIGNATURES:
These are the public-key primitives of message authentication. In the physical
world, it is common to use handwritten signatures on handwritten or typed messages. They
are used to bind signatory to the message. Similarly, a digital signature is a technique that
binds a person/entity to the digital data. This binding can be independently verified by
receiver as well as any third party. Digital signature is a cryptographic value that is calculated
from the data and a secret key known only by the signer.
As mentioned earlier, the digital signature scheme is based on public key cryptography. The
model of digital signature scheme is depicted in the following illustration.
Signing large data through modular exponentiation is computationally expensive and time
consuming. The hash of the data is a relatively small digest of the data, hence signing a hash
is more efficient than signing the entire data.
• The signature must be a bit pattern that depends on the message being signed.
• The signature must use some information unique to the sender to prevent both forgery
and denial.
: KERBEROS
The job of AS is to authenticate every use at the login time. AS shares a unique
secret password with every user.
The job of TGS is to certify to the servers in the network that a user is really what she
claims to be. For proving this, the mechanism of tickets (which allow entry into a
Server, just as a ticket allows parking a car or entering a music concert) is used.
Step 1: Login To start with, Alice, the user, sits down at an arbitrary public workstation and
enters her name. The work station sends her name in plain text to the AS.
In response, the AS performs several actions. It first creates a package of the user name (Alice)
and a randomly generated session key (KS). It encrypts this package with the symmetric key that
the AS shares with the Ticket Granting Server (TGS). The output of this step is called as the
Ticket Granting Ticket (TGT). Note that the TGT can be opened only by the TGS, since only it
possesses the corresponding symmetric key for decryption.
The AS then combines the TGT with the session key (KS), and encrypts the two together using a
symmetric key derived from the password of Alice (KA). Note that the final output can,
therefore, be opened only by Alice.
• The current timestamp, encrypted with the same session key (KS)
As we know, the TGT is encrypted with the secret key of the Ticket Granting Server
(TGS). Therefore, only the TGS can open it. This also serves as a proof to the TGS that the
message indeed came from Alice. Why? This is because, if you remember, the TGT was
created by the AS (remember that only the AS and the TGS know the secret key of TGS).
Furthermore, the TGT and the KS were encrypted together by the AS with the secret key
derived from the password of Alice. Therefore, only Alice could have opened that package
and retrieved the TGT. Once the TGS is satisfied of the credentials of Alice, the TGS creates
a session key KAB, for Alice to have secure communication with Bob. TGS sends it twice to
Alice: once combined with Bob’s id (Bob) and encrypted with the session key (KS) and a
second time, combined with Alice’s id (Alice) and encrypted with Bob’s secret key (KB).
This is shown in Fig. below.
Now how would Alice know if Bob received KAB correctly or not? In order
to satisfy this query, Bob now adds 1 to the timestamp sent by Alice, encrypts the result with
KAB and sends it back to Alice. This is shown in Fig. above. Since only Alice and Bob know
KAB, Alice can open this packet and verify that the timestamp incremented by Bob was
indeed the one sent by her to Bob in the first place. Now, Alice and Bob can communicate
securely with each other. They would use the shared secret key KAB to encrypt messages
before sending and also to decrypt the encrypted messages received from each other.
Fig.3.19: Acknowledgement
X.509 CERTIFICATES
X.509 defines a framework for the provision of authentication services by the X.500
directory to its users. The directory may serve as a repository of public-key certificates. Each
certificate contains the public key of a user and is signed with the private key of a trusted
certification authority. In addition, X.509 defines alternative authentication protocols based
on the use of public-key certificates. X.509 is an important standard because the certificate
structure and authentication protocols defined in X.509 are used in a variety of contexts. For
example, the X.509 certificate format is used in S/MIME, IP Security, and SSL/TLS
Certificates The heart of the X.509 scheme is the public-key certificate associated with each
user. These user certificates are assumed to be created by some trusted certification authority
(CA) and placed in the directory by the CA or by the user. The directory server itself is not
responsible for the creation of public keys or for the certification function; it merely provides
an easily accessible location for users to obtain certificates
• Serial number: An integer value, unique within the issuing CA, that is
unambiguously associated with this certificate.
• Issuer name: X.500 name of the CA that created and signed this certificate.
• Period of validity: Consists of two dates: the first and last on which the certificate is valid.
• Subject name: The name of the user to whom this certificate refers. That is,
this certificatecertifies the public key of the subject who holds the corresponding
private key.
• Issuer unique identifier: An optional bit string field used to identify uniquely
the issuing CA in the event the X.500 name has been reused for different entities.
• Signature: Covers all of the other fields of the certificate; it contains the hash code
of the other fields encrypted with the CA’s private key. This field includes the
signature algorithm identifier.