summaryrefslogtreecommitdiffstats
path: root/ssl/ssl_ciph.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssl/ssl_ciph.c')
-rw-r--r--ssl/ssl_ciph.c61
1 files changed, 36 insertions, 25 deletions
diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c
index a9cf6416b1..e70b800a5c 100644
--- a/ssl/ssl_ciph.c
+++ b/ssl/ssl_ciph.c
@@ -482,7 +482,8 @@ static int load_builtin_compressions(void)
int ssl_cipher_get_evp_cipher(SSL_CTX *ctx, const SSL_CIPHER *sslc,
const EVP_CIPHER **enc)
{
- int i = ssl_cipher_info_lookup(ssl_cipher_table_cipher, sslc->algorithm_enc);
+ int i = ssl_cipher_info_lookup(ssl_cipher_table_cipher,
+ sslc->algorithm_enc);
if (i == -1) {
*enc = NULL;
@@ -508,6 +509,33 @@ int ssl_cipher_get_evp_cipher(SSL_CTX *ctx, const SSL_CIPHER *sslc,
return 1;
}
+int ssl_cipher_get_evp_md_mac(SSL_CTX *ctx, const SSL_CIPHER *sslc,
+ const EVP_MD **md,
+ int *mac_pkey_type, size_t *mac_secret_size)
+{
+ int i = ssl_cipher_info_lookup(ssl_cipher_table_mac, sslc->algorithm_mac);
+
+ if (i == -1) {
+ *md = NULL;
+ if (mac_pkey_type != NULL)
+ *mac_pkey_type = NID_undef;
+ if (mac_secret_size != NULL)
+ *mac_secret_size = 0;
+ } else {
+ const EVP_MD *digest = ctx->ssl_digest_methods[i];
+
+ if (digest == NULL || !ssl_evp_md_up_ref(digest))
+ return 0;
+
+ *md = digest;
+ if (mac_pkey_type != NULL)
+ *mac_pkey_type = ctx->ssl_mac_pkey_id[i];
+ if (mac_secret_size != NULL)
+ *mac_secret_size = ctx->ssl_mac_secret_size[i];
+ }
+ return 1;
+}
+
int ssl_cipher_get_evp(SSL_CTX *ctx, const SSL_SESSION *s,
const EVP_CIPHER **enc, const EVP_MD **md,
int *mac_pkey_type, size_t *mac_secret_size,
@@ -547,34 +575,17 @@ int ssl_cipher_get_evp(SSL_CTX *ctx, const SSL_SESSION *s,
if (!ssl_cipher_get_evp_cipher(ctx, c, enc))
return 0;
- i = ssl_cipher_info_lookup(ssl_cipher_table_mac, c->algorithm_mac);
- if (i == -1) {
- *md = NULL;
- if (mac_pkey_type != NULL)
- *mac_pkey_type = NID_undef;
- if (mac_secret_size != NULL)
- *mac_secret_size = 0;
- if (c->algorithm_mac == SSL_AEAD)
- mac_pkey_type = NULL;
- } else {
- const EVP_MD *digest = ctx->ssl_digest_methods[i];
-
- if (digest == NULL
- || !ssl_evp_md_up_ref(digest)) {
- ssl_evp_cipher_free(*enc);
- return 0;
- }
- *md = digest;
- if (mac_pkey_type != NULL)
- *mac_pkey_type = ctx->ssl_mac_pkey_id[i];
- if (mac_secret_size != NULL)
- *mac_secret_size = ctx->ssl_mac_secret_size[i];
+ if (!ssl_cipher_get_evp_md_mac(ctx, c, md, mac_pkey_type,
+ mac_secret_size)) {
+ ssl_evp_cipher_free(*enc);
+ return 0;
}
if ((*enc != NULL)
- && (*md != NULL
+ && (*md != NULL
|| (EVP_CIPHER_get_flags(*enc) & EVP_CIPH_FLAG_AEAD_CIPHER))
- && (!mac_pkey_type || *mac_pkey_type != NID_undef)) {
+ && (c->algorithm_mac == SSL_AEAD
+ || mac_pkey_type == NULL || *mac_pkey_type != NID_undef)) {
const EVP_CIPHER *evp = NULL;
if (use_etm