From 5055c7670907a84b8769c3ab2558260748e8893e Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Tue, 4 Aug 2015 09:24:14 -0400 Subject: [PATCH] Rename algorithm2 to algorithm_prf. It's purely the PRF function now, although it's still different from the rest due to the _DEFAULT field being weird. Change-Id: Iaea7a99cccdc8be4cd60f6c1503df5be2a63c4c5 Reviewed-on: https://boringssl-review.googlesource.com/5614 Reviewed-by: Adam Langley --- include/openssl/ssl.h | 4 +--- ssl/internal.h | 5 ++--- ssl/s3_enc.c | 4 ++-- ssl/s3_lib.c | 4 ++-- ssl/ssl_cipher.c | 6 +++--- ssl/t1_enc.c | 6 +++--- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index 41745942..04304cb1 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -196,9 +196,7 @@ typedef struct ssl_cipher_st { uint32_t algorithm_mac; uint32_t algorithm_ssl; uint32_t algo_strength; - - /* algorithm2 contains extra flags. See ssl/internal.h. */ - uint32_t algorithm2; + uint32_t algorithm_prf; /* strength_bits is the strength of the cipher in bits. */ int strength_bits; diff --git a/ssl/internal.h b/ssl/internal.h index 58735705..7f2dd520 100644 --- a/ssl/internal.h +++ b/ssl/internal.h @@ -202,8 +202,7 @@ #define SSL_TLSV1 SSL_SSLV3 #define SSL_TLSV1_2 0x00000004L -/* Bits for |algorithm2| (handshake digests and other extra flags). */ - +/* Bits for |algorithm_prf| (handshake digest). */ #define SSL_HANDSHAKE_MAC_MD5 0x10 #define SSL_HANDSHAKE_MAC_SHA 0x20 #define SSL_HANDSHAKE_MAC_SHA256 0x40 @@ -1181,7 +1180,7 @@ int ssl3_is_version_enabled(SSL *s, uint16_t version); * the wire version except at API boundaries. */ uint16_t ssl3_version_from_wire(SSL *s, uint16_t wire_version); -uint32_t ssl_get_algorithm2(SSL *s); +uint32_t ssl_get_algorithm_prf(SSL *s); int tls1_process_sigalgs(SSL *s, const CBS *sigalgs); /* tls1_choose_signing_digest returns a digest for use with |ssl|'s private key diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c index f2b6e9d7..97555cd3 100644 --- a/ssl/s3_enc.c +++ b/ssl/s3_enc.c @@ -298,9 +298,9 @@ int ssl3_digest_cached_records( return 0; } - /* Loop through bits of algorithm2 field and create MD_CTX-es */ + /* Loop through bits of algorithm_prf field and create MD_CTX-es */ for (i = 0; ssl_get_handshake_digest(&mask, &md, i); i++) { - if ((mask & ssl_get_algorithm2(s)) && md) { + if ((mask & ssl_get_algorithm_prf(s)) && md) { s->s3->handshake_dgst[i] = EVP_MD_CTX_create(); if (s->s3->handshake_dgst[i] == NULL) { OPENSSL_PUT_ERROR(SSL, ERR_LIB_EVP); diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index ce5aed65..2566a4d3 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -659,9 +659,9 @@ static int ssl3_set_req_cert_type(CERT *c, const uint8_t *p, size_t len) { /* If we are using default SHA1+MD5 algorithms switch to new SHA256 PRF and * handshake macs if required. */ -uint32_t ssl_get_algorithm2(SSL *s) { +uint32_t ssl_get_algorithm_prf(SSL *s) { static const uint32_t kMask = SSL_HANDSHAKE_MAC_DEFAULT; - uint32_t alg2 = s->s3->tmp.new_cipher->algorithm2; + uint32_t alg2 = s->s3->tmp.new_cipher->algorithm_prf; if (s->enc_method->enc_flags & SSL_ENC_FLAG_SHA256_PRF && (alg2 & kMask) == kMask) { return SSL_HANDSHAKE_MAC_SHA256; diff --git a/ssl/ssl_cipher.c b/ssl/ssl_cipher.c index cbdf7ca0..29824aa7 100644 --- a/ssl/ssl_cipher.c +++ b/ssl/ssl_cipher.c @@ -1456,7 +1456,7 @@ static const char *ssl_cipher_get_enc_name(const SSL_CIPHER *cipher) { } static const char *ssl_cipher_get_prf_name(const SSL_CIPHER *cipher) { - if ((cipher->algorithm2 & SSL_HANDSHAKE_MAC_DEFAULT) == + if ((cipher->algorithm_prf & SSL_HANDSHAKE_MAC_DEFAULT) == SSL_HANDSHAKE_MAC_DEFAULT) { /* Before TLS 1.2, the PRF component is the hash used in the HMAC, which is * only ever MD5 or SHA-1. */ @@ -1469,9 +1469,9 @@ static const char *ssl_cipher_get_prf_name(const SSL_CIPHER *cipher) { assert(0); return "UNKNOWN"; } - } else if (cipher->algorithm2 & SSL_HANDSHAKE_MAC_SHA256) { + } else if (cipher->algorithm_prf & SSL_HANDSHAKE_MAC_SHA256) { return "SHA256"; - } else if (cipher->algorithm2 & SSL_HANDSHAKE_MAC_SHA384) { + } else if (cipher->algorithm_prf & SSL_HANDSHAKE_MAC_SHA384) { return "SHA384"; } else { assert(0); diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c index 93eb717e..0aa4d1aa 100644 --- a/ssl/t1_enc.c +++ b/ssl/t1_enc.c @@ -245,7 +245,7 @@ int tls1_prf(SSL *s, uint8_t *out, size_t out_len, const uint8_t *secret, /* Count number of digests and partition |secret| evenly. */ count = 0; for (idx = 0; ssl_get_handshake_digest(&m, &md, idx); idx++) { - if (m & ssl_get_algorithm2(s)) { + if (m & ssl_get_algorithm_prf(s)) { count++; } } @@ -260,7 +260,7 @@ int tls1_prf(SSL *s, uint8_t *out, size_t out_len, const uint8_t *secret, S1 = secret; memset(out, 0, out_len); for (idx = 0; ssl_get_handshake_digest(&m, &md, idx); idx++) { - if (m & ssl_get_algorithm2(s)) { + if (m & ssl_get_algorithm_prf(s)) { /* If |count| is 2 and |secret_len| is odd, |secret| is partitioned into * two halves with an overlapping byte. */ if (!tls1_P_hash(tmp, out_len, md, S1, len + (secret_len & 1), @@ -521,7 +521,7 @@ int tls1_handshake_digest(SSL *s, uint8_t *out, size_t out_len) { unsigned int digest_len; EVP_MD_CTX *hdgst = s->s3->handshake_dgst[i]; - if ((mask & ssl_get_algorithm2(s)) == 0) { + if ((mask & ssl_get_algorithm_prf(s)) == 0) { continue; }