Skip to content

Commit cbb4cbd

Browse files
committed
Rename TLS 1.3 ACVP handlers and add BoringSSL attribution
Address review feedback: - Rename the new modulewrapper ACVP handlers HKDFExtract/HKDFExpandLabel to TLS13_HKDFExtract/TLS13_HKDFExpandLabel. The ACVP command strings on the wire are unchanged; only the C++ identifiers move. This matches the existing TLSKDF / "TLSKDF/1.2/..." convention in the same file and disambiguates the new helpers from the generic HKDF / HKDF_expand helpers (KDA/HKDF and KDF/Feedback) already defined in this TU. - Add in-code attribution for the parts of this change that are ported from BoringSSL: the pair of ACVP handlers in modulewrapper.cc and the HkdfLabel/CBB construction in CRYPTO_tls13_hkdf_expand_label. The comment on the latter also calls out that the FIPS service-indicator lock/unlock and TLS13_KDF_verify_service_indicator call are AWS-LC-specific, to make the port vs. novel split explicit for future reviewers and for resyncs with BoringSSL upstream.
1 parent 59e6bb9 commit cbb4cbd

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

crypto/fipsmodule/tls/kdf.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ int CRYPTO_tls1_prf(const EVP_MD *digest,
130130
return ret;
131131
}
132132

133+
// CRYPTO_tls13_hkdf_expand_label: the HkdfLabel / CBB construction and the
134+
// overall shape of this function are ported from BoringSSL's
135+
// |tls13_hkdf_expand_label| (|crypto/fipsmodule/tls/internal.h|, originally
136+
// |hkdf_expand_label| in |ssl/tls13_enc.cc|), translated from C++ to C. The
137+
// FIPS service-indicator lock/unlock and |TLS13_KDF_verify_service_indicator|
138+
// call at the end are AWS-LC-specific and have no BoringSSL analogue.
133139
int CRYPTO_tls13_hkdf_expand_label(uint8_t *out, size_t out_len,
134140
const EVP_MD *digest,
135141
const uint8_t *secret, size_t secret_len,

util/fipstools/acvp/modulewrapper/modulewrapper.cc

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3246,9 +3246,15 @@ static bool TLSKDF(const Span<const uint8_t> args[],
32463246
return write_reply({out});
32473247
}
32483248

3249+
// TLS 1.3 KDF ACVP handlers. Ported from BoringSSL's
3250+
// util/fipstools/acvp/modulewrapper/modulewrapper.cc |HKDFExtract| and
3251+
// |HKDFExpandLabel|. Named with a TLS13_ prefix here because both are wired
3252+
// to the TLS-v1.3 ACVP suite (RFC 8446) and, in the case of |TLS13_HKDFExtract|,
3253+
// to distinguish it from the generic |HKDF| / |HKDF_expand| helpers already
3254+
// defined in this translation unit for KDA/HKDF and KDF/Feedback.
32493255
template <const EVP_MD *(MDFunc)()>
3250-
static bool HKDFExtract(const Span<const uint8_t> args[],
3251-
ReplyCallback write_reply) {
3256+
static bool TLS13_HKDFExtract(const Span<const uint8_t> args[],
3257+
ReplyCallback write_reply) {
32523258
const Span<const uint8_t> ikm = args[0];
32533259
const Span<const uint8_t> salt = args[1];
32543260
const EVP_MD *md = MDFunc();
@@ -3264,8 +3270,8 @@ static bool HKDFExtract(const Span<const uint8_t> args[],
32643270
}
32653271

32663272
template <const EVP_MD *(MDFunc)()>
3267-
static bool HKDFExpandLabel(const Span<const uint8_t> args[],
3268-
ReplyCallback write_reply) {
3273+
static bool TLS13_HKDFExpandLabel(const Span<const uint8_t> args[],
3274+
ReplyCallback write_reply) {
32693275
const Span<const uint8_t> out_len_bytes = args[0];
32703276
const Span<const uint8_t> secret = args[1];
32713277
const Span<const uint8_t> label = args[2];
@@ -4275,10 +4281,10 @@ static struct {
42754281
{"TLSKDF/1.2/SHA2-256", 5, TLSKDF<EVP_sha256>},
42764282
{"TLSKDF/1.2/SHA2-384", 5, TLSKDF<EVP_sha384>},
42774283
{"TLSKDF/1.2/SHA2-512", 5, TLSKDF<EVP_sha512>},
4278-
{"HKDFExtract/SHA2-256", 2, HKDFExtract<EVP_sha256>},
4279-
{"HKDFExtract/SHA2-384", 2, HKDFExtract<EVP_sha384>},
4280-
{"HKDFExpandLabel/SHA2-256", 4, HKDFExpandLabel<EVP_sha256>},
4281-
{"HKDFExpandLabel/SHA2-384", 4, HKDFExpandLabel<EVP_sha384>},
4284+
{"HKDFExtract/SHA2-256", 2, TLS13_HKDFExtract<EVP_sha256>},
4285+
{"HKDFExtract/SHA2-384", 2, TLS13_HKDFExtract<EVP_sha384>},
4286+
{"HKDFExpandLabel/SHA2-256", 4, TLS13_HKDFExpandLabel<EVP_sha256>},
4287+
{"HKDFExpandLabel/SHA2-384", 4, TLS13_HKDFExpandLabel<EVP_sha384>},
42824288
{"ECDH/P-224", 3, ECDH<NID_secp224r1>},
42834289
{"ECDH/P-256", 3, ECDH<NID_X9_62_prime256v1>},
42844290
{"ECDH/P-384", 3, ECDH<NID_secp384r1>},

0 commit comments

Comments
 (0)