Skip to content

Commit 80bc584

Browse files
authored
Spec: Improve definition of the encryption algorithm (#155)
This adds a missing return step to the algorithm definition, adds an explicit instruction to throw when encryption fails, and attempts to clarify our commentary on RFC9180. Followup to #147
1 parent 49cd4e0 commit 80bc584

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

spec.bs

+28-9
Original file line numberDiff line numberDiff line change
@@ -1066,16 +1066,35 @@ They return a [=byte sequence=] or an error.
10661066
of « "`aggregation_service`", |sharedInfo| ».
10671067
1. Let (|kem_id|, |kdf_id|, |aead_id|) be (0x0020, 0x0001, 0x0003).
10681068

1069-
Note: These indicate the HPKE algorithm identifiers, specifying the KEM
1070-
function as DHKEM(X25519, HKDF-SHA256), the KDF function as HKDF-SHA256
1071-
and the AEAD function as ChaCha20Poly1305.
1072-
1. Let |hpkeContext| be the result of setting up an [[RFC9180|HPKE]]
1073-
[[RFC9180#name-encryption-to-a-public-key|sender's context]] with |pkR|,
1074-
|info|, |kem_id|, |kdf_id| and |aead_id|.
1069+
Note: The ciphersuite triple above is composed of [[RFC9180|HPKE]]
1070+
[[RFC9180#name-algorithm-identifiers|algorithm identifiers]], specifying
1071+
the [[RFC9180#name-key-encapsulation-mechanism|KEM]] as DHKEM(X25519,
1072+
HKDF-SHA256), the [[RFC9180#name-key-derivation-functions-kd|KDF]]
1073+
function as HKDF-SHA256 and the
1074+
[[RFC9180#name-authenticated-encryption-wi|AEAD]] function as
1075+
ChaCha20Poly1305.
1076+
1. Let (|enc|, |hpkeContext|) be the result of setting up an [[RFC9180|HPKE]]
1077+
[[RFC9180#name-encryption-to-a-public-key|sender's context]] by calling
1078+
`SetupBaseS()` with a public key |pkR|, application-supplied information
1079+
|info|, KEM |kem_id|, KDF |kdf_id|, and AEAD |aead_id|. If this operation
1080+
fails, return an error.
1081+
1082+
Note: For clarity, we explicitly passed the KEM, KDF, and AEAD identifiers
1083+
to `SetupBaseS()` above, even though RFC9180 omits the parameters from its
1084+
pseudocode.
10751085
1. Let |aad| be \`\` (an empty [=byte sequence=]).
1076-
1. Let <var ignore>encryptedPayload</var> be the result of
1077-
[[RFC9180#name-encryption-and-decryption|encrypting]] |plaintextPayload|
1078-
with |hpkeContext| and |aad|.
1086+
1. Let |ciphertext| be the result of
1087+
[[RFC9180#name-encryption-and-decryption|sealing]] the payload by calling
1088+
`ContextS.Seal()` on the |hpkeContext| object with additional authenticated
1089+
data |aad| and plaintext |plaintextPayload|. If this operation fails, return
1090+
an error.
1091+
1. Let |encryptedPayload| be the concatenation of the [=byte sequences=] «
1092+
|enc|, |ciphertext| ».
1093+
1094+
Note: The length of the encapsulated symmetric key <var ignore>enc</var>
1095+
generated by our chosen KEM is exactly 32 bytes, as shown in RFC9180's
1096+
table of [[RFC9180#name-key-encapsulation-mechanism|KEM IDs]].
1097+
1. Return the [=byte sequence=] |encryptedPayload|.
10791098

10801099
</div>
10811100

0 commit comments

Comments
 (0)