Skip to content

Commit cb3e6f4

Browse files
nebeiddavidbensgmendajustsmth
authored
BoringSSL: Const-correct the kPrintMethods table and Update citations from RFC 3447 to RFC 8017 (#3026)
### Issues: ### Description of changes: Cherry-picked and adapted from BoringSSL: - google/boringssl@42dea11 - google/boringssl@92ae3b9 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license. --------- Co-authored-by: David Benjamin <davidben@google.com> Co-authored-by: Sanketh Menda <sgmenda@amazon.com> Co-authored-by: Justin W Smith <103147162+justsmth@users.noreply.github.com>
1 parent 105b1c9 commit cb3e6f4

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

crypto/evp_extra/p_rsa_asn1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static int rsa_priv_decode(EVP_PKEY *out, CBS *oid, CBS *params, CBS *key, CBS *
107107
return 0;
108108
}
109109

110-
// Per RFC 3447, A.1, the parameters have type NULL.
110+
// Per RFC 8017, A.1, the parameters have type NULL.
111111
CBS null;
112112
if (!CBS_get_asn1(params, &null, CBS_ASN1_NULL) ||
113113
CBS_len(&null) != 0 ||

crypto/evp_extra/print.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ typedef struct {
311311
int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent);
312312
} EVP_PKEY_PRINT_METHOD;
313313

314-
static EVP_PKEY_PRINT_METHOD kPrintMethods[] = {
314+
static const EVP_PKEY_PRINT_METHOD kPrintMethods[] = {
315315
{
316316
EVP_PKEY_RSA,
317317
rsa_pub_print,
@@ -340,7 +340,7 @@ static EVP_PKEY_PRINT_METHOD kPrintMethods[] = {
340340

341341
static size_t kPrintMethodsLen = OPENSSL_ARRAY_SIZE(kPrintMethods);
342342

343-
static EVP_PKEY_PRINT_METHOD *find_method(int type) {
343+
static const EVP_PKEY_PRINT_METHOD *find_method(int type) {
344344
for (size_t i = 0; i < kPrintMethodsLen; i++) {
345345
if (kPrintMethods[i].type == type) {
346346
return &kPrintMethods[i];
@@ -358,7 +358,7 @@ static int print_unsupported(BIO *out, const EVP_PKEY *pkey, int indent,
358358

359359
int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, int indent,
360360
ASN1_PCTX *pctx) {
361-
EVP_PKEY_PRINT_METHOD *method = find_method(EVP_PKEY_id(pkey));
361+
const EVP_PKEY_PRINT_METHOD *method = find_method(EVP_PKEY_id(pkey));
362362
if (method != NULL && method->pub_print != NULL) {
363363
return method->pub_print(out, pkey, indent);
364364
}
@@ -367,7 +367,7 @@ int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, int indent,
367367

368368
int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, int indent,
369369
ASN1_PCTX *pctx) {
370-
EVP_PKEY_PRINT_METHOD *method = find_method(EVP_PKEY_id(pkey));
370+
const EVP_PKEY_PRINT_METHOD *method = find_method(EVP_PKEY_id(pkey));
371371
if (method != NULL && method->priv_print != NULL) {
372372
return method->priv_print(out, pkey, indent);
373373
}
@@ -376,7 +376,7 @@ int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, int indent,
376376

377377
int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, int indent,
378378
ASN1_PCTX *pctx) {
379-
EVP_PKEY_PRINT_METHOD *method = find_method(EVP_PKEY_id(pkey));
379+
const EVP_PKEY_PRINT_METHOD *method = find_method(EVP_PKEY_id(pkey));
380380
if (method != NULL && method->param_print != NULL) {
381381
return method->param_print(out, pkey, indent);
382382
}

crypto/rsa_extra/rsa_asn1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ int RSA_public_key_to_bytes(uint8_t **out_bytes, size_t *out_len,
9999
}
100100

101101
// kVersionTwoPrime is the value of the version field for a two-prime
102-
// RSAPrivateKey structure (RFC 3447).
102+
// RSAPrivateKey structure (RFC 8017).
103103
static const uint64_t kVersionTwoPrime = 0;
104104

105105
// Distinguisher for stripped JCA RSA private keys, sets zeroed values to NULL

ssl/handshake_server.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ static enum ssl_hs_wait_t do_read_client_key_exchange(SSL_HANDSHAKE *hs) {
13891389
return ssl_hs_error;
13901390
}
13911391

1392-
// Check the padding. See RFC 3447, section 7.2.2.
1392+
// Check the padding. See RFC 8017, section 7.2.2.
13931393
size_t padding_len = decrypt_len - premaster_secret.size();
13941394
uint8_t good = constant_time_eq_int_8(decrypt_buf[0], 0) &
13951395
constant_time_eq_int_8(decrypt_buf[1], 2);

0 commit comments

Comments
 (0)