Network Security MAC
Network Security MAC
MAC
Kamalika Bhattacharjee
Message Authentication Requirements
1. Disclosure: Release of message contents to any person or process not possessing the
cryptographic key.
2. Traffic analysis: Discovery of the pattern of traffic between parties.
• connection-oriented application → frequency and duration of connections can be
determined Message
Confidentiality
• In general, the number and length of messages between parties could be determined.
➢ Digital signature is an authentication technique that also includes measures to counter repudiation by source.
• A digital signature technique will also counter some or all of the attacks from (3) through (6).
Message Authentication Requirements
• Any message authentication or digital signature mechanism has two levels of
functionality.
• At the lower level, a function exists that produces an authenticator: a value to be used to
authenticate a message.
• This lower-level function is then used as a primitive in a higher-level authentication protocol
that enables a receiver to verify the authenticity of a message.
• Confidentiality: If no other party knows the key, then confidentiality is provided: No other party
can recover the plaintext of the message
• Authentication: B is assured that the message was generated by A.
• The message must have come from A, because A is the only other party that possesses K and
therefore the only other party with the information necessary to construct ciphertext that can be
decrypted with K
Message Encryption
• Symmetric Encryption
• Given a decryption function D and a secret key K, the destination will accept any input X and
produce output Y = D(K, X).
• If X is the ciphertext of a legitimate message M produced by the corresponding encryption
function, then Y is some plaintext message M. Otherwise, Y will likely be a meaningless
sequence of bits.
• If the message M can be any arbitrary bit pattern, there is no way to determine
automatically, at the destination, whether an incoming message is the ciphertext of a
legitimate message.
• If M can be any bit pattern, then regardless of the value of X, the value Y = D(K, X) is
some bit pattern and therefore must be accepted as authentic plaintext.
• Only a small subset of all possible bit patterns be considered legitimate plaintext.
• Difficult to determine automatically if incoming ciphertext decrypts to intelligible plaintext.
• binary object file or digitized X-rays
• An opponent could achieve a certain level of disruption simply by issuing messages with
random content purporting to come from a legitimate user.
Message Encryption
• Symmetric Encryption
• Solution to this problem is to force the plaintext to have some structure
• Append an error-detecting code, a frame check sequence (FCS) or checksum, to each
message before encryption
• Disadvantage: public-key algorithm, which is complex, must be exercised four times rather
than two in each communication
Message Authentication Code
• Use a secret key to generate a small fixed-size block of data, known as a cryptographic checksum
or MAC, that is appended to the message.
• Assumes that two communicating parties, say A and B, share a common secret key K.
• When A has a message to send to B, it calculates the MAC as a function of the message and the
key:
MAC = C(K, M)
Where M = input message, C = MAC function, K = shared secret key,
MAC = message authentication code
Message Authentication Code
• The receiver is assured that the message has not been altered. Because the attacker is assumed
not to know the secret key, the attacker cannot alter the MAC to correspond to the alterations in
the message.
• The receiver is assured that the message is from the alleged sender. Because no one else knows
the secret key, no one else could prepare a message with a proper MAC.
• If the message includes a sequence number (such as is used with HDLC, X.25, and TCP), then the
receiver can be assured of the proper sequence because an attacker cannot successfully alter the
sequence number.
Message Authentication Code
• Authentication and Confidentiality
Typically, this is
preferred
In both these cases, two separate keys are needed, each of which is shared by the sender and the receiver
Message Authentication Code
• Situations where MAC is used:
• If same message is broadcast to a number of destinations: It is cheaper and more reliable to
have only one destination responsible for monitoring authenticity. Thus, the message must be
broadcast in plaintext with an associated message authentication code.
• An exchange in which one side has a heavy load and cannot afford time to decrypt all incoming
messages. Authentication is carried out on a selective basis, messages chosen at random
• Authentication of a computer program in plaintext is an attractive service. MAC could be
checked whenever assurance was required of the integrity of the program.
• For some applications, it may not be of concern to keep messages secret, but it is important to
authenticate messages. Example: Simple Network Management Protocol Version 3 (SNMPv3)
• Separation of authentication and confidentiality functions affords architectural flexibility
• A user may wish to prolong the period of protection beyond the time of reception and yet allow
processing of message contents. With message encryption, the message is protected against
fraudulent modifications only in transit but not within the target system.
➢ MAC does not provide a digital signature, because both sender and receiver share the same key.
Requirements of Message Authentication Code
• A MAC function is similar to encryption. One difference is that the MAC algorithm need not be
reversible, as it must be for decryption.
• In general, the MAC function is a many-to-one function.
• The domain of the function consists of messages of some arbitrary length, whereas the range
consists of all possible MACs and all possible keys.
MAC = C(K, M)
Where M = input message, C = MAC function, K = shared secret key,
MAC = message authentication code/ fixed-length authenticator/ tag
• Tag is appended to the message at the source at a time when the message is assumed or known
to be correct. The receiver authenticates that message by recomputing the tag.
• If an n-bit MAC is used, then there are 2^n possible MACs, whereas there are N possible
messages with N >> 2^n
• With a k-bit key, there are 2^k possible keys.
Requirements of Message Authentication Code
• If entire message is encrypted for confidentiality, then for a brute-force attack using all possible
keys, on average, will require 2𝑘−1 attempts for a k-bit key.
• For a ciphertext-only attack, the opponent, given ciphertext C, performs Pi = D(Ki, C) for all
possible key values Ki until a Pi is produced that matches the form of acceptable plaintext.
• Thus, a brute-force attempt to discover the authentication key is no less effort and may be
more effort than that required to discover a decryption key of the same length.
Requirements of Message Authentication Code
• However, other attacks that do not require the discovery of the key are possible.
• Consider message M = (X1 ||X2|| … ||Xm), a concatenation of 64-bit blocks Xi.
• Define Δ(M) = X1 ⊕X2 ⊕ … ⊕Xm
MAC(K, M) = E(K, Δ(M))
where ⊕ is the exclusive-OR (XOR) operation and encryption algorithm is DES
• So, key length is 56 bits, and tag length is 64 bits.
• If an opponent observes {M||MAC(K, M)}, a brute-force attempt to determine K will require at
least 2^{56} encryptions.
• Opponent can attack by replacing X1 through Xm-1 with any desired values Y1 through Ym-1 and
replacing Xm with Ym, where Ym is calculated as
Ym = Y1 ⊕Y2 ⊕ … ⊕Ym-1⊕ Δ(M)
The opponent can now concatenate the new message, using the original tag to form a message that
will be accepted as authentic by the receiver.
With this tactic, any message of length 64 * (m - 1) bits can be fraudulently inserted.
Requirements of Message Authentication Code
1. If an opponent observes M and MAC(K, M), it should be computationally infeasible for the
opponent to construct a message M′ such that MAC(K, M′) = MAC(K, M)
• The case when an opponent is able to construct a new message to match a given tag, even though the
opponent does not know and does not learn the key.
2. MAC(K, M) should be uniformly distributed in the sense that for randomly chosen messages, M
1
and M′, the probability that MAC(K, M) = MAC(K, M′) is 𝑛 , where n is the number of bits in tag.
2
• The need to thwart a brute-force attack based on chosen plaintext. If the MAC function exhibits uniform
distribution, then a brute-force method would require, on average, 2^(n-1) attempts before finding a
message that fits a given tag.
3. Let M′ be equal to some known transformation on M. That is, M′ = f(M). Then, Pr [MAC(K, M) =
1
MAC(K, M′)] = 𝑛
2
• The authentication algorithm should not be weaker with respect to certain parts or bits of message than
others. An opponent who had M and MAC(K, M) should not be able to find variations on M at the known
“weak spots” with a likelihood of early success at producing a new message that matched the old tags.
Security of Message Authentication Code
• Brute-force Attacks
• More difficult undertaking than a brute-force attack on a hash function as it requires known
message-tag pairs.
• To attack: Given a fixed message x with n-bit hash code h = H(x), a brute-force method of
finding a collision is to pick a random bit string y and check if H(y) = H(x).
• The attacker can do this repeatedly off line.
• The attacker would like to come up with the valid MAC code for a given message x.
• Two lines of attack possible:
• attack the key space
• attack the MAC value
Security of Message Authentication Code
• Brute-force Attacks
• If an attacker can determine the MAC key, then it is possible to generate a valid MAC value
for any input x.
• Suppose the key size is k bits and that the attacker has one known text-tag pair. Then the
attacker can compute the n-bit tag on the known text for all possible keys.
• At least one key is guaranteed to produce the correct tag, namely, the valid key that was
initially used to produce the known text-tag pair.
• This phase of the attack takes a level of effort proportional to 2^k
• MAC is a many-to-one mapping, other keys may also produce the correct value.
• Thus, if more than one key is found to produce the correct value, additional text-tag pairs
must be tested.
• It can be shown that the level of effort drops off rapidly with each additional text-MAC pair
and that the overall level of effort is roughly 2^k.
Security of Message Authentication Code
• Brute-force Attacks
• An attacker can also work on the tag without attempting to recover the key.
• Objective: generate a valid tag for a given message or find a message that matches a given tag
• level of effort is comparable to that for attacking one-way or weak collision-resistant property
of a hash code, that is 2^n.
• The attack cannot be conducted off line without further input; the attacker will require chosen
text-tag pairs or knowledge of the key.
➢ Level of effort for brute-force attack on a MAC algorithm is min(2^k, 2^n). The key length and tag
length should satisfy a relationship such as min(k, n) >= N, where N is in the range of 128 bits.
• Cryptanalysis:
• seek to exploit some property of the algorithm to perform some attack other than an
exhaustive search.
• The way to measure the resistance of a MAC algorithm to cryptanalysis is to compare its
strength to the effort required for a brute-force attack.
• An ideal MAC algorithm requires effort greater than or equal to the brute-force effort.
Cryptographic Hash Functions
• A hash function H accepts a variable-length block of data M as input and
produces a fixed-size hash value h = H(M).
• A “good” hash function has the property that the results of applying the function
to a large set of inputs will produce outputs that are evenly distributed and
apparently random
• The principal object of a hash function is data integrity. A change to any bit or
bits in M results, with high probability, in a change to the hash value.
• Iterated Hash Function
• All cryptographic hash functions need to create a fixed-size digest out of a variable-
size message. This is best accomplished using iteration.
• Instead of using a hash function with variable-size input, a function with fixed-size
input is created and is used a necessary number of times.
• The fixed-size input function is referred to as a compression function. It compresses
an n-bit string to create an m-bit string where n is normally greater than m.
• The scheme is referred to as an iterated cryptographic hash function.
Merkle-Damgard Scheme
• Iterated Hash Function
• One basic requirement is that it should be computationally infeasible to find two
distinct messages that hash to the same value.
• It is collision resistant if the compression function is collision resistant
Merkle-Damgard Scheme
Two Groups of Compression Functions
• We can design a compression function that is collision resistant and insert it in
the Merkle-Damgard scheme.
• Two Approaches:
• First, the compression function is made from scratch: it is particularly
designed for this purpose.
• Message Digest (MD), Secure Hash Algorithm (SHA), RACE Integrity Primitives Evaluation
Message Digest (RIPMED)
• HAVAL is a variable-length hashing algorithm with a message digest of size 128, 160, 192,
224, and 256. The block size is 1024 bits
• Before the addition of the length field, we need to pad the original message to make the
length a multiple of 1024.
• The length of the padding field can be calculated as follows. Let |M| be the length of the
original message and |P| be the length of the padding field
RotRi(x) is actually a
circular shiftright
operation.
Example:
SHA-512
• Message Digest Initialization
• The values are calculated from the first eight prime numbers (2, 3, 5, 7, 11, 13, 17, and 19).
• Each value is the fraction part of the square root of the corresponding prime number after
converting to binary and keeping only the first 64 bits.
• Example: Eighth prime is 19, with the square root => 4.35889894354. Converting the number
to binary with only 64 bits in the fraction part, we get
• Rotate function
SHA-512
• The values of 80 constants are calculated
from the first 80 prime numbers (2, 3,…, 409).
• Each value is the fraction part of the cubic
root of the corresponding prime number after
converting it to binary and keeping only the
first 64 bits