rfc3218.txt
来自「RFC 的详细文档!」· 文本 代码 · 共 396 行 · 第 1/2 页
TXT
396 行
Network Working Group E. Rescorla
Request for Comments: 3218 RTFM, Inc.
Category: Informational January 2002
Preventing the Million Message Attack on
Cryptographic Message Syntax
Status of this Memo
This memo provides information for the Internet community. It does
not specify an Internet standard of any kind. Distribution of this
memo is unlimited.
Copyright Notice
Copyright (C) The Internet Society (2002). All Rights Reserved.
Abstract
This memo describes a strategy for resisting the Million Message
Attack.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 1
2. Overview of PKCS-1 . . . . . . . . . . . . . . . . . . . . . 2
2.1. The Million Message Attack . . . . . . . . . . . . . . . . 3
2.2. Applicability . . . . . . . . . . . . . . . . . . . . . . . 3
2.2.1. Note on Block Cipher Padding . . . . . . . . . . . . . . 4
2.3. Countermeasures . . . . . . . . . . . . . . . . . . . . . . 4
2.3.1. Careful Checking . . . . . . . . . . . . . . . . . . . . 4
2.3.2. Random Filling . . . . . . . . . . . . . . . . . . . . . 5
2.3.3. OAEP . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.4. Security Considerations . . . . . . . . . . . . . . . . . . 6
3. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 6
4. References . . . . . . . . . . . . . . . . . . . . . . . . . 6
5. Author's Address. . . . . . . . . . . . . . . . . . . . . . . 6
6. Full Copyright Statement . . . . . . . . . . . . . . . . . . 7
1. Introduction
When data is encrypted using RSA it must be padded out to the length
of the modulus -- typically 512 to 2048 bits. The most popular
technique for doing this is described in [PKCS-1-v1.5]. However, in
1998 Bleichenbacher described an adaptive chosen ciphertext attack on
SSL [MMA]. This attack, called the Million Message Attack, allowed
the recovery of a single PKCS-1 encrypted block, provided that the
Rescorla Informational [Page 1]
RFC 3218 Preventing the Million Message Attack on CMS January 2002
attacker could convince the receiver to act as a particular kind of
oracle. (An oracle is a program which answers queries based on
information unavailable to the requester (in this case the private
key)). The MMA is also possible against [CMS]. Mail list agents are
the most likely CMS implementations to be targets for the MMA, since
mail list agents are automated servers that automatically respond to
a large number of messages. This document describes a strategy for
resisting such attacks.
2. Overview of PKCS-1
The first stage in RSA encryption is to map the message to be
encrypted (in CMS a symmetric content-encryption key (CEK)) into an
integer the same length as (but numerically less than) the RSA
modulus of the recipient's public key (typically somewhere between
512 and 2048 bits). PKCS-1 describes the most common procedure for
this transformation.
We start with an "encryption block" of the same length as the
modulus. The rightmost bytes of the block are set to the message to
be encrypted. The first two bytes are a zero byte and a "block type"
byte. For encryption the block type is 2. The remaining bytes are
used as padding. The padding is constructed by generating a series
of non-zero random bytes. The last padding byte is zero, which
allows the padding to be distinguished from the message.
+---+---+----------------------+---+---------------------+
| 0 | 2 | Nonzero random bytes | 0 | Message |
+---+---+----------------------+---+---------------------+
Once the block has been formatted, the sender must then convert the
block into an integer. This is done by treating the block as an
integer in big-endian form. Thus, the resulting number is less than
the modulus (because the first byte is zero), but within a factor of
2^16 (because the second byte is 2).
In CMS, the message is always a randomly generated symmetric
content-encryption key (CEK). Depending on the cipher being used it
might be anywhere from 8 to 32 bytes.
There must be at least 8 bytes of non-zero padding. The padding
prevents an attacker from verifying guesses about the encrypted
message. Imagine that the attacker wishes to determine whether or
not two RSA-encrypted keys are the same. Because there are at least
255^8 (about 2^64) different padding values with high probability two
encryptions of the same CEK will be different. The padding also
prevents the attacker from verifying guessed CEKs by trial-encrypting
them with the recipient's RSA key since he must try each potential
Rescorla Informational [Page 2]
RFC 3218 Preventing the Million Message Attack on CMS January 2002
pad for every guess. Note that a lower cost attack would be to
exhaustively search the CEK space by trial-decrypting the content and
examining the plaintext to see if it appears reasonable.
2.1. The Million Message Attack
The purpose of the Million Message Attack (MMA) is to recover a
single plaintext (formatted block) given the ciphertext (encrypted
block). The attacker first captures the ciphertext in transit and
then uses the recipient as an oracle to recover the plaintext by
sending transformed versions of the ciphertext and observing the
recipient's response.
Call the ciphertext C. The attacker then generates a series of
integers S and computes C'=C*(S^e) mod n. Upon decryption, C'
produces a corresponding plaintext M'. Most values of M' will appear
to be garbage but some values of M' (about one in 2^16) will have the
correct first two bytes 00 02 and thus appear to be properly PKCS-1
formatted. The attack proceeds by finding a sequence of values S
such that the resulting M' is properly PKCS-1 formatted. This
information can be used to discover M. Operationally, this attack
usually requires about 2^20 messages and responses. Details can be
found in [MMA].
2.2. Applicability
Since the MMA requires so many messages, it must be mounted against a
victim who is willing to process a large number of messages. In
practice, no human is willing to read this many messages and so the
MMA can only be mounted against an automated victim.
The MMA also requires that the attacker be able to distinguish cases
where M' was PKCS-1 formatted from cases where it was not. In the
case of CMS the attacker will be sending CMS messages with C'
replacing the wrapped CEK. Thus, there are five possibilities:
1. M' is improperly formatted.
2. M' is properly formatted but the CEK is prima facie bogus (wrong
length, etc.)
3. M' is properly formatted and the CEK appears OK. A signature or
MAC is present so integrity checking fails.
4. M' is properly formatted and no integrity check is applied. In
this case there is some possibility (approximately 1/32) that the
CBC padding block will verify properly. (The actual probability
depends highly on the receiving implementation. See "Note on
Block Cipher Padding" below). The message will appear OK at the
CMS level but will be bogus at the application level.
Rescorla Informational [Page 3]
RFC 3218 Preventing the Million Message Attack on CMS January 2002
5. M' is properly formatted and the resulting CEK is correct. This
is extremely improbable but not impossible.
The MMA requires the attacker to be able to distinguish case 1 from
cases 2-4. (He can always distinguish case 5, of course). This
might happen if the victim returned different errors for each case.
The attacker might also be able to distinguish these cases based on
timing -- decrypting the message and verifying the signature takes
some time. If the victim responds uniformly to all four errors then
no attack is possible.
2.2.1. Note on Block Cipher Padding
[CMS] specifies a particular kind of block cipher padding in which
the final cipher block is padded with bytes containing the length of
the padding. For instance, a 5-byte block would be padded with three
bytes of value 03, as in:
XX XX XX XX XX 03 03 03
[CMS] does not specify how this padding is to be removed but merely
observes that it is unambiguous. An implementation might simply get
the value of the final byte and truncate appropriately or might
verify that all the padding bytes are correct. If the receiver
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?