idnits 2.17.1 draft-hoffman-pkcs-rsa-encrypt-00.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-19) 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 == The page length should not exceed 58 lines per page, but there was 17 longer pages, the longest (page 2) being 60 lines == 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 213 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.) -- Couldn't find a document date in the document -- date freshness check skipped. -- 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 (~~), 5 warnings (==), 10 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 1 Internet Draft RSA Laboratories 2 Expires 11/5/97 4 PKCS #1: RSA Encryption 5 Version 1.5 7 9 Status of this Memo 11 This document is an Internet-Draft. Internet-Drafts are working 12 documents of the Internet Engineering Task Force (IETF), its areas, 13 and its working groups. Note that other groups may also distribute 14 working documents as Internet-Drafts. 16 Internet-Drafts are draft documents valid for a maximum of six months 17 and may be updated, replaced, or obsoleted by other documents at any 18 time. It is inappropriate to use Internet-Drafts as reference 19 material or to cite them other than as "work in progress." 21 To learn the current status of any Internet-Draft, please check the 22 "1id-abstracts.txt" listing contained in the Internet-Drafts Shadow 23 Directories on ftp.is.co.za (Africa), nic.nordu.net (Europe), 24 munnari.oz.au (Pacific Rim), ds.internic.net (US East Coast), or 25 ftp.isi.edu (US West Coast). 27 This memo provides information for the Internet community. This memo 28 does not specify an Internet standard of any kind. Distribution of 29 this memo is unlimited. 31 Overview 33 This standard describes a method for encrypting data using the RSA 34 public-key cryptosystem. 36 1. Scope 38 This standard describes a method for encrypting data using the RSA 39 public-key cryptosystem. Its intended use is in the construction of 40 digital signatures and digital envelopes, as described in PKCS #7: 42 o For digital signatures, the content to be signed 43 is first reduced to a message digest with a 44 message-digest algorithm (such as MD5), and then 45 an octet string containing the message digest is 46 encrypted with the RSA private key of the signer 47 of the content. The content and the encrypted 49 PKCS #1: RSA Encryption 51 message digest are represented together according 52 to the syntax in PKCS #7 to yield a digital 53 signature. This application is compatible with 54 Privacy-Enhanced Mail (PEM) methods. 56 o For digital envelopes, the content to be enveloped 57 is first encrypted under a content-encryption key 58 with a content-encryption algorithm (such as DES), 59 and then the content-encryption key is encrypted 60 with the RSA public keys of the recipients of the 61 content. The encrypted content and the encrypted 62 content-encryption key are represented together 63 according to the syntax in PKCS #7 to yield a 64 digital envelope. This application is also 65 compatible with PEM methods. 67 The standard also describes a syntax for RSA public keys and private 68 keys. The public-key syntax would be used in certificates; the 69 private-key syntax would be used typically in PKCS #8 private-key 70 information. The public-key syntax is identical to that in both X.509 71 and Privacy-Enhanced Mail. Thus X.509/PEM RSA keys can be used in 72 this standard. 74 The standard also defines three signature algorithms for use in 75 signing X.509/PEM certificates and certificate-revocation lists, PKCS 76 #6 extended certificates, and other objects employing digital 77 signatures such as X.401 message tokens. 79 Details on message-digest and content-encryption algorithms are 80 outside the scope of this standard, as are details on sources of the 81 pseudorandom bits required by certain methods in this standard. 83 2. References 85 FIPS PUB 46-1 National Bureau of Standards. FIPS PUB 46-1: 86 Data Encryption Standard. January 1988. 88 PKCS #6 RSA Laboratories. PKCS #6: Extended-Certificate 89 Syntax Standard. Version 1.5, November 1993. 91 PKCS #7 RSA Laboratories. PKCS #7: Cryptographic Message 92 Syntax Standard. Version 1.5, November 1993. 94 PKCS #8 RSA Laboratories. PKCS #8: Private-Key Information 95 Syntax Standard. Version 1.2, November 1993. 97 RFC 1319 B. Kaliski. RFC 1319: The MD2 Message-Digest 98 Algorithm. April 1992. 100 PKCS #1: RSA Encryption 102 RFC 1320 R. Rivest. RFC 1320: The MD4 Message-Digest 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 151 PKCS #1: RSA Encryption 153 Review, :30-34, April 1990. 155 [Mer90] R.C. Merkle. Note on MD4. Unpublished manuscript, 156 1990. 158 [Mil76] G.L. Miller. Riemann's hypothesis and tests for 159 primality. Journal of Computer and Systems 160 Sciences, 13(3):300-307, 1976. 162 [QC82] J.-J. Quisquater and C. Couvreur. Fast 163 decipherment algorithm for RSA public-key 164 cryptosystem. Electronics Letters, 18(21):905-907, 165 October 1982. 167 [RSA78] R.L. Rivest, A. Shamir, and L. Adleman. A method 168 for obtaining digital signatures and public-key 169 cryptosystems. Communications of the ACM, 170 21(2):120-126, February 1978. 172 3. Definitions 174 For the purposes of this standard, the following definitions apply. 176 AlgorithmIdentifier: A type that identifies an algorithm (by object 177 identifier) and associated parameters. This type is defined in X.509. 179 ASN.1: Abstract Syntax Notation One, as defined in X.208. 181 BER: Basic Encoding Rules, as defined in X.209. 183 DES: Data Encryption Standard, as defined in FIPS PUB 46-1. 185 MD2: RSA Data Security, Inc.'s MD2 message-digest algorithm, as 186 defined in RFC 1319. 188 MD4: RSA Data Security, Inc.'s MD4 message-digest algorithm, as 189 defined in RFC 1320. 191 MD5: RSA Data Security, Inc.'s MD5 message-digest algorithm, as 192 defined in RFC 1321. 194 modulus: Integer constructed as the product of two primes. 196 PEM: Internet Privacy-Enhanced Mail, as defined in RFC 1423 and 197 related documents. 199 RSA: The RSA public-key cryptosystem, as defined in [RSA78]. 201 PKCS #1: RSA Encryption 203 private key: Modulus and private exponent. 205 public key: Modulus and public exponent. 207 4. Symbols and abbreviations 209 Upper-case italic symbols (e.g., BT) denote octet strings and bit 210 strings (in the case of the signature S); lower-case italic symbols 211 (e.g., c) denote integers. 213 ab hexadecimal octet value c exponent 214 BT block type d private exponent 215 D data e public exponent 216 EB encryption block k length of modulus in 217 octets 218 ED encrypted data n modulus 219 M message p, q prime factors of modulus 220 MD message digest x integer encryption block 221 MD' comparative message y integer encrypted data 222 digest 223 PS padding string mod n modulo n 224 S signature X || Y concatenation of X, Y 225 ||X|| length in octets of X 227 5. General overview 229 The next six sections specify key generation, key syntax, the 230 encryption process, the decryption process, signature algorithms, and 231 object identifiers. 233 Each entity shall generate a pair of keys: a public key and a private 234 key. The encryption process shall be performed with one of the keys 235 and the decryption process shall be performed with the other key. 236 Thus the encryption process can be either a public-key operation or a 237 private-key operation, and so can the decryption process. Both 238 processes transform an octet string to another octet string. The 239 processes are inverses of each other if one process uses an entity's 240 public key and the other process uses the same entity's private key. 242 The encryption and decryption processes can implement either the 243 classic RSA transformations, or variations with padding. 245 6. Key generation 247 This section describes RSA key generation. 249 Each entity shall select a positive integer e as its public exponent. 251 PKCS #1: RSA Encryption 253 Each entity shall privately and randomly select two distinct odd 254 primes p and q such that (p-1) and e have no common divisors, and 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 standard (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 standard. 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 PKCS #1: RSA Encryption 303 The fields of type RSAPublicKey have the following meanings: 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 standard. It shall 330 be 0 for this version of the standard. 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 PKCS #1: RSA Encryption 353 1. An RSA private key logically consists of only the 354 modulus n and the private exponent d. The presence 355 of the values p, q, d mod (p-1), d mod (p-1), and 356 q-1 mod p is intended for efficiency, as 357 Quisquater and Couvreur have shown [QC82]. A 358 private-key syntax that does not include all the 359 extra values can be converted readily to the 360 syntax defined here, provided the public key is 361 known, according to a result by Miller [Mil76]. 363 2. The presence of the public exponent e is intended 364 to make it straightforward to derive a public key 365 from the private key. 367 8. Encryption process 369 This section describes the RSA encryption process. 371 The encryption process consists of four steps: encryption- block 372 formatting, octet-string-to-integer conversion, RSA computation, and 373 integer-to-octet-string conversion. The input to the encryption 374 process shall be an octet string D, the data; an integer n, the 375 modulus; and an integer c, the exponent. For a public-key operation, 376 the integer c shall be an entity's public exponent e; for a private- 377 key operation, it shall be an entity's private exponent d. The output 378 from the encryption process shall be an octet string ED, the 379 encrypted data. 381 The length of the data D shall not be more than k-11 octets, which is 382 positive since the length k of the modulus is at least 12 octets. 383 This limitation guarantees that the length of the padding string PS 384 is at least eight octets, which is a security condition. 386 Notes. 388 1. In typical applications of this standard to 389 encrypt content-encryption keys and message 390 digests, one would have ||D|| <= 30. Thus the 391 length of the RSA modulus will need to be at least 392 328 bits (41 octets), which is reasonable and 393 consistent with security recommendations. 395 2. The encryption process does not provide an 396 explicit integrity check to facilitate error 397 detection should the encrypted data be corrupted 398 in transmission. However, the structure of the 399 encryption block guarantees that the probability 401 PKCS #1: RSA Encryption 403 that corruption is undetected is less than 2-16, 404 which is an upper bound on the probability that a 405 random encryption block looks like block type 02. 407 3. Application of private-key operations as defined 408 here to data other than an octet string containing 409 a message digest is not recommended and is subject 410 to further study. 412 4. This standard may be extended to handle data of 413 length more than k-11 octets. 415 8.1 Encryption-block formatting 417 A block type BT, a padding string PS, and the data D shall be 418 formatted into an octet string EB, the encryption block. 420 EB = 00 || BT || PS || 00 || D . (1) 422 The block type BT shall be a single octet indicating the structure of 423 the encryption block. For this version of the standard it shall have 424 value 00, 01, or 02. For a private- key operation, the block type 425 shall be 00 or 01. For a public-key operation, it shall be 02. 427 The padding string PS shall consist of k-3-||D|| octets. For block 428 type 00, the octets shall have value 00; for block type 01, they 429 shall have value FF; and for block type 02, they shall be 430 pseudorandomly generated and nonzero. This makes the length of the 431 encryption block EB equal to k. 433 Notes. 435 1. The leading 00 octet ensures that the encryption 436 block, converted to an integer, is less than the 437 modulus. 439 2. For block type 00, the data D must begin with a 440 nonzero octet or have known length so that the 441 encryption block can be parsed unambiguously. For 442 block types 01 and 02, the encryption block can be 443 parsed unambiguously since the padding string PS 444 contains no octets with value 00 and the padding 445 string is separated from the data D by an octet 446 with value 00. 448 3. Block type 01 is recommended for private-key 449 operations. Block type 01 has the property that 451 PKCS #1: RSA Encryption 453 the encryption block, converted to an integer, is 454 guaranteed to be large, which prevents certain 455 attacks of the kind proposed by Desmedt and 456 Odlyzko [DO86]. 458 4. Block types 01 and 02 are compatible with PEM RSA 459 encryption of content-encryption keys and message 460 digests as described in RFC 1423. 462 5. For block type 02, it is recommended that the 463 pseudorandom octets be generated independently for 464 each encryption process, especially if the same 465 data is input to more than one encryption process. 466 Hastad's results [Has88] motivate this 467 recommendation. 469 6. For block type 02, the padding string is at least 470 eight octets long, which is a security condition 471 for public-key operations that prevents an 472 attacker from recoving data by trying all possible 473 encryption blocks. For simplicity, the minimum 474 length is the same for block type 01. 476 7. This standard may be extended in the future to 477 include other block types. 479 8.2 Octet-string-to-integer conversion 481 The encryption block EB shall be converted to an integer x, the 482 integer encryption block. Let EB1, ..., EBk be the octets of EB from 483 first to last. Then the integer x shall satisfy 485 k 486 x = SUM 2^(8(k-i)) EBi . (2) 487 i = 1 489 In other words, the first octet of EB has the most significance in 490 the integer and the last octet of EB has the least significance. 492 Note. The integer encryption block x satisfies 0 <= x < n since EB1 493 = 00 and 2^(8(k-1)) <= n. 495 8.3 RSA computation 497 The integer encryption block x shall be raised to the power c modulo 498 n to give an integer y, the integer encrypted data. 500 y = x^c mod n, 0 <= y < n . 502 PKCS #1: RSA Encryption 504 This is the classic RSA computation. 506 8.4 Integer-to-octet-string conversion 508 The integer encrypted data y shall be converted to an octet string ED 509 of length k, the encrypted data. The encrypted data ED shall satisfy 511 k 512 y = SUM 2^(8(k-i)) EDi . (3) 513 i = 1 515 where ED1, ..., EDk are the octets of ED from first to last. 517 In other words, the first octet of ED has the most significance in 518 the integer and the last octet of ED has the least significance. 520 9. Decryption process 522 This section describes the RSA decryption process. 524 The decryption process consists of four steps: octet-string- to- 525 integer conversion, RSA computation, integer-to-octet- string 526 conversion, and encryption-block parsing. The input to the decryption 527 process shall be an octet string ED, the encrypted data; an integer 528 n, the modulus; and an integer c, the exponent. For a public-key 529 operation, the integer c shall be an entity's public exponent e; for 530 a private-key operation, it shall be an entity's private exponent d. 531 The output from the decryption process shall be an octet string D, 532 the data. 534 It is an error if the length of the encrypted data ED is not k. 536 For brevity, the decryption process is described in terms of the 537 encryption process. 539 9.1 Octet-string-to-integer conversion 541 The encrypted data ED shall be converted to an integer y, the integer 542 encrypted data, according to Equation (3). 544 It is an error if the integer encrypted data y does not satisfy 0 <= 545 y < n. 547 9.2 RSA computation 549 The integer encrypted data y shall be raised to the power c modulo n 550 to give an integer x, the integer encryption block. 552 PKCS #1: RSA Encryption 554 x = y^c mod n, 0 <= x < n . 556 This is the classic RSA computation. 558 9.3 Integer-to-octet-string conversion 560 The integer encryption block x shall be converted to an octet string 561 EB of length k, the encryption block, according to Equation (2). 563 9.4 Encryption-block parsing 565 The encryption block EB shall be parsed into a block type BT, a 566 padding string PS, and the data D according to Equation (1). 568 It is an error if any of the following conditions occurs: 570 o The encryption block EB cannot be parsed 571 unambiguously (see notes to Section 8.1). 573 o The padding string PS consists of fewer than eight 574 octets, or is inconsistent with the block type BT. 576 o The decryption process is a public-key operation 577 and the block type BT is not 00 or 01, or the 578 decryption process is a private-key operation and 579 the block type is not 02. 581 10. Signature algorithms 583 This section defines three signature algorithms based on the RSA 584 encryption process described in Sections 8 and 9. The intended use of 585 the signature algorithms is in signing X.509/PEM certificates and 586 certificate-revocation lists, PKCS #6 extended certificates, and 587 other objects employing digital signatures such as X.401 message 588 tokens. The algorithms are not intended for use in constructing 589 digital signatures in PKCS #7. The first signature algorithm 590 (informally, "MD2 with RSA") combines the MD2 message-digest 591 algorithm with RSA, the second (informally, "MD4 with RSA") combines 592 the MD4 message-digest algorithm with RSA, and the third (informally, 593 "MD5 with RSA") combines the MD5 message- digest algorithm with RSA. 595 This section describes the signature process and the verification 596 process for the two algorithms. The "selected" message-digest 597 algorithm shall be either MD2 or MD5, depending on the signature 598 algorithm. The signature process shall be performed with an entity's 599 private key and the verification process shall be performed with an 600 entity's public key. The signature process transforms an octet string 601 (the message) to a bit string (the signature); the verification 603 PKCS #1: RSA Encryption 605 process determines whether a bit string (the signature) is the 606 signature of an octet string (the message). 608 Note. The only difference between the signature algorithms defined 609 here and one of the the methods by which signatures (encrypted 610 message digests) are constructed in PKCS #7 is that signatures here 611 are represented here as bit strings, for consistency with the X.509 612 SIGNED macro. In PKCS #7 encrypted message digests are octet strings. 614 10.1 Signature process 616 The signature process consists of four steps: message digesting, data 617 encoding, RSA encryption, and octet-string- to-bit-string conversion. 618 The input to the signature process shall be an octet string M, the 619 message; and a signer's private key. The output from the signature 620 process shall be a bit string S, the signature. 622 10.1.1 Message digesting 624 The message M shall be digested with the selected message- digest 625 algorithm to give an octet string MD, the message digest. 627 10.1.2 Data encoding 629 The message digest MD and a message-digest algorithm identifier shall 630 be combined into an ASN.1 value of type DigestInfo, described below, 631 which shall be BER-encoded to give an octet string D, the data. 633 DigestInfo ::= SEQUENCE { 634 digestAlgorithm DigestAlgorithmIdentifier, 635 digest Digest } 637 DigestAlgorithmIdentifier ::= AlgorithmIdentifier 639 Digest ::= OCTET STRING 641 The fields of type DigestInfo have the following meanings: 643 o digestAlgorithm identifies the message-digest 644 algorithm (and any associated parameters). For 645 this application, it should identify the selected 646 message-digest algorithm, MD2, MD4 or MD5. For 647 reference, the relevant object identifiers are the 648 following: 650 md2 OBJECT IDENTIFIER ::= 651 { iso(1) member-body(2) US(840) rsadsi(113549) 652 digestAlgorithm(2) 2 } md4 OBJECT IDENTIFIER ::= 654 PKCS #1: RSA Encryption 656 { iso(1) member-body(2) US(840) rsadsi(113549) 657 digestAlgorithm(2) 4 } md5 OBJECT IDENTIFIER ::= 658 { iso(1) member-body(2) US(840) rsadsi(113549) 659 digestAlgorithm(2) 5 } 661 For these object identifiers, the parameters field 662 of the digestAlgorithm value should be NULL. 664 o digest is the result of the message-digesting 665 process, i.e., the message digest MD. 667 Notes. 669 1. A message-digest algorithm identifier is included 670 in the DigestInfo value to limit the damage 671 resulting from the compromise of one message- 672 digest algorithm. For instance, suppose an 673 adversary were able to find messages with a given 674 MD2 message digest. That adversary might try to 675 forge a signature on a message by finding an 676 innocuous-looking message with the same MD2 677 message digest, and coercing a signer to sign the 678 innocuous-looking message. This attack would 679 succeed only if the signer used MD2. If the 680 DigestInfo value contained only the message 681 digest, however, an adversary could attack signers 682 that use any message digest. 684 2. Although it may be claimed that the use of a 685 SEQUENCE type violates the literal statement in 686 the X.509 SIGNED and SIGNATURE macros that a 687 signature is an ENCRYPTED OCTET STRING (as opposed 688 to ENCRYPTED SEQUENCE), such a literal 689 interpretation need not be required, as I'Anson 690 and Mitchell point out [IM90]. 692 3. No reason is known that MD4 would not be 693 sufficient for very high security digital 694 signature schemes, but because MD4 was designed to 695 be exceptionally fast, it is "at the edge" in 696 terms of risking successful cryptanalytic attack. 697 A message-digest algorithm can be considered 698 "broken" if someone can find a collision: two 699 messages with the same digest. While collisions 700 have been found in variants of MD4 with only two 701 digesting "rounds" [Mer90][dBB92], none have been 702 found in MD4 itself, which has three rounds. After 704 PKCS #1: RSA Encryption 706 further critical review, it may be appropriate to 707 consider MD4 for very high security applications. 709 MD5, which has four rounds and is proportionally 710 slower than MD4, is recommended until the 711 completion of MD4's review. The reported 712 "pseudocollisions" in MD5's internal compression 713 function [dBB93] do not appear to have any 714 practical impact on MD5's security. 716 MD2, the slowest of the three, has the most 717 conservative design. No attacks on MD2 have been 718 published. 720 10.1.3 RSA encryption 722 The data D shall be encrypted with the signer's RSA private key as 723 described in Section 7 to give an octet string ED, the encrypted 724 data. The block type shall be 01. (See Section 8.1.) 726 10.1.4 Octet-string-to-bit-string conversion 728 The encrypted data ED shall be converted into a bit string S, the 729 signature. Specifically, the most significant bit of the first octet 730 of the encrypted data shall become the first bit of the signature, 731 and so on through the least significant bit of the last octet of the 732 encrypted data, which shall become the last bit of the signature. 734 Note. The length in bits of the signature S is a multiple of eight. 736 10.2 Verification process 738 The verification process for both signature algorithms consists of 739 four steps: bit-string-to-octet-string conversion, RSA decryption, 740 data decoding, and message digesting and comparison. The input to the 741 verification process shall be an octet string M, the message; a 742 signer's public key; and a bit string S, the signature. The output 743 from the verification process shall be an indication of success or 744 failure. 746 10.2.1 Bit-string-to-octet-string conversion 748 The signature S shall be converted into an octet string ED, the 749 encrypted data. Specifically, assuming that the length in bits of the 750 signature S is a multiple of eight, the first bit of the signature 751 shall become the most significant bit of the first octet of the 752 encrypted data, and so on through the last bit of the signature, 753 which shall become the least significant bit of the last octet of the 755 PKCS #1: RSA Encryption 757 encrypted data. 759 It is an error if the length in bits of the signature S is not a 760 multiple of eight. 762 10.2.2 RSA decryption 764 The encrypted data ED shall be decrypted with the signer's RSA public 765 key as described in Section 8 to give an octet string D, the data. 767 It is an error if the block type recovered in the decryption process 768 is not 01. (See Section 9.4.) 770 10.2.3 Data decoding 772 The data D shall be BER-decoded to give an ASN.1 value of type 773 DigestInfo, which shall be separated into a message digest MD and a 774 message-digest algorithm identifier. The message-digest algorithm 775 identifier shall determine the "selected" message-digest algorithm 776 for the next step. 778 It is an error if the message-digest algorithm identifier does not 779 identify the MD2, MD4 or MD5 message-digest algorithm. 781 10.2.4 Message digesting and comparison 783 The message M shall be digested with the selected message- digest 784 algorithm to give an octet string MD', the comparative message 785 digest. The verification process shall succeed if the comparative 786 message digest MD' is the same as the message digest MD, and the 787 verification process shall fail otherwise. 789 11. Object identifiers 791 This standard defines five object identifiers: pkcs-1, rsaEncryption, 792 md2WithRSAEncryption, md4WithRSAEncryption, and md5WithRSAEncryption. 794 The object identifier pkcs-1 identifies this standard. 796 pkcs-1 OBJECT IDENTIFIER ::= 798 { iso(1) member-body(2) US(840) rsadsi(113549) 799 pkcs(1) 1 } 801 The object identifier rsaEncryption identifies RSA public and private 802 keys as defined in Section 7 and the RSA encryption and decryption 803 processes defined in Sections 8 and 9. 805 PKCS #1: RSA Encryption 807 rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1 } 809 The rsaEncryption object identifier is intended to be used in the 810 algorithm field of a value of type AlgorithmIdentifier. The 811 parameters field of that type, which has the algorithm-specific 812 syntax ANY DEFINED BY algorithm, would have ASN.1 type NULL for this 813 algorithm. 815 The object identifiers md2WithRSAEncryption, md4WithRSAEncryption, 816 md5WithRSAEncryption, identify, respectively, the "MD2 with RSA," 817 "MD4 with RSA," and "MD5 with RSA" signature and verification 818 processes defined in Section 10. 820 md2WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 2 } 821 md4WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 3 } 822 md5WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 4 } 824 These object identifiers are intended to be used in the algorithm 825 field of a value of type AlgorithmIdentifier. The parameters field of 826 that type, which has the algorithm- specific syntax ANY DEFINED BY 827 algorithm, would have ASN.1 type NULL for these algorithms. 829 Note. X.509's object identifier rsa also identifies RSA public keys 830 as defined in Section 7, but does not identify private keys, and 831 identifies different encryption and decryption processes. It is 832 expected that some applications will identify public keys by rsa. 833 Such public keys are compatible with this standard; an rsaEncryption 834 process under an rsa public key is the same as the rsaEncryption 835 process under an rsaEncryption public key. 837 Revision history 839 Versions 1.0-1.3 841 Versions 1.0-1.3 were distributed to participants in RSA Data 842 Security, Inc.'s Public-Key Cryptography Standards meetings in 843 February and March 1991. 845 Version 1.4 847 Version 1.4 is part of the June 3, 1991 initial public release of 848 PKCS. Version 1.4 was published as NIST/OSI Implementors' Workshop 849 document SEC-SIG-91-18. 851 Version 1.5 853 PKCS #1: RSA Encryption 855 Version 1.5 incorporates several editorial changes, including updates 856 to the references and the addition of a revision history. The 857 following substantive changes were made: 859 o Section 10: "MD4 with RSA" signature and 860 verification processes are added. 862 o Section 11: md4WithRSAEncryption object identifier 863 is added. 865 Supersedes June 3, 1991 version, which was also published as NIST/OSI 866 Implementors' Workshop document SEC-SIG-91-18. 868 Copyright 870 Copyright (C) 1991-1993 RSA Laboratories, a division of RSA Data 871 Security, Inc. License to copy this document is granted provided that 872 it is identified as "RSA Data Security, Inc. Public-Key Cryptography 873 Standards (PKCS)" in all material mentioning or referencing this 874 document. 876 Author's Address 878 RSA Laboratories 879 100 Marine Parkway 880 Redwood City, CA 94065 USA 881 Tel: (415) 595-7703 882 Fax: (415) 595-4126 883 pkcs-editor@rsa.com