diff options
author | jsing <> | 2014-06-13 10:52:24 +0000 |
---|---|---|
committer | jsing <> | 2014-06-13 10:52:24 +0000 |
commit | 87e30739835137951cf48dfa7f692aae2f40dc40 (patch) | |
tree | c478059909f99617992b0630fe527244e4f5873d /src | |
parent | 9ef9f06708ef4fe615f3485f5d82f3fb919fdf03 (diff) | |
download | openbsd-87e30739835137951cf48dfa7f692aae2f40dc40.tar.gz openbsd-87e30739835137951cf48dfa7f692aae2f40dc40.tar.bz2 openbsd-87e30739835137951cf48dfa7f692aae2f40dc40.zip |
Add an SSL_AEAD_CTX to enable the use of EVP_AEAD with an SSL cipher.
Read and write contexts are also added to the SSL_CTX, along with
supporting code.
Based on Adam Langley's chromium diffs.
Rides the recent SSL library bump.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libssl/s3_pkt.c | 5 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/s3_pkt.c | 5 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/ssl.h | 12 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/ssl_lib.c | 13 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/ssl_locl.h | 23 | ||||
-rw-r--r-- | src/lib/libssl/ssl.h | 12 | ||||
-rw-r--r-- | src/lib/libssl/ssl_lib.c | 13 | ||||
-rw-r--r-- | src/lib/libssl/ssl_locl.h | 23 |
8 files changed, 98 insertions, 8 deletions
diff --git a/src/lib/libssl/s3_pkt.c b/src/lib/libssl/s3_pkt.c index 8235e0775a..f5d8bedbea 100644 --- a/src/lib/libssl/s3_pkt.c +++ b/src/lib/libssl/s3_pkt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_pkt.c,v 1.46 2014/06/12 15:49:31 deraadt Exp $ */ | 1 | /* $OpenBSD: s3_pkt.c,v 1.47 2014/06/13 10:52:24 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -753,6 +753,9 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, | |||
753 | eivlen = EVP_GCM_TLS_EXPLICIT_IV_LEN; | 753 | eivlen = EVP_GCM_TLS_EXPLICIT_IV_LEN; |
754 | else | 754 | else |
755 | eivlen = 0; | 755 | eivlen = 0; |
756 | } else if (s->aead_write_ctx != NULL && | ||
757 | s->aead_write_ctx->variable_nonce_in_record) { | ||
758 | eivlen = s->aead_write_ctx->variable_nonce_len; | ||
756 | } else | 759 | } else |
757 | eivlen = 0; | 760 | eivlen = 0; |
758 | 761 | ||
diff --git a/src/lib/libssl/src/ssl/s3_pkt.c b/src/lib/libssl/src/ssl/s3_pkt.c index 8235e0775a..f5d8bedbea 100644 --- a/src/lib/libssl/src/ssl/s3_pkt.c +++ b/src/lib/libssl/src/ssl/s3_pkt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_pkt.c,v 1.46 2014/06/12 15:49:31 deraadt Exp $ */ | 1 | /* $OpenBSD: s3_pkt.c,v 1.47 2014/06/13 10:52:24 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -753,6 +753,9 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, | |||
753 | eivlen = EVP_GCM_TLS_EXPLICIT_IV_LEN; | 753 | eivlen = EVP_GCM_TLS_EXPLICIT_IV_LEN; |
754 | else | 754 | else |
755 | eivlen = 0; | 755 | eivlen = 0; |
756 | } else if (s->aead_write_ctx != NULL && | ||
757 | s->aead_write_ctx->variable_nonce_in_record) { | ||
758 | eivlen = s->aead_write_ctx->variable_nonce_len; | ||
756 | } else | 759 | } else |
757 | eivlen = 0; | 760 | eivlen = 0; |
758 | 761 | ||
diff --git a/src/lib/libssl/src/ssl/ssl.h b/src/lib/libssl/src/ssl/ssl.h index cd71f7bcfe..826d7c1696 100644 --- a/src/lib/libssl/src/ssl/ssl.h +++ b/src/lib/libssl/src/ssl/ssl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl.h,v 1.53 2014/06/13 04:29:13 miod Exp $ */ | 1 | /* $OpenBSD: ssl.h,v 1.54 2014/06/13 10:52:24 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -654,6 +654,8 @@ void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, | |||
654 | #define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) | 654 | #define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) |
655 | #define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) | 655 | #define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) |
656 | 656 | ||
657 | struct ssl_aead_ctx_st; | ||
658 | typedef struct ssl_aead_ctx_st SSL_AEAD_CTX; | ||
657 | 659 | ||
658 | #define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */ | 660 | #define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */ |
659 | 661 | ||
@@ -1093,6 +1095,10 @@ struct ssl_st { | |||
1093 | * the ones to be 'copied' into these ones */ | 1095 | * the ones to be 'copied' into these ones */ |
1094 | int mac_flags; | 1096 | int mac_flags; |
1095 | 1097 | ||
1098 | SSL_AEAD_CTX *aead_read_ctx; /* AEAD context. If non-NULL, then | ||
1099 | enc_read_ctx and read_hash are | ||
1100 | ignored. */ | ||
1101 | |||
1096 | EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ | 1102 | EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ |
1097 | EVP_MD_CTX *read_hash; /* used for mac generation */ | 1103 | EVP_MD_CTX *read_hash; /* used for mac generation */ |
1098 | #ifndef OPENSSL_NO_COMP | 1104 | #ifndef OPENSSL_NO_COMP |
@@ -1101,6 +1107,10 @@ struct ssl_st { | |||
1101 | char *expand; | 1107 | char *expand; |
1102 | #endif | 1108 | #endif |
1103 | 1109 | ||
1110 | SSL_AEAD_CTX *aead_write_ctx; /* AEAD context. If non-NULL, then | ||
1111 | enc_write_ctx and write_hash are | ||
1112 | ignored. */ | ||
1113 | |||
1104 | EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ | 1114 | EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ |
1105 | EVP_MD_CTX *write_hash; /* used for mac generation */ | 1115 | EVP_MD_CTX *write_hash; /* used for mac generation */ |
1106 | #ifndef OPENSSL_NO_COMP | 1116 | #ifndef OPENSSL_NO_COMP |
diff --git a/src/lib/libssl/src/ssl/ssl_lib.c b/src/lib/libssl/src/ssl/ssl_lib.c index 05abdb3944..297c80124d 100644 --- a/src/lib/libssl/src/ssl/ssl_lib.c +++ b/src/lib/libssl/src/ssl/ssl_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_lib.c,v 1.66 2014/06/13 04:29:13 miod Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.67 2014/06/13 10:52:24 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -2660,6 +2660,17 @@ ssl_clear_cipher_ctx(SSL *s) | |||
2660 | EVP_CIPHER_CTX_free(s->enc_write_ctx); | 2660 | EVP_CIPHER_CTX_free(s->enc_write_ctx); |
2661 | s->enc_write_ctx = NULL; | 2661 | s->enc_write_ctx = NULL; |
2662 | 2662 | ||
2663 | if (s->aead_read_ctx != NULL) { | ||
2664 | EVP_AEAD_CTX_cleanup(&s->aead_read_ctx->ctx); | ||
2665 | free(s->aead_read_ctx); | ||
2666 | s->aead_read_ctx = NULL; | ||
2667 | } | ||
2668 | if (s->aead_write_ctx != NULL) { | ||
2669 | EVP_AEAD_CTX_cleanup(&s->aead_write_ctx->ctx); | ||
2670 | free(s->aead_write_ctx); | ||
2671 | s->aead_write_ctx = NULL; | ||
2672 | } | ||
2673 | |||
2663 | #ifndef OPENSSL_NO_COMP | 2674 | #ifndef OPENSSL_NO_COMP |
2664 | COMP_CTX_free(s->expand); | 2675 | COMP_CTX_free(s->expand); |
2665 | s->expand = NULL; | 2676 | s->expand = NULL; |
diff --git a/src/lib/libssl/src/ssl/ssl_locl.h b/src/lib/libssl/src/ssl/ssl_locl.h index 18b329048e..ea5f8c3d4e 100644 --- a/src/lib/libssl/src/ssl/ssl_locl.h +++ b/src/lib/libssl/src/ssl/ssl_locl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_locl.h,v 1.49 2014/06/12 15:49:31 deraadt Exp $ */ | 1 | /* $OpenBSD: ssl_locl.h,v 1.50 2014/06/13 10:52:24 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -578,6 +578,27 @@ typedef struct ssl3_enc_method { | |||
578 | /* Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2. */ | 578 | /* Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2. */ |
579 | #define SSL_ENC_FLAG_TLS1_2_CIPHERS (1 << 4) | 579 | #define SSL_ENC_FLAG_TLS1_2_CIPHERS (1 << 4) |
580 | 580 | ||
581 | /* | ||
582 | * ssl_aead_ctx_st contains information about an AEAD that is being used to | ||
583 | * encrypt an SSL connection. | ||
584 | */ | ||
585 | struct ssl_aead_ctx_st { | ||
586 | EVP_AEAD_CTX ctx; | ||
587 | /* | ||
588 | * fixed_nonce contains any bytes of the nonce that are fixed for all | ||
589 | * records. | ||
590 | */ | ||
591 | unsigned char fixed_nonce[8]; | ||
592 | unsigned char fixed_nonce_len; | ||
593 | unsigned char variable_nonce_len; | ||
594 | unsigned char tag_len; | ||
595 | /* | ||
596 | * variable_nonce_in_record is non-zero if the variable nonce | ||
597 | * for a record is included as a prefix before the ciphertext. | ||
598 | */ | ||
599 | char variable_nonce_in_record; | ||
600 | }; | ||
601 | |||
581 | #ifndef OPENSSL_NO_COMP | 602 | #ifndef OPENSSL_NO_COMP |
582 | /* Used for holding the relevant compression methods loaded into SSL_CTX */ | 603 | /* Used for holding the relevant compression methods loaded into SSL_CTX */ |
583 | typedef struct ssl3_comp_st { | 604 | typedef struct ssl3_comp_st { |
diff --git a/src/lib/libssl/ssl.h b/src/lib/libssl/ssl.h index cd71f7bcfe..826d7c1696 100644 --- a/src/lib/libssl/ssl.h +++ b/src/lib/libssl/ssl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl.h,v 1.53 2014/06/13 04:29:13 miod Exp $ */ | 1 | /* $OpenBSD: ssl.h,v 1.54 2014/06/13 10:52:24 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -654,6 +654,8 @@ void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, | |||
654 | #define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) | 654 | #define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) |
655 | #define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) | 655 | #define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) |
656 | 656 | ||
657 | struct ssl_aead_ctx_st; | ||
658 | typedef struct ssl_aead_ctx_st SSL_AEAD_CTX; | ||
657 | 659 | ||
658 | #define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */ | 660 | #define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */ |
659 | 661 | ||
@@ -1093,6 +1095,10 @@ struct ssl_st { | |||
1093 | * the ones to be 'copied' into these ones */ | 1095 | * the ones to be 'copied' into these ones */ |
1094 | int mac_flags; | 1096 | int mac_flags; |
1095 | 1097 | ||
1098 | SSL_AEAD_CTX *aead_read_ctx; /* AEAD context. If non-NULL, then | ||
1099 | enc_read_ctx and read_hash are | ||
1100 | ignored. */ | ||
1101 | |||
1096 | EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ | 1102 | EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ |
1097 | EVP_MD_CTX *read_hash; /* used for mac generation */ | 1103 | EVP_MD_CTX *read_hash; /* used for mac generation */ |
1098 | #ifndef OPENSSL_NO_COMP | 1104 | #ifndef OPENSSL_NO_COMP |
@@ -1101,6 +1107,10 @@ struct ssl_st { | |||
1101 | char *expand; | 1107 | char *expand; |
1102 | #endif | 1108 | #endif |
1103 | 1109 | ||
1110 | SSL_AEAD_CTX *aead_write_ctx; /* AEAD context. If non-NULL, then | ||
1111 | enc_write_ctx and write_hash are | ||
1112 | ignored. */ | ||
1113 | |||
1104 | EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ | 1114 | EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ |
1105 | EVP_MD_CTX *write_hash; /* used for mac generation */ | 1115 | EVP_MD_CTX *write_hash; /* used for mac generation */ |
1106 | #ifndef OPENSSL_NO_COMP | 1116 | #ifndef OPENSSL_NO_COMP |
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index 05abdb3944..297c80124d 100644 --- a/src/lib/libssl/ssl_lib.c +++ b/src/lib/libssl/ssl_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_lib.c,v 1.66 2014/06/13 04:29:13 miod Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.67 2014/06/13 10:52:24 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -2660,6 +2660,17 @@ ssl_clear_cipher_ctx(SSL *s) | |||
2660 | EVP_CIPHER_CTX_free(s->enc_write_ctx); | 2660 | EVP_CIPHER_CTX_free(s->enc_write_ctx); |
2661 | s->enc_write_ctx = NULL; | 2661 | s->enc_write_ctx = NULL; |
2662 | 2662 | ||
2663 | if (s->aead_read_ctx != NULL) { | ||
2664 | EVP_AEAD_CTX_cleanup(&s->aead_read_ctx->ctx); | ||
2665 | free(s->aead_read_ctx); | ||
2666 | s->aead_read_ctx = NULL; | ||
2667 | } | ||
2668 | if (s->aead_write_ctx != NULL) { | ||
2669 | EVP_AEAD_CTX_cleanup(&s->aead_write_ctx->ctx); | ||
2670 | free(s->aead_write_ctx); | ||
2671 | s->aead_write_ctx = NULL; | ||
2672 | } | ||
2673 | |||
2663 | #ifndef OPENSSL_NO_COMP | 2674 | #ifndef OPENSSL_NO_COMP |
2664 | COMP_CTX_free(s->expand); | 2675 | COMP_CTX_free(s->expand); |
2665 | s->expand = NULL; | 2676 | s->expand = NULL; |
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h index 18b329048e..ea5f8c3d4e 100644 --- a/src/lib/libssl/ssl_locl.h +++ b/src/lib/libssl/ssl_locl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_locl.h,v 1.49 2014/06/12 15:49:31 deraadt Exp $ */ | 1 | /* $OpenBSD: ssl_locl.h,v 1.50 2014/06/13 10:52:24 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -578,6 +578,27 @@ typedef struct ssl3_enc_method { | |||
578 | /* Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2. */ | 578 | /* Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2. */ |
579 | #define SSL_ENC_FLAG_TLS1_2_CIPHERS (1 << 4) | 579 | #define SSL_ENC_FLAG_TLS1_2_CIPHERS (1 << 4) |
580 | 580 | ||
581 | /* | ||
582 | * ssl_aead_ctx_st contains information about an AEAD that is being used to | ||
583 | * encrypt an SSL connection. | ||
584 | */ | ||
585 | struct ssl_aead_ctx_st { | ||
586 | EVP_AEAD_CTX ctx; | ||
587 | /* | ||
588 | * fixed_nonce contains any bytes of the nonce that are fixed for all | ||
589 | * records. | ||
590 | */ | ||
591 | unsigned char fixed_nonce[8]; | ||
592 | unsigned char fixed_nonce_len; | ||
593 | unsigned char variable_nonce_len; | ||
594 | unsigned char tag_len; | ||
595 | /* | ||
596 | * variable_nonce_in_record is non-zero if the variable nonce | ||
597 | * for a record is included as a prefix before the ciphertext. | ||
598 | */ | ||
599 | char variable_nonce_in_record; | ||
600 | }; | ||
601 | |||
581 | #ifndef OPENSSL_NO_COMP | 602 | #ifndef OPENSSL_NO_COMP |
582 | /* Used for holding the relevant compression methods loaded into SSL_CTX */ | 603 | /* Used for holding the relevant compression methods loaded into SSL_CTX */ |
583 | typedef struct ssl3_comp_st { | 604 | typedef struct ssl3_comp_st { |