Add SSL_CIPHER_get_protocol_id.
This was introduced in OpenSSL 1.1.1, and wpa_supplicant expects us to
have it. We had this same function as SSL_CIPHER_get_value (to match
SSL_get_cipher_by_value). Align with upstream's name.
It seems we also had a ssl_cipher_get_value lying around, so fold them
together. (I've retained the assert in ssl_cipher_get_value as it seems
reasonable enough; casting a hypothetical SSLv2 cipher ID to uint16_t
would not behave correctly.)
Change-Id: Ifbec460435bbc483f2c3de988522e321f2708172
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42966
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/ssl_cipher.cc b/ssl/ssl_cipher.cc
index c421292..4f5049c 100644
--- a/ssl/ssl_cipher.cc
+++ b/ssl/ssl_cipher.cc
@@ -1279,14 +1279,6 @@
return true;
}
-uint16_t ssl_cipher_get_value(const SSL_CIPHER *cipher) {
- uint32_t id = cipher->id;
- // All OpenSSL cipher IDs are prefaced with 0x03. Historically this referred
- // to SSLv2 vs SSLv3.
- assert((id & 0xff000000) == 0x03000000);
- return id & 0xffff;
-}
-
uint32_t ssl_cipher_auth_mask_for_key(const EVP_PKEY *key) {
switch (EVP_PKEY_id(key)) {
case EVP_PKEY_RSA:
@@ -1376,10 +1368,17 @@
uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *cipher) { return cipher->id; }
-uint16_t SSL_CIPHER_get_value(const SSL_CIPHER *cipher) {
+uint16_t SSL_CIPHER_get_protocol_id(const SSL_CIPHER *cipher) {
+ // All OpenSSL cipher IDs are prefaced with 0x03. Historically this referred
+ // to SSLv2 vs SSLv3.
+ assert((cipher->id & 0xff000000) == 0x03000000);
return static_cast<uint16_t>(cipher->id);
}
+uint16_t SSL_CIPHER_get_value(const SSL_CIPHER *cipher) {
+ return SSL_CIPHER_get_protocol_id(cipher);
+}
+
int SSL_CIPHER_is_aead(const SSL_CIPHER *cipher) {
return (cipher->algorithm_mac & SSL_AEAD) != 0;
}