idnits 2.17.1 draft-hoffman-pkcs-rsa-encrypt-02.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- ** Cannot find the required boilerplate sections (Copyright, IPR, etc.) in this document. Expected boilerplate is as follows today (2024-04-25) according to https://trustee.ietf.org/license-info : IETF Trust Legal Provisions of 28-dec-2009, Section 6.a: This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. IETF Trust Legal Provisions of 28-dec-2009, Section 6.b(i), paragraph 2: Copyright (c) 2024 IETF Trust and the persons identified as the document authors. All rights reserved. IETF Trust Legal Provisions of 28-dec-2009, Section 6.b(i), paragraph 3: This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- ** Missing expiration date. The document expiration date should appear on the first and last page. ** The document seems to lack a 1id_guidelines paragraph about Internet-Drafts being working documents. ** The document seems to lack a 1id_guidelines paragraph about the list of current Internet-Drafts. ** The document seems to lack a 1id_guidelines paragraph about the list of Shadow Directories. ** The document is more than 15 pages and seems to lack a Table of Contents. == No 'Intended status' indicated for this document; assuming Proposed Standard == It seems as if not all pages are separated by form feeds - found 0 form feeds but 18 pages Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack an Abstract section. ** The document seems to lack a Security Considerations section. ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) ** The document seems to lack separate sections for Informative/Normative References. All references will be assumed normative when checking for downward references. Miscellaneous warnings: ---------------------------------------------------------------------------- == Line 132 has weird spacing: '...en Boer and A...' == Line 212 has weird spacing: '... ab hexade...' -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (March 16, 1998) is 9537 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Possible downref: Non-RFC (?) normative reference: ref. 'DO86' -- Possible downref: Non-RFC (?) normative reference: ref. 'Has88' -- Possible downref: Non-RFC (?) normative reference: ref. 'IM90' -- Possible downref: Non-RFC (?) normative reference: ref. 'Mer90' -- Possible downref: Non-RFC (?) normative reference: ref. 'Mil76' -- Possible downref: Non-RFC (?) normative reference: ref. 'QC82' -- Possible downref: Non-RFC (?) normative reference: ref. 'RSA78' Summary: 10 errors (**), 0 flaws (~~), 4 warnings (==), 10 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 1 Internet Draft Burt Kaliski 2 Expires March 16, 1998 3 5 PKCS #1: RSA Encryption 6 Version 1.5 8 Status of this Memo 10 This document is an Internet-Draft. Internet-Drafts are working 11 documents of the Internet Engineering Task Force (IETF), its areas, 12 and its working groups. Note that other groups may also distribute 13 working documents as Internet-Drafts. 15 Internet-Drafts are draft documents valid for a maximum of six months 16 and may be updated, replaced, or obsoleted by other documents at any 17 time. It is inappropriate to use Internet-Drafts as reference 18 material or to cite them other than as "work in progress." 20 To learn the current status of any Internet-Draft, please check the 21 "1id-abstracts.txt" listing contained in the Internet-Drafts Shadow 22 Directories on ftp.is.co.za (Africa), nic.nordu.net (Europe), 23 munnari.oz.au (Pacific Rim), ds.internic.net (US East Coast), or 24 ftp.isi.edu (US West Coast). 26 This memo provides information for the Internet community. This memo 27 does not specify an Internet standard of any kind. Distribution of 28 this memo is unlimited. 30 Overview 32 This document describes a method for encrypting data using the RSA 33 public-key cryptosystem. 35 1. Scope 37 This document describes a method for encrypting data using the RSA 38 public-key cryptosystem. Its intended use is in the construction of 39 digital signatures and digital envelopes, as described in PKCS #7: 41 o For digital signatures, the content to be signed 42 is first reduced to a message digest with a 43 message-digest algorithm (such as MD5), and then 44 an octet string containing the message digest is 45 encrypted with the RSA private key of the signer 46 of the content. The content and the encrypted 47 message digest are represented together according 48 to the syntax in PKCS #7 to yield a digital 50 RFC nnn PKCS #1: RSA Encryption November 1993 52 signature. This application is compatible with 53 Privacy-Enhanced Mail (PEM) methods. 55 o For digital envelopes, the content to be enveloped 56 is first encrypted under a content-encryption key 57 with a content-encryption algorithm (such as DES), 58 and then the content-encryption key is encrypted 59 with the RSA public keys of the recipients of the 60 content. The encrypted content and the encrypted 61 content-encryption key are represented together 62 according to the syntax in PKCS #7 to yield a 63 digital envelope. This application is also 64 compatible with PEM methods. 66 The document also describes a syntax for RSA public keys and private 67 keys. The public-key syntax would be used in certificates; the 68 private-key syntax would be used typically in PKCS #8 private-key 69 information. The public-key syntax is identical to that in both X.509 70 and Privacy-Enhanced Mail. Thus X.509/PEM RSA keys can be used in 71 this document. 73 The document also defines three signature algorithms for use in 74 signing X.509/PEM certificates and certificate-revocation lists, PKCS 75 #6 extended certificates, and other objects employing digital 76 signatures such as X.401 message tokens. 78 Details on message-digest and content-encryption algorithms are 79 outside the scope of this document, as are details on sources of the 80 pseudorandom bits required by certain methods in this document. 82 2. References 84 FIPS PUB 46-1 National Bureau of Standards. FIPS PUB 46-1: 85 Data Encryption Standard. January 1988. 87 PKCS #6 RSA Laboratories. PKCS #6: Extended-Certificate 88 Syntax. Version 1.5, November 1993. 90 PKCS #7 RSA Laboratories. PKCS #7: Cryptographic Message 91 Syntax. Version 1.5, November 1993. 93 PKCS #8 RSA Laboratories. PKCS #8: Private-Key Information 94 Syntax. Version 1.2, November 1993. 96 RFC 1319 B. Kaliski. RFC 1319: The MD2 Message-Digest 97 Algorithm. April 1992. 99 RFC 1320 R. Rivest. RFC 1320: The MD4 Message-Digest 101 RFC nnn PKCS #1: RSA Encryption November 1993 103 Algorithm. April 1992. 105 RFC 1321 R. Rivest. RFC 1321: The MD5 Message-Digest 106 Algorithm. April 1992. 108 RFC 1423 D. Balenson. RFC 1423: Privacy Enhancement for 109 Internet Electronic Mail: Part III: Algorithms, 110 Modes, and Identifiers. February 1993. 112 X.208 CCITT. Recommendation X.208: Specification of 113 Abstract Syntax Notation One (ASN.1). 1988. 115 X.209 CCITT. Recommendation X.209: Specification of 116 Basic Encoding Rules for Abstract Syntax Notation 117 One (ASN.1). 1988. 119 X.411 CCITT. Recommendation X.411: Message Handling 120 Systems: Message Transfer System: Abstract Service 121 Definition and Procedures.1988. 123 X.509 CCITT. Recommendation X.509: The Directory-- 124 Authentication Framework. 1988. 126 [dBB92] B. den Boer and A. Bosselaers. An attack on the 127 last two rounds of MD4. In J. Feigenbaum, editor, 128 Advances in Cryptology---CRYPTO '91 Proceedings, 129 volume 576 of Lecture Notes in Computer Science, 130 pages 194-203. Springer-Verlag, New York, 1992. 132 [dBB93] B. den Boer and A. Bosselaers. Collisions for the 133 compression function of MD5. Presented at 134 EUROCRYPT '93 (Lofthus, Norway, May 24-27, 1993). 136 [DO86] Y. Desmedt and A.M. Odlyzko. A chosen text attack 137 on the RSA cryptosystem and some discrete 138 logarithm schemes. In H.C. Williams, editor, 139 Advances in Cryptology---CRYPTO '85 Proceedings, 140 volume 218 of Lecture Notes in Computer Science, 141 pages 516-521. Springer-Verlag, New York, 1986. 143 [Has88] Johan Hastad. Solving simultaneous modular 144 equations. SIAM Journal on Computing, 145 17(2):336-341, April 1988. 147 [IM90] Colin I'Anson and Chris Mitchell. Security defects 148 in CCITT Recommendation X.509--The directory 149 authentication framework. Computer Communications 150 Review, :30-34, April 1990. 152 RFC nnn PKCS #1: RSA Encryption November 1993 154 [Mer90] R.C. Merkle. Note on MD4. Unpublished manuscript, 155 1990. 157 [Mil76] G.L. Miller. Riemann's hypothesis and tests for 158 primality. Journal of Computer and Systems 159 Sciences, 13(3):300-307, 1976. 161 [QC82] J.-J. Quisquater and C. Couvreur. Fast 162 decipherment algorithm for RSA public-key 163 cryptosystem. Electronics Letters, 18(21):905-907, 164 October 1982. 166 [RSA78] R.L. Rivest, A. Shamir, and L. Adleman. A method 167 for obtaining digital signatures and public-key 168 cryptosystems. Communications of the ACM, 169 21(2):120-126, February 1978. 171 3. Definitions 173 For the purposes of this document, the following definitions apply. 175 AlgorithmIdentifier: A type that identifies an algorithm (by object 176 identifier) and associated parameters. This type is defined in X.509. 178 ASN.1: Abstract Syntax Notation One, as defined in X.208. 180 BER: Basic Encoding Rules, as defined in X.209. 182 DES: Data Encryption Standard, as defined in FIPS PUB 46-1. 184 MD2: RSA Data Security, Inc.'s MD2 message-digest algorithm, as 185 defined in RFC 1319. 187 MD4: RSA Data Security, Inc.'s MD4 message-digest algorithm, as 188 defined in RFC 1320. 190 MD5: RSA Data Security, Inc.'s MD5 message-digest algorithm, as 191 defined in RFC 1321. 193 modulus: Integer constructed as the product of two primes. 195 PEM: Internet Privacy-Enhanced Mail, as defined in RFC 1423 and 196 related documents. 198 RSA: The RSA public-key cryptosystem, as defined in [RSA78]. 200 private key: Modulus and private exponent. 202 RFC nnn PKCS #1: RSA Encryption November 1993 204 public key: Modulus and public exponent. 206 4. Symbols and abbreviations 208 Upper-case symbols (e.g., BT) denote octet strings and bit strings 209 (in the case of the signature S); lower-case symbols (e.g., c) denote 210 integers. 212 ab hexadecimal octet value c exponent 213 BT block type d private exponent 214 D data e public exponent 215 EB encryption block k length of modulus in 216 octets 217 ED encrypted data n modulus 218 M message p, q prime factors of modulus 219 MD message digest x integer encryption block 220 MD' comparative message y integer encrypted data 221 digest 222 PS padding string mod n modulo n 223 S signature X || Y concatenation of X, Y 224 ||X|| length in octets of X 226 5. General overview 228 The next six sections specify key generation, key syntax, the 229 encryption process, the decryption process, signature algorithms, and 230 object identifiers. 232 Each entity shall generate a pair of keys: a public key and a private 233 key. The encryption process shall be performed with one of the keys 234 and the decryption process shall be performed with the other key. 235 Thus the encryption process can be either a public-key operation or a 236 private-key operation, and so can the decryption process. Both 237 processes transform an octet string to another octet string. The 238 processes are inverses of each other if one process uses an entity's 239 public key and the other process uses the same entity's private key. 241 The encryption and decryption processes can implement either the 242 classic RSA transformations, or variations with padding. 244 6. Key generation 246 This section describes RSA key generation. 248 Each entity shall select a positive integer e as its public exponent. 250 Each entity shall privately and randomly select two distinct odd 251 primes p and q such that (p-1) and e have no common divisors, and 253 RFC nnn PKCS #1: RSA Encryption November 1993 255 (q-1) and e have no common divisors. 257 The public modulus n shall be the product of the private prime 258 factors p and q: 260 n = pq . 262 The private exponent shall be a positive integer d such that de-1 is 263 divisible by both p-1 and q-1. 265 The length of the modulus n in octets is the integer k satisfying 267 2^(8(k-1)) <= n < 2^(8k) . 269 The length k of the modulus must be at least 12 octets to accommodate 270 the block formats in this document (see Section 8). 272 Notes. 274 1. The public exponent may be standardized in 275 specific applications. The values 3 and F4 (65537) 276 may have some practical advantages, as noted in 277 X.509 Annex C. 279 2. Some additional conditions on the choice of primes 280 may well be taken into account in order to deter 281 factorization of the modulus. These security 282 conditions fall outside the scope of this 283 document. The lower bound on the length k is to 284 accommodate the block formats, not for security. 286 7. Key syntax 288 This section gives the syntax for RSA public and private keys. 290 7.1 Public-key syntax 292 An RSA public key shall have ASN.1 type RSAPublicKey: 294 RSAPublicKey ::= SEQUENCE { 295 modulus INTEGER, -- n 296 publicExponent INTEGER -- e } 298 (This type is specified in X.509 and is retained here for 299 compatibility.) 301 The fields of type RSAPublicKey have the following meanings: 303 RFC nnn PKCS #1: RSA Encryption November 1993 305 o modulus is the modulus n. 307 o publicExponent is the public exponent e. 309 7.2 Private-key syntax 311 An RSA private key shall have ASN.1 type RSAPrivateKey: 313 RSAPrivateKey ::= SEQUENCE { 314 version Version, 315 modulus INTEGER, -- n 316 publicExponent INTEGER, -- e 317 privateExponent INTEGER, -- d 318 prime1 INTEGER, -- p 319 prime2 INTEGER, -- q 320 exponent1 INTEGER, -- d mod (p-1) 321 exponent2 INTEGER, -- d mod (q-1) 322 coefficient INTEGER -- (inverse of q) mod p } 324 Version ::= INTEGER 326 The fields of type RSAPrivateKey have the following meanings: 328 o version is the version number, for compatibility 329 with future revisions of this document. It shall 330 be 0 for this version of the document. 332 o modulus is the modulus n. 334 o publicExponent is the public exponent e. 336 o privateExponent is the private exponent d. 338 o prime1 is the prime factor p of n. 340 o prime2 is the prime factor q of n. 342 o exponent1 is d mod (p-1). 344 o exponent2 is d mod (q-1). 346 o coefficient is the Chinese Remainder Theorem 347 coefficient q-1 mod p. 349 Notes. 351 1. An RSA private key logically consists of only the 353 RFC nnn PKCS #1: RSA Encryption November 1993 355 modulus n and the private exponent d. The presence 356 of the values p, q, d mod (p-1), d mod (p-1), and 357 q-1 mod p is intended for efficiency, as 358 Quisquater and Couvreur have shown [QC82]. A 359 private-key syntax that does not include all the 360 extra values can be converted readily to the 361 syntax defined here, provided the public key is 362 known, according to a result by Miller [Mil76]. 364 2. The presence of the public exponent e is intended 365 to make it straightforward to derive a public key 366 from the private key. 368 8. Encryption process 370 This section describes the RSA encryption process. 372 The encryption process consists of four steps: encryption- block 373 formatting, octet-string-to-integer conversion, RSA computation, and 374 integer-to-octet-string conversion. The input to the encryption 375 process shall be an octet string D, the data; an integer n, the 376 modulus; and an integer c, the exponent. For a public-key operation, 377 the integer c shall be an entity's public exponent e; for a private- 378 key operation, it shall be an entity's private exponent d. The output 379 from the encryption process shall be an octet string ED, the 380 encrypted data. 382 The length of the data D shall not be more than k-11 octets, which is 383 positive since the length k of the modulus is at least 12 octets. 384 This limitation guarantees that the length of the padding string PS 385 is at least eight octets, which is a security condition. 387 Notes. 389 1. In typical applications of this document to 390 encrypt content-encryption keys and message 391 digests, one would have ||D|| <= 30. Thus the 392 length of the RSA modulus will need to be at least 393 328 bits (41 octets), which is reasonable and 394 consistent with security recommendations. 396 2. The encryption process does not provide an 397 explicit integrity check to facilitate error 398 detection should the encrypted data be corrupted 399 in transmission. However, the structure of the 400 encryption block guarantees that the probability 401 that corruption is undetected is less than 2-16, 403 RFC nnn PKCS #1: RSA Encryption November 1993 405 which is an upper bound on the probability that a 406 random encryption block looks like block type 02. 408 3. Application of private-key operations as defined 409 here to data other than an octet string containing 410 a message digest is not recommended and is subject 411 to further study. 413 4. This document may be extended to handle data of 414 length more than k-11 octets. 416 8.1 Encryption-block formatting 418 A block type BT, a padding string PS, and the data D shall be 419 formatted into an octet string EB, the encryption block. 421 EB = 00 || BT || PS || 00 || D . (1) 423 The block type BT shall be a single octet indicating the structure of 424 the encryption block. For this version of the document it shall have 425 value 00, 01, or 02. For a private- key operation, the block type 426 shall be 00 or 01. For a public-key operation, it shall be 02. 428 The padding string PS shall consist of k-3-||D|| octets. For block 429 type 00, the octets shall have value 00; for block type 01, they 430 shall have value FF; and for block type 02, they shall be 431 pseudorandomly generated and nonzero. This makes the length of the 432 encryption block EB equal to k. 434 Notes. 436 1. The leading 00 octet ensures that the encryption 437 block, converted to an integer, is less than the 438 modulus. 440 2. For block type 00, the data D must begin with a 441 nonzero octet or have known length so that the 442 encryption block can be parsed unambiguously. For 443 block types 01 and 02, the encryption block can be 444 parsed unambiguously since the padding string PS 445 contains no octets with value 00 and the padding 446 string is separated from the data D by an octet 447 with value 00. 449 3. Block type 01 is recommended for private-key 450 operations. Block type 01 has the property that 451 the encryption block, converted to an integer, is 453 RFC nnn PKCS #1: RSA Encryption November 1993 455 guaranteed to be large, which prevents certain 456 attacks of the kind proposed by Desmedt and 457 Odlyzko [DO86]. 459 4. Block types 01 and 02 are compatible with PEM RSA 460 encryption of content-encryption keys and message 461 digests as described in RFC 1423. 463 5. For block type 02, it is recommended that the 464 pseudorandom octets be generated independently for 465 each encryption process, especially if the same 466 data is input to more than one encryption process. 467 Hastad's results [Has88] motivate this 468 recommendation. 470 6. For block type 02, the padding string is at least 471 eight octets long, which is a security condition 472 for public-key operations that prevents an 473 attacker from recoving data by trying all possible 474 encryption blocks. For simplicity, the minimum 475 length is the same for block type 01. 477 7. This document may be extended in the future to 478 include other block types. 480 8.2 Octet-string-to-integer conversion 482 The encryption block EB shall be converted to an integer x, the 483 integer encryption block. Let EB1, ..., EBk be the octets of EB from 484 first to last. Then the integer x shall satisfy 486 k 487 x = SUM 2^(8(k-i)) EBi . (2) 488 i = 1 490 In other words, the first octet of EB has the most significance in 491 the integer and the last octet of EB has the least significance. 493 Note. The integer encryption block x satisfies 0 <= x < n since EB1 494 = 00 and 2^(8(k-1)) <= n. 496 8.3 RSA computation 498 The integer encryption block x shall be raised to the power c modulo 499 n to give an integer y, the integer encrypted data. 501 y = x^c mod n, 0 <= y < n . 503 RFC nnn PKCS #1: RSA Encryption November 1993 505 This is the classic RSA computation. 507 8.4 Integer-to-octet-string conversion 509 The integer encrypted data y shall be converted to an octet string ED 510 of length k, the encrypted data. The encrypted data ED shall satisfy 512 k 513 y = SUM 2^(8(k-i)) EDi . (3) 514 i = 1 516 where ED1, ..., EDk are the octets of ED from first to last. 518 In other words, the first octet of ED has the most significance in 519 the integer and the last octet of ED has the least significance. 521 9. Decryption process 523 This section describes the RSA decryption process. 525 The decryption process consists of four steps: octet-string- to- 526 integer conversion, RSA computation, integer-to-octet- string 527 conversion, and encryption-block parsing. The input to the decryption 528 process shall be an octet string ED, the encrypted data; an integer 529 n, the modulus; and an integer c, the exponent. For a public-key 530 operation, the integer c shall be an entity's public exponent e; for 531 a private-key operation, it shall be an entity's private exponent d. 532 The output from the decryption process shall be an octet string D, 533 the data. 535 It is an error if the length of the encrypted data ED is not k. 537 For brevity, the decryption process is described in terms of the 538 encryption process. 540 9.1 Octet-string-to-integer conversion 542 The encrypted data ED shall be converted to an integer y, the integer 543 encrypted data, according to Equation (3). 545 It is an error if the integer encrypted data y does not satisfy 0 <= 546 y < n. 548 9.2 RSA computation 550 The integer encrypted data y shall be raised to the power c modulo n 551 to give an integer x, the integer encryption block. 553 RFC nnn PKCS #1: RSA Encryption November 1993 555 x = y^c mod n, 0 <= x < n . 557 This is the classic RSA computation. 559 9.3 Integer-to-octet-string conversion 561 The integer encryption block x shall be converted to an octet string 562 EB of length k, the encryption block, according to Equation (2). 564 9.4 Encryption-block parsing 566 The encryption block EB shall be parsed into a block type BT, a 567 padding string PS, and the data D according to Equation (1). 569 It is an error if any of the following conditions occurs: 571 o The encryption block EB cannot be parsed 572 unambiguously (see notes to Section 8.1). 574 o The padding string PS consists of fewer than eight 575 octets, or is inconsistent with the block type BT. 577 o The decryption process is a public-key operation 578 and the block type BT is not 00 or 01, or the 579 decryption process is a private-key operation and 580 the block type is not 02. 582 10. Signature algorithms 584 This section defines three signature algorithms based on the RSA 585 encryption process described in Sections 8 and 9. The intended use of 586 the signature algorithms is in signing X.509/PEM certificates and 587 certificate-revocation lists, PKCS #6 extended certificates, and 588 other objects employing digital signatures such as X.401 message 589 tokens. The algorithms are not intended for use in constructing 590 digital signatures in PKCS #7. The first signature algorithm 591 (informally, "MD2 with RSA") combines the MD2 message-digest 592 algorithm with RSA, the second (informally, "MD4 with RSA") combines 593 the MD4 message-digest algorithm with RSA, and the third (informally, 594 "MD5 with RSA") combines the MD5 message- digest algorithm with RSA. 596 This section describes the signature process and the verification 597 process for the two algorithms. The "selected" message-digest 598 algorithm shall be either MD2 or MD5, depending on the signature 599 algorithm. The signature process shall be performed with an entity's 600 private key and the verification process shall be performed with an 601 entity's public key. The signature process transforms an octet string 602 (the message) to a bit string (the signature); the verification 604 RFC nnn PKCS #1: RSA Encryption November 1993 606 process determines whether a bit string (the signature) is the 607 signature of an octet string (the message). 609 Note. The only difference between the signature algorithms defined 610 here and one of the the methods by which signatures (encrypted 611 message digests) are constructed in PKCS #7 is that signatures here 612 are represented here as bit strings, for consistency with the X.509 613 SIGNED macro. In PKCS #7 encrypted message digests are octet strings. 615 10.1 Signature process 617 The signature process consists of four steps: message digesting, data 618 encoding, RSA encryption, and octet-string- to-bit-string conversion. 619 The input to the signature process shall be an octet string M, the 620 message; and a signer's private key. The output from the signature 621 process shall be a bit string S, the signature. 623 10.1.1 Message digesting 625 The message M shall be digested with the selected message- digest 626 algorithm to give an octet string MD, the message digest. 628 10.1.2 Data encoding 630 The message digest MD and a message-digest algorithm identifier shall 631 be combined into an ASN.1 value of type DigestInfo, described below, 632 which shall be BER-encoded to give an octet string D, the data. 634 DigestInfo ::= SEQUENCE { 635 digestAlgorithm DigestAlgorithmIdentifier, 636 digest Digest } 638 DigestAlgorithmIdentifier ::= AlgorithmIdentifier 640 Digest ::= OCTET STRING 642 The fields of type DigestInfo have the following meanings: 644 o digestAlgorithm identifies the message-digest 645 algorithm (and any associated parameters). For 646 this application, it should identify the selected 647 message-digest algorithm, MD2, MD4 or MD5. For 648 reference, the relevant object identifiers are the 649 following: 651 md2 OBJECT IDENTIFIER ::= 652 { iso(1) member-body(2) US(840) rsadsi(113549) 653 digestAlgorithm(2) 2 } md4 OBJECT IDENTIFIER ::= 655 RFC nnn PKCS #1: RSA Encryption November 1993 657 { iso(1) member-body(2) US(840) rsadsi(113549) 658 digestAlgorithm(2) 4 } md5 OBJECT IDENTIFIER ::= 659 { iso(1) member-body(2) US(840) rsadsi(113549) 660 digestAlgorithm(2) 5 } 662 For these object identifiers, the parameters field 663 of the digestAlgorithm value should be NULL. 665 o digest is the result of the message-digesting 666 process, i.e., the message digest MD. 668 Notes. 670 1. A message-digest algorithm identifier is included 671 in the DigestInfo value to limit the damage 672 resulting from the compromise of one message- 673 digest algorithm. For instance, suppose an 674 adversary were able to find messages with a given 675 MD2 message digest. That adversary might try to 676 forge a signature on a message by finding an 677 innocuous-looking message with the same MD2 678 message digest, and coercing a signer to sign the 679 innocuous-looking message. This attack would 680 succeed only if the signer used MD2. If the 681 DigestInfo value contained only the message 682 digest, however, an adversary could attack signers 683 that use any message digest. 685 2. Although it may be claimed that the use of a 686 SEQUENCE type violates the literal statement in 687 the X.509 SIGNED and SIGNATURE macros that a 688 signature is an ENCRYPTED OCTET STRING (as opposed 689 to ENCRYPTED SEQUENCE), such a literal 690 interpretation need not be required, as I'Anson 691 and Mitchell point out [IM90]. 693 3. No reason is known that MD4 would not be 694 sufficient for very high security digital 695 signature schemes, but because MD4 was designed to 696 be exceptionally fast, it is "at the edge" in 697 terms of risking successful cryptanalytic attack. 698 A message-digest algorithm can be considered 699 "broken" if someone can find a collision: two 700 messages with the same digest. While collisions 701 have been found in variants of MD4 with only two 702 digesting "rounds" [Mer90][dBB92], none have been 703 found in MD4 itself, which has three rounds. After 705 RFC nnn PKCS #1: RSA Encryption November 1993 707 further critical review, it may be appropriate to 708 consider MD4 for very high security applications. 710 MD5, which has four rounds and is proportionally 711 slower than MD4, is recommended until the 712 completion of MD4's review. The reported 713 "pseudocollisions" in MD5's internal compression 714 function [dBB93] do not appear to have any 715 practical impact on MD5's security. 717 MD2, the slowest of the three, has the most 718 conservative design. No attacks on MD2 have been 719 published. 721 10.1.3 RSA encryption 723 The data D shall be encrypted with the signer's RSA private key as 724 described in Section 7 to give an octet string ED, the encrypted 725 data. The block type shall be 01. (See Section 8.1.) 727 10.1.4 Octet-string-to-bit-string conversion 729 The encrypted data ED shall be converted into a bit string S, the 730 signature. Specifically, the most significant bit of the first octet 731 of the encrypted data shall become the first bit of the signature, 732 and so on through the least significant bit of the last octet of the 733 encrypted data, which shall become the last bit of the signature. 735 Note. The length in bits of the signature S is a multiple of eight. 737 10.2 Verification process 739 The verification process for both signature algorithms consists of 740 four steps: bit-string-to-octet-string conversion, RSA decryption, 741 data decoding, and message digesting and comparison. The input to the 742 verification process shall be an octet string M, the message; a 743 signer's public key; and a bit string S, the signature. The output 744 from the verification process shall be an indication of success or 745 failure. 747 10.2.1 Bit-string-to-octet-string conversion 749 The signature S shall be converted into an octet string ED, the 750 encrypted data. Specifically, assuming that the length in bits of the 751 signature S is a multiple of eight, the first bit of the signature 752 shall become the most significant bit of the first octet of the 753 encrypted data, and so on through the last bit of the signature, 754 which shall become the least significant bit of the last octet of the 756 RFC nnn PKCS #1: RSA Encryption November 1993 758 encrypted data. 760 It is an error if the length in bits of the signature S is not a 761 multiple of eight. 763 10.2.2 RSA decryption 765 The encrypted data ED shall be decrypted with the signer's RSA public 766 key as described in Section 8 to give an octet string D, the data. 768 It is an error if the block type recovered in the decryption process 769 is not 01. (See Section 9.4.) 771 10.2.3 Data decoding 773 The data D shall be BER-decoded to give an ASN.1 value of type 774 DigestInfo, which shall be separated into a message digest MD and a 775 message-digest algorithm identifier. The message-digest algorithm 776 identifier shall determine the "selected" message-digest algorithm 777 for the next step. 779 It is an error if the message-digest algorithm identifier does not 780 identify the MD2, MD4 or MD5 message-digest algorithm. 782 10.2.4 Message digesting and comparison 784 The message M shall be digested with the selected message- digest 785 algorithm to give an octet string MD', the comparative message 786 digest. The verification process shall succeed if the comparative 787 message digest MD' is the same as the message digest MD, and the 788 verification process shall fail otherwise. 790 11. Object identifiers 792 This document defines five object identifiers: pkcs-1, rsaEncryption, 793 md2WithRSAEncryption, md4WithRSAEncryption, and md5WithRSAEncryption. 795 The object identifier pkcs-1 identifies this document. 797 pkcs-1 OBJECT IDENTIFIER ::= 799 { iso(1) member-body(2) US(840) rsadsi(113549) 800 pkcs(1) 1 } 802 The object identifier rsaEncryption identifies RSA public and private 803 keys as defined in Section 7 and the RSA encryption and decryption 804 processes defined in Sections 8 and 9. 806 RFC nnn PKCS #1: RSA Encryption November 1993 808 rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1 } 810 The rsaEncryption object identifier is intended to be used in the 811 algorithm field of a value of type AlgorithmIdentifier. The 812 parameters field of that type, which has the algorithm-specific 813 syntax ANY DEFINED BY algorithm, would have ASN.1 type NULL for this 814 algorithm. 816 The object identifiers md2WithRSAEncryption, md4WithRSAEncryption, 817 md5WithRSAEncryption, identify, respectively, the "MD2 with RSA," 818 "MD4 with RSA," and "MD5 with RSA" signature and verification 819 processes defined in Section 10. 821 md2WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 2 } 822 md4WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 3 } 823 md5WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 4 } 825 These object identifiers are intended to be used in the algorithm 826 field of a value of type AlgorithmIdentifier. The parameters field of 827 that type, which has the algorithm- specific syntax ANY DEFINED BY 828 algorithm, would have ASN.1 type NULL for these algorithms. 830 Note. X.509's object identifier rsa also identifies RSA public keys 831 as defined in Section 7, but does not identify private keys, and 832 identifies different encryption and decryption processes. It is 833 expected that some applications will identify public keys by rsa. 834 Such public keys are compatible with this document; an rsaEncryption 835 process under an rsa public key is the same as the rsaEncryption 836 process under an rsaEncryption public key. 838 Revision history 840 Versions 1.0-1.3 842 Versions 1.0-1.3 were distributed to participants in RSA Data 843 Security, Inc.'s Public-Key Cryptography Standards meetings in 844 February and March 1991. 846 Version 1.4 848 Version 1.4 is part of the June 3, 1991 initial public release of 849 PKCS. Version 1.4 was published as NIST/OSI Implementors' Workshop 850 document SEC-SIG-91-18. 852 Version 1.5 854 RFC nnn PKCS #1: RSA Encryption November 1993 856 Version 1.5 incorporates several editorial changes, including updates 857 to the references and the addition of a revision history. The 858 following substantive changes were made: 860 o Section 10: "MD4 with RSA" signature and 861 verification processes are added. 863 o Section 11: md4WithRSAEncryption object identifier 864 is added. 866 Supersedes June 3, 1991 version, which was also published as NIST/OSI 867 Implementors' Workshop document SEC-SIG-91-18. 869 Copyright 871 Copyright (c) 1991-1993 RSA Laboratories, a division of RSA Data 872 Security, Inc. Any substantial use of the text from this document 873 must acknowledge RSA Data Security, Inc. RSA Data Security, Inc. 874 requests that all material mentioning or referencing this document 875 identify this as "RSA Data Security, Inc. PKCS #1". 877 Author's Address 879 Burt Kaliski 880 RSA Laboratories East 881 20 Crosby Drive 882 Bedford, MA 01730 883 (617) 687-7000 884 burt@rsa.com