1 Review: Message Authentication Codes (Macs)
Total Page:16
File Type:pdf, Size:1020Kb
EE 418 Network Security and Cryptography Lecture #15 November 22, 2016 Message Authentication Codes (MACs). Digital Signatures. Lecture notes prepared by Professor Radha Poovendran. Tamara Bonaci Department of Electrical Engineering University of Washington, Seattle Outline: 1. Review: Message Authentication Codes (MACs) { Review: MAC from Block Cipher: CBC-MAC 2. Introduction to Digital Signatures 3. RSA digital signature scheme 4. ElGamal digital signature scheme 5. Schnoor Digital signature scheme 6. The Digital signature algorithm 1 Review: Message Authentication Codes (MACs) Last time, we started our discussion about message authentication codes (MACs), and we defined a MAC as a code that is appended to a message in order to provide message integrity1. In MACs, communicating parties share a secret key that is used to generate the code, and if a MAC is well-designed, then only a user with the shared key can compute a valid MAC for a given message. Two parties Alice and Bob who share a key K can use a MAC for message integrity as follows (illustrated in Figure 1): 1. Alice computes a MAC for message m as y = MAC(K; m), and sends pair (m; y) through the channel to Bob. 2. Bob receives (m; y). Using the secret key, Bob computes MAC(K; m) and checks y =? MAC(K; m). 3. If y = MAC(K; m), then Bob accepts the message. Otherwise, Bob rejects the message, since the message and MAC are inconsistent. Alice Bob MAC Generation Computes y = MAC(K,m) from secret key K and message m [m, y] MAC Verification Extracts m, computes y’=MAC(K,m) If y + y’ =0, accept the message If y + y’≠ 0, discard the message Fig. 1. Block diagram for message integrity using a message authentication code (MAC). We said that there are two basic methods for constructing MACs. In the first method, the MAC is constructed by incorporating a key K into the hash function computation. In the second method, the MAC is constructed by using block encryption techniques. 1 Unlike a regular hash function, where the hash output needs to be exchanged via a secure side channel. 1 1.1 Review: MAC from Block Cipher: CBC-MAC We then showed another approach for constructing MACs, by using block ciphers. An advantage of using block ciphers to compute a MAC is that the same hardware or software implementation can be used for both encryption and authentication (but the best practice is to use different keys for encryption and message authentication). Block ciphers can also be used to develop authenticated encryption mechanisms, which provides both message confidentiality and integrity. The most common MAC construction using block ciphers is CBC-MAC, which is recommended by NIST 800-38B and NIST 800-38C. CBC-MAC computation is illustrated in Figure 2 and as Algorithm 1. CBC- n n MAC uses a symmetric key encryption function EK as a building block, with EK : f0; 1g ! f0; 1g (examples are DES with n = 64 or AES with n = 128). The steps in CBC-MAC computation are as follows: 1. The message m is divided into r blocks, each of length n, denoted m1; : : : ; mr. The last block is padded with zeros to ensure that the length is n. 2. The first iteration is computed as y1 = EK (m1 ⊕ IV ); where IV represents an initialization vector. 3. For each i = 2; : : : ; r, compute yi = EK (mi ⊕ yi−1). 4. The MAC value is given by CBC-MAC(K; m) = yr. Note that, unlike the CBC encryption mode, only the last block yr is transmitted. As in CBC encryption mode, either a fixed value of IV can be used, or a random value of IV can be used and sent along with the message. Algorithm 1 MAC construction using CBC encryption mode. 1: procedure CBC-MAC(m, h, K, IV ) 2: Input: Message m of length jmj = k, m = m1jj · · · jjmr where jmij = n. 3: Key K n n 4: Symmetric-key encryption function EK : f0; 1g ! f0; 1g . 5: Vector IV used to compute hash function. 6: Output: MAC value CBC-MAC(K; m) 7: y1 EK (m1 ⊕ IV ) 8: for i = 1;:::; (r − 1) do 9: yi+1 EK (mi+1 ⊕ yi) 10: end for 11: CBC-MAC(K; m) yr 12: return yr 13: end procedure 2 Digital Signatures A digital signature is a public-key mechanism for providing message integrity and authentication. Like public-key cryptosystems, a digital signature scheme requires two keys, a private (signing) key and a public (verifying) key. Any digital signature scheme includes the following basic steps, as depicted in Figure 3: 1. A user Alice generates a public key PKA and a private key SKA. Alice publishes the public key, while keeping the private key a secret. 2. A user Bob downloads PKA (later we will discuss methods for Bob to verify that the public key was generated by Alice, instead of a different user impersonating Alice). 3. Alice signs a message m using the private key SKA and a signing function sigSKA (m). Alice appends the σ = sigSKA (m) to message m and transmits it to Bob. 4. Bob receives the message and signature (m; σ). Bob computes a verification function verPKA (m; σ) using Alice's public key. If verPKA (m; σ) returns true, Bob accepts the message; otherwise, Bob concludes that the message has been modified and discards it. 2 m1 m2 m3 m4 m5 mr−1 mr IV ⊕ ⊕ ⊕ ⊕ ⊕ ⊕ ⊕ ··· E E E E E E E Enc. with secret key K y1 y2 y3 y4 y5 yr−1 yr CBC-MAC(K; m) Fig. 2. CBC-MAC computation. More formally, a digital signature can be defined as follows: Definition 1: A digital signature scheme is a five-tuple (P; A; K; S; V), where: 1. P is a finite set of possible messages. 2. A is a finite set of possible signatures. 3. K is a finite set of possible keys. 4. sigK (m) 2 S is a signing algorithm that takes as an input key K and message m and outputs a signature σ, often called a tag. 5. verK 2 V is a verification algorithm that takes as input a message m and a signature σ and outputs true if the signature is accepted, and false if the signature is not accepted. For every message m 2 P and signature σ 2 A, the verification algorithm verK (m; σ): P × A ! ftrue; falseg satisfies: verK (m; σ) = true; σ = sigK (m) (1) verK (m; σ) = false; σ 6= sigK (m) (2) Alice Bob True, accept =sigK(m) [m, ] m sigK(.) verK(.) False, reject K Fig. 3. Providing message integrity using digital signatures. The advantage of digital signatures is that Alice and Bob do not need to share a secret key K in order for Bob to verify a message sent by Alice. Signing is done with the private key SKA, while anyone can verify the signature using the public key PKA. In what follows, we will define four digital signature schemes, namely: (i) RSA, (ii) ElGamal, (iii) Schnorr, and (iv) the Digital Signature Algorithm (DSA), but let's first investigate a general security of digital signatures. 3 Security of Digital Signatures An attacker against digital signature schemes may have different capabilities, such as: 1. Key-only attack An attacker mounts the attack using only knowledge of the public key. 3 2. Known message attack An attacker possesses a list of valid (message, signature) pairs (x1; y1); (x2; y2);::: . This attacker model is analogous to the known plaintext attacker model. 3. Chosen message attack An attacker requests signatures for a set of messages x1; x2;::: , and obtains valid signatures, y1; y2;::: . This attacker model is analogous to chosen plaintext attack. An attacker may also have different goals, such as: 1. Total break: Recovery of the private key. 2. Selective forgery: An attacker is given a message m, and (s)he is able to find a signature σ such that verK (m; ) = true. 3. Existential forgery: An attacker is able to find at least one (m; σ) pair such that verK (m; σ)= true. 4 RSA Digital Signature Scheme The RSA digital signature scheme was proposed in 1978 by Rivest, Shamir, and Adelman in the same paper as the RSA cryptosystem. The RSA is one digital signature that is adopted by NIST in FIPS 186-4. Like RSA encryption, the security of RSA digital signatures relies on the difficulty of factoring large integers. The RSA digital signature consists of three components, namely Key Generation, Signature Generation, and Signature Verification. These components are described as follows. 4.1 RSA Key Generation Alice generates keys for the RSA digital signature scheme via the following procedure: 1. Alice generates two distinct large primes p and q. Alice computes n = pq. In FIPS 186-4, NIST recom- mends that p and q be chosen such that n is at least 1024 bits. Alice computes φ(n) = (p − 1)(q − 1). 2. Alice generates a random integer a satisfying gcd (a; n) = 1 and gcd (a; φ(n)) = 1. 3. Alice computes b such that ab ≡ 1 mod φ(n). 4. The public key PKA is given by (b; n), and is published by Alice. The private key is SKA = (a; n) and is kept secret. Note: The public key and private key for the RSA digital signature are generated in the same way as the public and private keys for RSA encryption. 4.2 RSA Signature Generation Alice generates a signature on a message m by computing: a sigSKA (m) = m mod n: We observe that signature generation in RSA is similar to encryption in the RSA cryptosystem.