The method is a combination of an ECC Diffie-Hellman method to establish a shared secret, a key derivation method to process the shared secret into a derived key, and a key wrapping method that uses the derived key to protect a session key used to encrypt a message.¶
The One-Pass Diffie-Hellman method C(1, 1, ECC CDH) [SP800-56A] MUST be implemented with the following restrictions: the ECC CDH primitive employed by this method is modified to always assume the cofactor as 1, the KDF specified in Section 13.3 is used, and the KDF parameters specified below are used.¶
The KDF parameters are encoded as a concatenation of the following 5 variable-length and fixed-length fields, compatible with the definition of the OtherInfo bitstring [SP800-56A]:¶
-
a variable-length field containing a curve OID, formatted as follows:¶
- a one-octet size of the following field¶
- the octets representing a curve OID, defined in Section 9.2¶
- a one-octet public key algorithm ID defined in Section 9.1¶
-
a variable-length field containing KDF parameters, identical to the corresponding field in the ECDH public key, formatted as follows:¶
- a one-octet size of the following fields; values 0 and 0xff are reserved for future extensions¶
- a one-octet value 01, reserved for future extensions¶
- a one-octet hash function ID used with the KDF¶
- a one-octet algorithm ID for the symmetric algorithm used to wrap the symmetric key for message encryption; see Section 13.4 for details¶
- 20 octets representing the UTF-8 encoding of the string
Anonymous Sender
, which is the octet sequence 41 6E 6F 6E 79 6D 6F 75 73 20 53 65 6E 64 65 72 20 20 20 20¶
- 20 octets representing a recipient encryption subkey or a master key fingerprint, identifying the key material that is needed for the decryption.
For version 5 keys the 20 leftmost octets of the fingerprint are used.¶
The size of the KDF parameters sequence, defined above, is either 54 for the NIST curve P-256, 51 for the curves P-384 and P-521, or 56 for Curve25519.¶
The key wrapping method is described in [RFC3394].
KDF produces a symmetric key that is used as a key-encryption key (KEK) as specified in [RFC3394].
Refer to Section 15 for the details regarding the choice of the KEK algorithm, which SHOULD be one of three AES algorithms.
Key wrapping and unwrapping is performed with the default initial value of [RFC3394].¶
The input to the key wrapping method is the value "m" derived from the session key, as described in Section 5.1, "Public-Key Encrypted Session Key Packets (Tag 1)", except that the PKCS #1.5 padding step is omitted.
The result is padded using the method described in [PKCS5] to the 8-byte granularity.
For example, the following AES-256 session key, in which 32 octets are denoted from k0 to k31, is composed to form the following 40 octet sequence:¶
09 k0 k1 ... k31 c0 c1 05 05 05 05 05
¶
The octets c0 and c1 above denote the checksum.
This encoding allows the sender to obfuscate the size of the symmetric encryption key used to encrypt the data.
For example, assuming that an AES algorithm is used for the session key, the sender MAY use 21, 13, and 5 bytes of padding for AES-128, AES-192, and AES-256, respectively, to provide the same number of octets, 40 total, as an input to the key wrapping method.¶
The output of the method consists of two fields.
The first field is the MPI containing the ephemeral key used to establish the shared secret.
The second field is composed of the following two fields:¶
- a one-octet encoding the size in octets of the result of the key wrapping method; the value 255 is reserved for future extensions;¶
- up to 254 octets representing the result of the key wrapping method, applied to the 8-byte padded session key, as described above.¶
Note that for session key sizes 128, 192, and 256 bits, the size of the result of the key wrapping method is, respectively, 32, 40, and 48 octets, unless the size obfuscation is used.¶
For convenience, the synopsis of the encoding method is given below; however, this section, [SP800-56A], and [RFC3394] are the normative sources of the definition.¶
- Obtain the authenticated recipient public key R¶
- Generate an ephemeral key pair {v, V=vG}¶
- Compute the shared point S = vR;¶
- m = symm_alg_ID || session key || checksum || pkcs5_padding;¶
- curve_OID_len = (byte)len(curve_OID);¶
- Param = curve_OID_len || curve_OID || public_key_alg_ID || 03 || 01 || KDF_hash_ID || KEK_alg_ID for AESKeyWrap ||
Anonymous Sender
|| recipient_fingerprint;¶
- Z_len = the key size for the KEK_alg_ID used with AESKeyWrap¶
- Compute Z = KDF( S, Z_len, Param );¶
- Compute C = AESKeyWrap( Z, m ) as per [RFC3394]¶
- VB = convert point V to the octet string¶
- Output (MPI(VB) || len(C) || C).¶
The decryption is the inverse of the method given.
Note that the recipient obtains the shared secret by calculating¶
S = rV = rvG, where (r,R) is the recipient's key pair.
¶
Consistent with Section 5.14, Modification Detection Code (MDC) MUST be used anytime the symmetric key is protected by ECDH.¶