Fact-checked by Grok 2 weeks ago

PKCS 1

PKCS #1, formally known as Standards #1, is a cryptographic standard that provides specifications for implementing based on the algorithm, including for encryption and signatures, specific encryption and signature schemes with padding, and syntax for keys and related structures. Originally developed by Laboratories as part of their Standards () series, PKCS #1 was first released in version 1.0 in 1991 to promote in -based systems, such as signatures and data encryption. Subsequent revisions addressed security improvements and compatibility; version 1.5 was published as 2313 in 1998, version 2.0 as 2437 later that year introducing (), version 2.1 as 3447 in 2003 adding probabilistic signature scheme (PSS), and the current version 2.2 republished by the IETF as 8017 in 2016 to transfer maintenance while supporting updated hash functions like SHA-224 and SHA-512 variants per FIPS 180-4. The standard defines essential components such as public keys (consisting of n and exponent e) and keys (including the exponent d and optional prime factors), along with raw primitives like primitive (RSAEP) and primitive (RSASP1). For , it mandates RSAES-OAEP for new implementations due to its provable against chosen-ciphertext attacks, while retaining the legacy RSAES-PKCS1-v1_5 for ; similarly, RSASSA-PSS is recommended for with its reduction to the model, alongside RSASSA-PKCS1-v1_5. Widely used in protocols like certificates, , and secure communications, PKCS #1 ensures robust deployments but notes that older schemes like PKCS1-v1_5 may be vulnerable to padding oracle attacks if not implemented carefully.

Overview

Purpose and Development

PKCS#1, also known as Public-Key Cryptography Standard #1, is a specification developed to define formats for RSA public and private keys, along with cryptographic primitives for encryption and digital signatures based on the RSA algorithm. It forms part of the broader PKCS series aimed at promoting consistent implementations of public-key cryptography. The standard originated from efforts by RSA Laboratories, which initiated the PKCS series in 1991 through meetings with early adopters of public-key technology. Initial internal versions (1.0 through 1.3) were distributed to participants in these meetings between 1991 and 1993, while the first public release, version 1.4, occurred on June 3, 1991, as part of preliminary materials for a workshop. Version 1.5 followed in November 1993 and was formalized as RFC 2313 by the IETF in March 1998. Subsequent versions addressed evolving needs: version 2.0 in October 1998 (RFC 2437) introduced optimal asymmetric encryption padding (OAEP), version 2.1 in February 2003 (RFC 3447) added probabilistic signature schemes (PSS) and multi-prime RSA support, and version 2.2 in November 2016 (RFC 8017) incorporated additional hash functions while transferring change control to the IETF, obsoleting prior RFCs. The core objectives of PKCS#1 center on standardizing usage to facilitate across diverse systems and vendors, while bolstering against known weaknesses in unpadded or "textbook" , such as vulnerability to chosen-ciphertext attacks. By mandating schemes and encoding rules, the standard mitigates risks like deterministic encryption flaws and ensures resistance to common cryptanalytic threats, evolving over versions to incorporate proven secure primitives as cryptographic research advanced. This focus has made PKCS#1 a foundational reference for implementations in protocols like TLS and secure messaging systems.

Scope and Relation to RSA

PKCS#1 specifies standardized formats, primitives, and schemes for implementing exclusively using the algorithm. It defines Abstract Syntax Notation One () structures in Distinguished Encoding Rules (DER) for RSA public and private keys, including the representation of key components such as the and exponents. Additionally, it outlines basic for RSA encryption and decryption operations, as well as for signing and verification processes, and provides specific and schemes that incorporate these primitives. However, PKCS#1 excludes procedures for RSA , which are addressed in the more general private-key information syntax defined in PKCS#8. PKCS#1 extends the foundational algorithm by standardizing secure constructions that mitigate vulnerabilities inherent in direct application of RSA's core operation— for public-key encryption and decryption. While RSA relies on the computational difficulty of to ensure security, PKCS#1 mandates the use of probabilistic mechanisms in its schemes to prevent deterministic attacks, such as chosen-ciphertext attacks that could otherwise compromise or . This relation positions PKCS#1 as a practical for deploying RSA in real-world systems, transforming the theoretical algorithm into robust, implementation-ready protocols without altering its underlying mathematical basis. Beyond its RSA-centric focus, PKCS#1 deliberately limits its scope to avoid overlap with other aspects of public-key infrastructure. It does not address protocols, which are covered in PKCS#3 for Diffie-Hellman-based agreements, nor does it include mechanisms for certificate requests or certification processes, as specified in PKCS#10. Furthermore, PKCS#1 applies solely to and excludes support for alternative public-key algorithms, such as (ECC), ensuring specialized but non-generalized guidance for RSA deployments.

Key Formats

Public Key Encoding

In PKCS#1, the RSA public key is encoded using Abstract Syntax Notation One (ASN.1) to ensure a standardized, interoperable representation suitable for cryptographic operations such as and . The structure is defined as a containing two components: the n and the public exponent e. This , known as RSAPublicKey, employs the Distinguished Encoding Rules (DER) for , which produces a deterministic output from the ASN.1 description. The modulus n is the product of at least two distinct primes, forming a positive that serves as the basis for the domain, with typical lengths ranging from 2048 to 4096 bits to provide adequate against attacks. The public exponent e is an satisfying $3 \leq e < n and coprime to \lambda(n), where \lambda(n) is the Carmichael function of n; the value 65537 ($2^{16} + 1) is commonly used due to its efficiency in modular exponentiation and resistance to certain attacks. Integers are represented in big-endian byte order, with the most significant byte first, and no additional padding is applied within the key encoding itself to maintain compactness. This encoding facilitates the export of public keys for integration into X.509 certificates or direct use in cryptographic primitives defined elsewhere in PKCS#1. For instance, a 512-bit RSAPublicKey with modulus n = 0x0A66791DC6988168DE7AB77419BB7FB0C001C62710270075142942E19A8D8C51D053B3E3782A1DE5DC5AF4EBE99468170114A1DFE67CDC9A9AF55D655620BBAB and exponent e = 65537 yields the following DER-encoded byte sequence (in hexadecimal):
30 47 02 40 0A 66 79 1D C6 98 81 68 DE 7A B7 74 19 BB 7F B0
C0 01 C6 27 10 27 00 75 14 29 42 E1 9A 8D 8C 51 D0 53 B3 E3
78 2A 1D E5 DC 5A F4 EB E9 94 68 17 01 14 A1 DF E6 7C DC 9A
9A F5 5D 65 56 20 BB AB 02 03 01 00 01
This 73-byte structure begins with the SEQUENCE tag (0x30), followed by the length, then the modulus (tagged 0x02, 64 bytes), and the exponent (tagged 0x02, 3 bytes).

Private Key Encoding

The private key encoding in PKCS#1 specifies an ASN.1 structure for representing , enabling secure storage and transmission while supporting efficient cryptographic operations. This format encapsulates both the essential secret components required for and optional auxiliary parameters that optimize performance without compromising security. The ASN.1 type for an RSA private key is defined as:
RSAPrivateKey ::= SEQUENCE {
  version           Version,
  modulus           INTEGER,  -- n
  publicExponent    INTEGER,  -- e
  privateExponent   INTEGER,  -- d
  prime1            INTEGER,  -- p
  prime2            INTEGER,  -- q
  exponent1         INTEGER,  -- d mod (p-1)
  exponent2         INTEGER,  -- d mod (q-1)
  coefficient       INTEGER,  -- q^{-1} mod p
  otherPrimeInfos   OtherPrimeInfos OPTIONAL
}
Here, Version ::= INTEGER { two-prime(0), multi(1) }, where version 0 indicates a two-prime RSA key (the default case) and omits otherPrimeInfos, while version 1 supports multi-prime RSA with additional prime factors specified in the optional field. The core components include the modulus n, which is the product of two distinct primes p (prime1) and q (prime2) such that n = p \cdot q; the public exponent e; and the private exponent d, a positive integer less than n satisfying e \cdot d \equiv 1 \pmod{\lambda(n)}, where \lambda(n) is the of n. These elements form the foundational secret material for RSA decryption and signing operations. To enhance computational efficiency, particularly for decryption, the structure incorporates Chinese Remainder Theorem (CRT) parameters: exponent1 as d \mod (p-1), exponent2 as d \mod (q-1), and coefficient as the modular inverse q^{-1} \mod p, allowing faster reduction modulo n by operating separately modulo p and q. For multi-prime cases (version 1), otherPrimeInfos extends this with sequences of additional primes r_i, their corresponding exponents d_i, and coefficients t_i, maintaining compatibility with two-prime optimizations. Private keys in this encoding must be rigorously protected against unauthorized disclosure or modification, as exposure of components like d, p, or q could enable factorization of n or direct computation of plaintexts and signatures; the standardized format facilitates secure handling in protocols like for key wrapping and for storage.

Cryptographic Primitives

Basic RSA Functions

PKCS#1 defines the foundational RSA primitives as low-level building blocks for secure cryptographic schemes, consisting of basic encryption and signature operations performed modulo the RSA modulus. These primitives operate on integer representatives and rely on the RSA trapdoor one-way function, where the public key is the pair (n, e) and the private key includes the exponent d. Here, n is the , the product of two distinct odd primes p and q (with n at least 1024 bits long as specified in the standard, though at least 2048 bits is recommended for adequate security as of 2025); e is the public exponent, an integer satisfying 2 < e < n and gcd(e, λ(n)) = 1, where λ(n) is the λ(n) = lcm(p-1, q-1); and d is the private exponent, a positive integer less than n such that e · d ≡ 1 (mod λ(n)). The encryption primitive, known as RSA Encryption Primitive (RSAEP), computes the ciphertext from a message representative. Specifically, given the public key (n, e) and an integer message representative m where 0 ≤ m < n, the ciphertext c is calculated as: c = m^e \mod n The output c satisfies 0 ≤ c < n. The corresponding decryption primitive, RSA Decryption Primitive (RSADP), recovers the message using the private key. Given the private key (which includes n and d) and ciphertext c where 0 ≤ c < n, the message m is: m = c^d \mod n with 0 ≤ m < n, assuming correct key usage and no errors in computation. These operations form the core of RSA-based encryption but are deterministic and vulnerable to attacks if used without additional encoding. For digital signatures, PKCS#1 specifies primitives that operate on a message representative m, typically derived from hashing the original message to ensure fixed length and security properties. The signature primitive, RSA Signature Primitive (RSASP1), generates the signature using the private key: given (n, d) and m where 0 ≤ m < n, the signature s is: s = m^d \mod n with 0 ≤ s < n. Verification uses the RSA Verification Primitive (RSAVP1): given the public key (n, e) and s where 0 ≤ s < n, compute: m' = s^e \mod n then check if m' equals the expected message representative m (e.g., the hash of the signed data). If they match, the signature is valid. Like the encryption primitives, raw RSA signatures are insecure without proper encoding to prevent malleability and other attacks, as detailed in subsequent sections on encoding mechanisms.

Encoding and Padding Mechanisms

In PKCS#1, encoding mechanisms convert messages or hashes represented as octet strings into integer values suitable for RSA operations. The Octet-String-to-Integer Primitive (OS2IP) performs this conversion by interpreting the input as a big-endian octet string, where the integer x is computed as x = \sum_{i=0}^{xLen-1} x_i \cdot 256^{xLen-1-i}, with x_i denoting the i-th octet from the left. This ensures that byte sequences are mapped uniquely to nonnegative integers within the RSA modulus range, facilitating the application of RSA primitives like exponentiation. Padding is essential in PKCS#1 because raw RSA encryption and signature operations are inherently deterministic and malleable, allowing an adversary to modify ciphertexts or signatures without detection and predict outputs from known inputs. Without padding, these vulnerabilities enable attacks such as chosen-ciphertext manipulations, as the lack of randomness and structure in plaintext-to-ciphertext mapping exposes the scheme to forgery or decryption oracle exploitation. Padding schemes address this by incorporating redundancy, randomness, and formatting to achieve semantic security and verifiability. PKCS#1 defines two primary padding categories: deterministic schemes like PKCS#1 v1.5, which append a fixed structure with redundancy (e.g., a padding string of nonzero octets followed by a delimiter), and probabilistic schemes like OAEP, which employ a mask generation function (MGF) to introduce randomness and obscure the message boundary. The v1.5 padding ensures a specific octet sequence (e.g., 0x00 || 0x02 || PS || 0x00 || M) for both encryption and signatures, providing basic redundancy without variability. In contrast, OAEP uses iterative masking to expand and randomize the encoded message, enhancing resistance to cryptanalytic attacks through provable security under the random oracle model. For decryption, redundancy checks in padding schemes verify the integrity of recovered messages; for instance, in v1.5 encryption, the presence of the leading 0x00 octet and padding delimiter confirms correct unpadding, rejecting malformed outputs to prevent partial decryptions. In signature schemes, Encoding Method for Signature Append (EMSA) integrates hash functions to process messages into padded octet strings, such as EMSA-PKCS1-v1.5, which prefixes a DigestInfo structure (containing the hash) with a deterministic padding string (00 || 01 || PS || 00), enabling verification against the signer's public key. These EMSA methods ensure that signatures bind the hash of the message via redundancy, thwarting existential forgery by requiring exact matches during recovery.

Encryption Schemes

RSAES-PKCS1-v1_5

RSAES-PKCS1-v1_5 is a legacy RSA encryption scheme defined in PKCS#1 version 1.5, which combines the RSA encryption primitive (RSAEP) with the EME-PKCS1-v1_5 encoding method to provide a basic mechanism for encrypting messages using a public key. This scheme supports messages of up to k - 11 octets in length, where k is the length of the RSA modulus n in octets, and it is included in later versions of the standard primarily for backward compatibility rather than for new implementations. The encoding ensures that the padded message fits exactly into k octets before applying the RSA exponentiation. The encryption process begins with inputs consisting of an RSA public key (n, e) and a M represented as an octet string of length mLen, where $0 < mLen \leq k - 11. If mLen > k - 11, the process outputs an error indicating the message is too long. Otherwise, a string PS of length k - mLen - 3 octets is generated, consisting of pseudo-random bytes each in the range 1 to 255 (non-zero). The encoded EM is then formed as the concatenation EM = 00 \parallel 02 \parallel PS \parallel 00 \parallel M, where $00 and $02 are single-octet values in notation, PS provides probabilistic padding, and the trailing $00 serves as a before the M. To complete encryption, convert EM to an m using the octet string to integer primitive (OS2IP), compute the ciphertext integer c = m^e \mod n via RSAEP, and output the C as the k-octet string from integer to octet string primitive (I2OSP) applied to c. The full padding structure follows the format: EM = 00 \parallel \text{BT} \parallel PS \parallel 00 \parallel M where BT is the block type octet equal to 02 for encryption, and |PS| \geq 8 to ensure sufficient randomness against certain attacks. Decryption takes as input an RSA private key K (which includes n and the decryption exponent d, or equivalent via Chinese Remainder Theorem components) and a ciphertext C of exactly k octets, with k \geq 11. If the length conditions are not met, it outputs a decryption error. Convert C to integer c via OS2IP, compute the integer m = c^d \mod n (or equivalent) via the RSA decryption primitive (RSADP), and recover EM as the k-octet I2OSP of m. Parse EM: it must begin with the octet 00 followed by BT = 02, then non-zero octets in PS of at least 8 octets, followed by the octet 00; if any check fails (e.g., no valid separator or insufficient padding), output a decryption error. Otherwise, extract M as the remaining octets after the separator. In this , the type BT distinguishes the encoding purpose: the leading 00 acts as a (effectively BT = 00 in some contexts), while BT = 02 specifically indicates with data , and the minimum |PS| \geq 8 enforces a property by randomizing at least 8 bytes. For , the probabilistic choice of non-zero bytes in PS aims to prevent deterministic attacks, though the scheme's overall structure has known limitations compared to more modern alternatives.

RSAES-OAEP

RSAES-OAEP is an RSA encryption scheme introduced in PKCS#1 that combines the encryption primitive (RSAEP) with the (OAEP) encoding method, known as EME-OAEP, to achieve against adaptive chosen-ciphertext attacks (IND-CCA2). This scheme supports messages of length up to k - 2hLen - 2 octets, where k is the length of the RSA n in octets and hLen is the length of the output of the underlying in octets. Unlike earlier padding methods, RSAES-OAEP incorporates randomization through a value and uses a mask generation function to expand and obfuscate the message, providing provable security in the model assuming the difficulty of inverting the function. The key components of RSAES-OAEP include the EME-OAEP encoding scheme, a (such as SHA-256, which produces hLen = 32 octets), and the mask generation function MGF1, which is based on the hash function and generates a pseudorandom string of arbitrary length from a . MGF1 operates by iteratively hashing the seed concatenated with a counter to produce the mask, ensuring across the padded data. An optional L (defaulting to an ) allows for additional context in the encoding, with its hash lHash = \text{Hash}(L) prepended to the padded message; the label length must not exceed $2^{61} - 1 octets to prevent overflow issues. These elements together ensure that the encoded message block EM is exactly k octets long before exponentiation. The encryption process, RSAES-OAEP-ENCRYPT, takes as input the RSA public key (n, e), a message M of length mLen \leq k - 2hLen - 2, and the optional label L. It proceeds as follows:
  1. If L is not provided, set L to the empty string and compute lHash = \text{Hash}(L). Generate a padding string PS consisting of k - mLen - 2hLen - 2 zero octets. Form the data block DB = lHash || PS || 0x01 || M.
  2. Generate a random of hLen octets. Compute the mask dbMask = \text{MGF1}(seed, k - hLen), where the mask length is the length of DB. Then, maskedDB = DB \oplus dbMask, where \oplus denotes octet-wise XOR. Compute seedMask = MGF1(maskedDB, hLen), and maskedSeed = \oplus seedMask. The encoded message is EM = 0x00 || maskedSeed || maskedDB.
  3. Convert EM to an integer m = OS2IP(EM), compute the ciphertext integer c = RSAEP(n, e, m) = m^e \mod n, and output the ciphertext C = I2OSP(c, k).
This encoding expands the message while randomizing it, preventing deterministic attacks on the underlying function. The full OAEP expansion can be represented as: \begin{align*} &[DB](/page/DB) = lHash || [PS](/page/PS) || 0x01 || [M](/page/M), \\ &masked[DB](/page/DB) = [DB](/page/DB) \oplus \text{MGF1}([seed](/page/Seed), |[DB](/page/DB)|), \\ &maskedSeed = [seed](/page/Seed) \oplus \text{MGF1}(masked[DB](/page/DB), hLen), \\ &[EM](/page/EM) = 0x00 || maskedSeed || masked[DB](/page/DB), \end{align*} followed by C = I2OSP( \text{OS2IP}([EM](/page/EM))^e \mod n, k ). Decryption, RSAES-OAEP-DECRYPT, reverses the process using the RSA private key K (corresponding to modulus length k) and C, with the same L. It requires k \geq 2hLen + 2.
  1. Convert C to c = OS2IP(C). Compute m = RSADP(K, c); if c \geq n or the operation fails, output "decryption error". Convert back to EM = I2OSP(m, k). If the leading octet of EM is not 0x00, output "decryption error".
  2. Compute lHash = \text{Hash}(L). Extract maskedSeed (first hLen octets after 0x00) and maskedDB (remaining k - hLen - 1 octets). Compute seedMask = MGF1(maskedDB, hLen), so seed = maskedSeed \oplus seedMask. Then, dbMask = MGF1(seed, k - hLen - 1), and DB = maskedDB \oplus dbMask.
  3. Parse DB for lHash' (first hLen octets), followed by zero octets PS, a 0x01 octet, and message M. If lHash' ≠ lHash, no 0x01 is found, or PS contains non-zero octets, output "decryption error". Otherwise, output M.
These checks ensure and recover the original , rejecting invalid or tampered ciphertexts without leaking .

Signature Schemes

RSASSA-PKCS1-v1_5

RSASSA-PKCS1-v1_5 is a with appendix that combines the signing primitive RSASP1 with the deterministic encoding method EMSA-PKCS1-v1_5 to produce signatures on messages of arbitrary length, provided a suitable is used. It was originally specified in PKCS#1 version 1.5 and remains included in later versions for with legacy systems. The assumes the infeasibility of computing e-th roots modulo the RSA modulus n and relies on the security of the underlying to prevent collisions. The signing process begins by applying a to the M to produce a value H, followed by encoding the identifier and H into a DER-encoded DigestInfo T, where tLen denotes the of T in octets. If the intended encoded emLen (equal to the octet k of the RSA modulus n) is less than tLen + 11, the process fails with an error. Otherwise, a padding string PS of emLen - tLen - 3 octets, consisting entirely of 0xFF bytes, is generated. The encoded EM is then constructed as the concatenation: \text{EM} = 0x00 \parallel 0x01 \parallel \text{PS} \parallel 0x00 \parallel \text{T} where \parallel denotes concatenation. This EM is converted to an integer m via the octet string to integer primitive OS2IP, and the signature representative s is computed using the RSA private key (n, d) as s = m^d \mod n. Finally, the signature S is the integer s converted back to an octet string of length k via I2OSP. The process outputs S or fails with errors such as "message too long" if the hash exceeds allowable limits. Verification uses the signer's public key (n, e) and proceeds by first confirming that the signature S has exactly k octets. The octet string S is converted to an s via OS2IP, and an m is recovered as m = s^e \mod n using the RSA verification primitive RSAVP1. This m is then converted to an octet string EM' of length k via I2OSP. Independently, the original message M is re-encoded using EMSA-PKCS1-v1_5 to produce EM, and the scheme outputs "valid " if EM equals EM', ensuring the padding structure (starting with 0x00 || 0x01, followed by 0xFF padding, a 0x00 separator, and the matching DigestInfo) and hash value are intact; otherwise, it outputs "invalid ". Errors like "RSA modulus too short" may occur if parameters are invalid. The scheme supports a range of digest algorithms, each prefixed with its AlgorithmIdentifier in the DigestInfo T, including MD2 (tLen=18), (tLen=18), (tLen=35), SHA-224 (tLen=47), SHA-256 (tLen=51), SHA-384 (tLen=67), SHA-512 (tLen=83), SHA-512/224 (tLen=47), and SHA-512/256 (tLen=51). These identifiers are DER-encoded as specified in RFC 8017, Appendix A.2, to ensure interoperability.

RSASSA-PSS

RSASSA-PSS is a probabilistic scheme with appendix, defined in PKCS#1 and subsequent revisions, that combines the signature primitive (RSASP1) with the EMSA-PSS encoding method to produce signatures with provable security properties. The scheme operates on messages of arbitrary length by first ing the input and then applying a randomized padding mechanism, ensuring existential unforgeability under chosen-message attacks in the model, provided the is intractable and the underlying and generation functions are secure. This design, originally proposed by Bellare and Rogaway, enhances resistance to forgery compared to deterministic alternatives by incorporating , making it suitable for high-security applications. The core components of RSASSA-PSS include an private K (typically (n, d), where n is the and d is the private exponent) for signing and the corresponding public (n, e) for verification, along with a (Hash, such as SHA-256) and a mask generation function (MGF, usually MGF1 based on the same ). A element is the , a random octet string of length sLen octets, which introduces probabilistic behavior to thwart certain attacks. Relevant parameters are emBits (the intended of the encoded EM, typically one less than the of n), hLen (the octet length of the output), and sLen (the length, recommended to be at least 8 octets and often equal to hLen - 2 for optimal security). The signing process begins by computing mHash = \text{Hash}(M), where M is the message to sign. A random salt of length sLen is generated. The EMSA-PSS encoding is then applied to produce EM of length emLen = \lceil emBits / 8 \rceil octets: first form M' = eight zero octets \| mHash \| salt, then compute H = \text{Hash}(M'); next, construct the data block DB = padding string PS (of emLen - sLen - hLen - 2 zero octets) \| 0x01 \| salt, generate the mask dbMask = \text{MGF}(H, emLen - hLen - 1), compute maskedDB = DB \oplus dbMask, set the leftmost $8 \cdot emLen - emBits bits of maskedDB to zero if emBits is not a multiple of 8, and finally form EM = maskedDB \| H \| 0xBC. This EM is converted to an integer m = OS2IP(EM), and the signature integer s = RSASP1(K, m) = m^d \mod n is output as the octet string S = I2OSP(s, k), where k =\lceil (\text{bit length of } n)/8 \rceil. Verification recovers the encoded message by converting the signature S to integer s = OS2IP(S), computing m = RSAVP1((n, e), s) = s^e \mod n, and converting back to EM = I2OSP(m, emLen). The EMSA-PSS verification then extracts H' (the hLen octets before the final 0xBC octet) and maskedDB from EM, generates dbMask = MGF(H', emLen - hLen - 1), unmasks DB = maskedDB \oplus dbMask, checks that the rightmost octet of maskedDB is 0xBC, the leftmost bits are zero as required, and DB starts with PS \| 0x01 followed by a salt of length sLen; it then recomputes M'' = eight zero octets \| mHash \| extracted salt, H'' = \text{Hash}(M''), and mHash = \text{Hash}(M), verifying that H' = H''. If all checks pass, the signature is valid; otherwise, it is invalid. The full PSS encoding integrates the salt for randomization within a masked structure, represented as: \text{EM} = \underbrace{\text{maskedDB}}_{\text{length: } emLen - hLen - 1} \ \| \ \underbrace{H}_{\text{length: } hLen} \ \| \ 0\text{xBC} where maskedDB derives from the XOR of the data block (padding \| 0x01 \| salt) with the MGF output from H = Hash(eight zero octets \| Hash(M) \| salt), ensuring the padding is indistinguishable from random without the salt. This construction provides the scheme's security foundation, with proofs showing that breaking RSASSA-PSS implies solving the RSA problem or distinguishing the hash/MGF from random oracles.

Version History

Versions 1.0 to 1.5

The Standards (PKCS) #1 specification originated with version 1.0 in 1991, developed and privately distributed by RSA Data Security, Inc., to define basic -based for and digital signatures. This initial version introduced minimal mechanisms for , known as EME-PKCS1-v1_5, which prepends a padding string to the before , and a corresponding signature scheme, EMSA-PKCS1-v1_5, which applies similar to a digest for verification. These schemes provided foundational support for operations in public-key systems but lacked explicit integration with hash functions, relying instead on direct or basic . Subsequent minor revisions from version 1.1 to 1.3, in February through March 1991, and version 1.4 in June 1991, were handled internally by Laboratories through working group distributions, with version 1.4 marking the first public release on June 3, 1991, as part of the broader suite documented in NIST/OSI Implementors' materials. These updates refined the basic primitives and syntax for public and private keys, improving interoperability with emerging standards like for certificate encoding. Version 1.4 consolidated these enhancements into a more structured format suitable for implementors. Version 1.5, first issued in November 1993 and published as IETF informational 2313 in March 1998, represented a significant milestone, signaling a transition from RSA Laboratories' proprietary oversight to broader community influence under IETF auspices. It formally standardized the EME-PKCS1-v1_5 scheme, which uses a deterministic of 00 02 followed by random non-zero bytes and a message separator, and the EMSA-PKCS1-v1_5 scheme, which embeds a DigestInfo structure containing the hash algorithm identifier (supporting , , and ) within a padded block. These mechanisms ensured compatibility with existing implementations while specifying exact byte-level formats for blocks and values. 2313 was later obsoleted by 2437 in October 1998, which introduced with expanded features. At this stage, PKCS #1 remained focused on these legacy methods, without incorporating probabilistic schemes like OAEP for or PSS for s.

Versions 2.0 to 2.2

PKCS#1 version 2.0, published in October 1998 as RFC 2437, marked a significant advancement by introducing the RSAES-OAEP encryption scheme, which incorporates optimal asymmetric encryption padding to enhance security against chosen-ciphertext attacks under the random oracle model. This version also removed support for the MD4 hash function due to emerging cryptanalytic weaknesses, while retaining the RSASSA-PKCS1-v1_5 signature scheme and providing initial security analyses linking scheme robustness to the difficulty of inverting the RSA function with sufficiently large keys. Although it included discussions on plaintext-aware properties for OAEP, full provable security arguments were not yet formalized. Version 2.1, released in February 2003 as RFC 3447, built upon its predecessor by adding the RSASSA-PSS signature scheme, a designed to provide existential unforgeability against adaptive chosen-message attacks in the model. It also introduced support for multi-prime RSA to improve computational efficiency in and operations, while formalizing proofs for both RSAES-OAEP and RSASSA-PSS, establishing their to the under standard assumptions. Regarding hash functions, this version restricted MD2 and MD5 to compatibility use with the legacy PKCS1-v1_5 scheme, recommending stronger alternatives like SHA-1, SHA-256, SHA-384, and SHA-512 for new implementations due to vulnerabilities in the older hashes. The current version 2.2, published in November 2016 as RFC 8017, obsoleted RFC 3447 and incorporated errata fixes, clarified the application of the MGF1 mask generation function—recommending it use the same underlying hash as the primary scheme for consistency—and expanded support for family hashes by adding SHA-224, SHA-512/224, and SHA-512/256 to align with FIPS 180-4. These updates emphasized probabilistic schemes like OAEP and PSS as preferred for their provable security properties, while maintaining for deterministic alternatives in legacy contexts. As of 2025, no major revisions have occurred, though NIST guidelines in the have discussed deprecating RSA-based mechanisms with key sizes below 2048 bits by 2030 due to post-quantum threats, without altering the PKCS#1 specification itself.

Implementations

Software Libraries

, a widely used open-source cryptographic library, provides comprehensive support for all PKCS#1 schemes through its high-level EVP interface, which abstracts low-level operations and includes legacy PKCS#1 v1.5 padding alongside modern v2.0+ features like OAEP and PSS. The EVP interface enables secure encryption and signing; for instance, OAEP encryption can be performed using EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_OAEP_PADDING) followed by EVP_PKEY_encrypt, with options for specifying hash functions like SHA-256 via EVP_PKEY_CTX_set_rsa_oaep_md. This design promotes safe usage by handling padding internally and warning against insecure legacy modes in recent versions. Bouncy Castle, available for and C#, offers full PKCS#1 compliance, implementing (RSAES-PKCS1-v1_5 and RSAES-OAEP) and signature schemes (RSASSA-PKCS1-v1_5 and RSASSA-PSS) with integrated parsing for key and message formatting as defined in 8017. Key classes like PKCS1Encoding handle padding schemes, ensuring interoperability with standards-compliant systems, while the library's modular structure allows customization of underlying hashes and masks for OAEP/PSS operations. Crypto++, a C++ library focused on performance, supports high-speed implementations of PKCS#1 schemes, including PSS for probabilistic signatures and OAEP for , optimized for large-scale applications with where available. It provides classes like RSAES<OAEP<SHA256>> for and RSASS<PSS> for signing, adhering to RFC 8017 specifications for and encoding. Other notable libraries include Python's module, which implements PKCS#1 v1.5 and v2.2 schemes via its hazmat.primitives.asymmetric.[rsa](/page/RSA) package, supporting OAEP with rsa.OAEP and PSS signing with rsa.PSS; Go's standard crypto/[rsa](/page/RSA) package, which directly implements PKCS#1 and signatures per RFC 8017 using functions like EncryptOAEP and SignPSS; and Intel's Integrated Performance Primitives (IPP) Cryptography library, which accelerates PKCS#1 v1.5 operations like ippsRSAEncrypt_PKCSv15 for embedded and . As of , these libraries have incorporated warnings about RSA's vulnerability to quantum attacks, urging migration to post-quantum alternatives, though no new PKCS#1 version has been released since RFC 8017 in 2016.

Compliance and Standards

PKCS#1 schemes are integral to several foundational cryptographic standards. In the (TLS) protocol version 1.2, as defined in RFC 5246, RSA key exchange employs RSAES-PKCS1-v1_5 for encrypting the premaster secret, while digital signatures in handshakes and certificates use RSASSA-PKCS1-v1_5 with specified hash functions. Similarly, the (CMS) in RFC 5652 utilizes PKCS#1 for RSA-based key transport in enveloped data, where the content-encryption key is encrypted via RSAES-PKCS1-v1_5 or RSAES-OAEP, and for signing operations in signed data via RSASSA-PKCS1-v1_5 or RSASSA-PSS. PKCS#1 also underpins RSA key structures in X.509 certificates, with the rsaEncryption object identifier (1.2.840.113549.1.1.1) and associated ASN.1 encodings enabling public key representation and usage in certificate profiles as outlined in RFC 5280. Implementation compliance with PKCS#1 is rigorously tested through the NIST Cryptographic Algorithm Validation Program (CAVP), which evaluates primitives such as RSASP1 for signature generation (supporting both PKCS#1 v1.5 and PSS ) and RSADP for decryption, aligned with FIPS 186-4 requirements. These tests generate automated vectors to verify correctness across key sizes and moduli, ensuring modules meet federal standards before Cryptographic Module Validation Program (CMVP) certification. Additionally, RFC 8017 provides sample inputs and outputs for encryption and signature schemes, including detailed examples for RSAES-OAEP and RSASSA-PSS operations, serving as reference vectors for developer verification. The specification is maintained by the IETF Crypto Forum Research Group (CFRG), which published 8017 as the authoritative version 2.2 in 2016 and continues to issue guidance through ongoing drafts, including the September 2025 revision of "Implementation Guidance for the PKCS #1 RSA Cryptography Specification" (draft-irtf-cfrg-rsa-guidance). CFRG recommendations explicitly deprecate RSAES-PKCS1-v1_5 and RSASSA-PKCS1-v1_5 in new designs, mandating RSAES-OAEP for and RSASSA-PSS for signatures to mitigate known vulnerabilities, with additional guidance on side-channel protections such as constant-time operations and blinding techniques. This shift, emphasized in CFRG documents since 2023, prioritizes provably secure primitives while preserving for legacy deployments. Interoperability is facilitated by PKCS#1's module, which standardizes PublicKey and RSAPrivateKey structures for encoding parameters like modulus and exponents, enabling seamless integration across libraries and protocols such as and . These definitions ensure cross-vendor compatibility for and operations. However, legacy systems adhering to PKCS#1 v1.5 often face interoperability challenges with modern endpoints, exacerbated by exploitable flaws like the Marvin , which affects older TLS, , and token implementations supporting vulnerable padding.

Security Considerations

Known Attacks

One of the most significant vulnerabilities in early PKCS#1 implementations is Bleichenbacher's on RSAES-PKCS1-v1_5 encryption, introduced in 1998. This adaptive attack exploits a —where a decryption device reveals whether a has valid PKCS#1 v1.5 (block type 02)—to gradually narrow down the space through iterative queries. By crafting modified and observing oracle responses, an attacker can decrypt an arbitrary target using approximately 10^5 to 10^6 queries, making it practical against real-world systems like SSL/TLS servers. For signatures, RSASSA-PKCS1-v1_5 is susceptible to broadcast attacks when the same message is signed under multiple public keys with small exponents (e.g., e=3), as demonstrated by Håstad in 1988; using the on the resulting congruences enables message recovery with high probability if at least e recipients are involved. In contrast, the RSAES-OAEP and RSASSA-PSS schemes introduced in PKCS#1 v2.0 provide stronger security guarantees. Both are provably secure against chosen-ciphertext attacks in the model, assuming the underlying and mask generation function behave ideally, as formalized by Bellare and Rogaway for OAEP in 1994 and extended to PSS in 1996. However, real-world implementations remain vulnerable to side-channel attacks, such as timing discrepancies during padding validation or to bypass checks, which can leak information about intermediate values. A notable example is Manger's attack (2001), which exploits leaks in OAEP decoding to perform chosen-ciphertext attacks with around 2^14 to 2^16 interactions. Post-2012 analyses confirm no fundamental breaks on the core RSAES-OAEP or RSASSA-PSS in PKCS#1 v2.2, but legacy v1.5 usage persists in protocols like TLS, enabling variants of Bleichenbacher's attack. The attack, disclosed in 2017, exploits such oracles in TLS handshakes to recover session keys or cookies using about 65,000 queries across multiple connections, affecting numerous servers due to incomplete mitigations. More recently, the Marvin attack (2023) demonstrated practical timing-based Bleichenbacher variants on both PKCS#1 v1.5 and OAEP implementations, allowing attackers to perform decryption or signing operations by observing cache-timing differences during padding checks, often requiring only thousands of observations.

Best Practices and Mitigations

To ensure secure implementation of PKCS#1 schemes, it is recommended to prefer RSAES-OAEP for encryption and RSASSA-PSS for signatures over the older PKCS#1 v1.5 padding, as the latter is vulnerable to chosen-ciphertext attacks and lacks probabilistic padding. key sizes of at least 3000 bits should be used to provide adequate security against factoring attacks, as recommended by authorities like BSI; 2048-bit keys remain acceptable under NIST guidelines until December 31, 2030, but larger sizes (e.g., 3072 bits or more) are advised for protection beyond 2030. Additionally, hash functions such as SHA-256 or stronger must be employed in conjunction with these schemes to maintain . Mitigations against side-channel attacks require constant-time implementations for critical operations like in , ensuring that execution time and memory access patterns do not leak information about keys or messages. To counter padding oracle vulnerabilities, particularly in legacy v1.5 deployments, error blinding techniques should be applied during decryption, randomizing responses to invalid paddings without revealing structural details. NIST Special Publication 800-131A Revision 2 deprecates PKCS#1 v1.5 for encryption, key establishment, and key transport, with legacy use acceptable only until December 31, 2030, mandating a transition to more secure alternatives thereafter. In preparation for quantum threats, organizations are advised to migrate toward hybrid schemes combining classical with post-quantum algorithms like ML-KEM, as outlined in NIST's 2024 transition guidance, to enable gradual adoption without disrupting existing infrastructure. Specific best practices include generating random salts of appropriate length (typically matching the output size) during RSASSA-PSS signing to enhance against attempts, ensuring each incorporates fresh . For RSAES-OAEP, a non-empty should be used when contextual binding is needed, such as specifying the intended recipient or application, to prevent misuse in multi-purpose deployments; otherwise, an empty is acceptable for simplicity. Regular key rotation, at least annually or upon evidence of compromise, is essential to limit exposure, following guidelines for cryptographic .

References

  1. [1]
    RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2
    This document provides recommendations for the implementation of public-key cryptography based on the RSA algorithm.
  2. [2]
    Information on RFC 8017 - » RFC Editor
    This document represents a republication of PKCS #1 v2. 2 from RSA Laboratories' Public-Key Cryptography Standards (PKCS) series. By publishing this RFC, ...<|control11|><|separator|>
  3. [3]
    RFC 2437 - PKCS #1: RSA Cryptography Specifications Version 2.0
    This memo is the successor to RFC 2313. This document provides recommendations for the implementation of public-key cryptography based on the RSA algorithm.
  4. [4]
    RFC 8017 - PKCS #1: RSA Cryptography Specifications Version 2.2
    This document provides recommendations for the implementation of public-key cryptography based on the RSA algorithm.
  5. [5]
    doc: RFC 2313: PKCS #1: RSA Encryption Version 1.5 - hjp
    Version 1.4 is part of the June 3, 1991 initial public release of PKCS. Version 1.4 was published as NIST/OSI Implementors' Workshop document SEC-SIG-91-18.
  6. [6]
    RFC 2313 - PKCS #1: RSA Encryption Version 1.5 - IETF Datatracker
    This document describes a method for encrypting data using the RSA public-key cryptosystem. Its intended use is in the construction of digital signatures and ...Missing: early obsoletions
  7. [7]
    RFC 3447 - Public-Key Cryptography Standards (PKCS) #1
    This document provides recommendations for the implementation of public-key cryptography based on the RSA algorithm
  8. [8]
    [PDF] An Overview of the PKCS Standards
    The three algorithm standards—PKCS #1 (RSA Encryption Standard), PKCS #3 ... The November 1, 1993 version incorporates several editorial changes, including.
  9. [9]
  10. [10]
  11. [11]
    ASN.1 objects: binary DER- and BER-encoded files vs PEM ...
    Example. An RSA public key is represented with the ASN.1 type RSAPublicKey specified in PKCS#1 [RFC3447] RSAPublicKey ::= SEQUENCE { modulus INTEGER, -- n ...
  12. [12]
  13. [13]
  14. [14]
  15. [15]
  16. [16]
  17. [17]
  18. [18]
  19. [19]
  20. [20]
  21. [21]
  22. [22]
  23. [23]
  24. [24]
    [PDF] Optimal Asymmetric Encryption How to Encrypt with RSA - UCSD CSE
    Nov 19, 1995 · De Santis ed., Springer-Verlag, 1994. Optimal Asymmetric Encryption. How to Encrypt with RSA. Mihir Bellare∗. Phillip Rogaway†.
  25. [25]
  26. [26]
  27. [27]
  28. [28]
  29. [29]
  30. [30]
    [PDF] The Exact Security of Digital Signatures How to Sign with RSA and ...
    Mar 14, 1996 · We describe an RSA-based signing scheme called PSS which combines essentially optimal effi- ciency with attractive security properties. Signing ...Missing: original | Show results with:original
  31. [31]
    RFC 2313: PKCS #1: RSA Encryption Version 1.5
    This document describes a method for encrypting data using the RSA public-key cryptosystem. Its intended use is in the construction of digital signatures and ...<|control11|><|separator|>
  32. [32]
    RFC 2437: PKCS #1: RSA Cryptography Specifications Version 2.0
    Revision history Versions 1.0-1.3 Versions 1.0-1.3 were distributed to participants in RSA Data Security, Inc.'s Public-Key Cryptography Standards meetings ...
  33. [33]
    [PDF] Transitioning the Use of Cryptographic Algorithms and Key Lengths
    Oct 21, 2024 · The use of SHA-1 is deprecated through December 31, 2030, for applying protection in ... PKCS #1: RSA Cryptography. Specifications Version 2.2. ( ...Missing: 2020s | Show results with:2020s
  34. [34]
    evp - OpenSSL Documentation
    The EVP library provides a high-level interface to cryptographic functions. The EVP_SealXXX and EVP_OpenXXX functions provide public key encryption and ...
  35. [35]
    RSA_padding_add_PKCS1_typ...
    You should prefer the use of EVP PKEY APIs for PKCS#1 v1.5 decryption as they implement the necessary workarounds internally. SEE ALSO¶ · RSA_public_encrypt(3) ...Synopsis · Description · WarningsMissing: interface | Show results with:interface
  36. [36]
    Documentation Bouncy Castle Java - Bouncycastle
    The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms and cryptographic protocols that make use of the algorithms.
  37. [37]
    RSA — Cryptography 47.0.0.dev1 documentation
    Larger keys provide more security; currently 1024 and below are considered breakable while 2048 or 4096 are reasonable default key sizes for new keys. The ...
  38. [38]
    crypto/rsa - Go Packages
    Package rsa implements RSA encryption as specified in PKCS #1 and RFC 8017. RSA is a single, fundamental operation that is used in this package.Documentation · Overview · Functions · Types
  39. [39]
    RSAEncrypt_PKCSv15 - Intel
    Reference for how to use the Intel® IPP Cryptography library, including security features, encryption protocols, data protection solutions, symmetry and ...
  40. [40]
    RFC 5246 - The Transport Layer Security (TLS) Protocol Version 1.2
    This document specifies Version 1.2 of the Transport Layer Security (TLS) protocol. The TLS protocol provides communications security over the Internet.
  41. [41]
    RFC 5652 - Cryptographic Message Syntax (CMS) - IETF Datatracker
    This document describes the Cryptographic Message Syntax (CMS). This syntax is used to digitally sign, digest, authenticate, or encrypt arbitrary message ...
  42. [42]
    RFC 5280 - Internet X.509 Public Key Infrastructure Certificate and ...
    This memo profiles the X.509 v3 certificate and X.509 v2 certificate revocation list (CRL) for use in the Internet.
  43. [43]
    Cryptographic Algorithm Validation Program | CSRC
    The NIST Cryptographic Algorithm Validation Program (CAVP) provides validation testing of Approved (ie, FIPS-approved and NIST-recommended) cryptographic ...Validation Search · CAVP Testing: Block Ciphers · Component Testing · Retired
  44. [44]
    Component Testing - Cryptographic Algorithm Validation Program
    The RSASP1 Signature Primitive Validation System (RSASP1VS) specifies validation testing requirements for the RSASP1 function as described in PKCS#1 v2.1: RSA ...Missing: compliance | Show results with:compliance
  45. [45]
    The Marvin Attack - Red Hat People
    Sep 25, 2023 · The Marvin Attack is a return of a 25 year old vulnerability that allows performing RSA decryption and signing operations as an attacker.
  46. [46]
    Chosen ciphertext attacks against protocols based on the RSA ...
    May 28, 2006 · Cite this paper. Bleichenbacher, D. (1998). Chosen ciphertext attacks against protocols based on the RSA encryption standard PKCS #1. In ...
  47. [47]
    A Chosen Ciphertext Attack on RSA Optimal Asymmetric Encryption ...
    Abstract. An adaptive chosen ciphertext attack against PKCS #1 v2.0 RSA OAEP encryption is described. It recovers the plaintext - not the private key ...Missing: original | Show results with:original
  48. [48]
    Return Of Bleichenbacher's Oracle Threat (ROBOT) - USENIX
    Abstract: In 1998 Bleichenbacher presented an adaptive chosen-ciphertext attack on the RSA PKCS~#1~v1.5 padding scheme. The attack exploits ...Missing: original | Show results with:original
  49. [49]
    Implementation Guidance for the PKCS #1 RSA Cryptography ... - IETF
    Mar 4, 2024 · This document specifies additions and amendments to RFC 8017. Specifically, it provides guidance to implementers of the standard to protect ...
  50. [50]
    [PDF] Recommendations and Key Lengths, Version 2025-01 - BSI
    Recommenda- tion of Argon2id for password-based key derivation. Transitional extension of the conformance of RSA keys with a key length of 2000 bits or more to ...
  51. [51]
    [PDF] Transitioning the Use of Cryptographic Algorithms and Key Lengths
    Mar 2, 2019 · 2, Use of Non-NIST Recommended Asymmetric Key Sizes and Elliptic Curves. ... Guidance on key lengths for RSA is provided in SP 800-56B. SP ...
  52. [52]
    [PDF] NIST IR 8547 initial public draft, Transition to Post-Quantum ...
    Nov 12, 2024 · These guidelines had projected that NIST would disallow public-key schemes that provide 112 bits of security on January 1, 2031. However, based ...Missing: 2020s | Show results with:2020s
  53. [53]
    [PDF] Part 3: Application-Specific Key Management Guidance
    Jan 1, 2015 · Part 1 provides general guidance and best practices for the management of cryptographic keying material. Part 2 provides guidance on policy ...