blob: 4b87983aa957130db864c225833936fcc9c81306 [file] [log] [blame]
David Benjaminea72bd02014-12-21 21:27:41 -05001/* Copyright (c) 2014, Google Inc.
2 *
3 * Permission to use, copy, modify, and/or distribute this software for any
4 * purpose with or without fee is hereby granted, provided that the above
5 * copyright notice and this permission notice appear in all copies.
6 *
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14
15#include <assert.h>
16#include <limits.h>
17#include <string.h>
18
19#include <openssl/aead.h>
20#include <openssl/cipher.h>
21#include <openssl/err.h>
22#include <openssl/hmac.h>
David Benjamin9f897b22015-12-07 19:34:31 -050023#include <openssl/md5.h>
David Benjaminea72bd02014-12-21 21:27:41 -050024#include <openssl/mem.h>
25#include <openssl/sha.h>
David Benjaminb34f5102015-02-28 03:59:33 -050026#include <openssl/type_check.h>
David Benjaminea72bd02014-12-21 21:27:41 -050027
Martin Kreichgauer18d9f282017-06-06 12:29:48 -070028#include "../fipsmodule/cipher/internal.h"
Steven Valdezcb966542016-08-17 16:56:14 -040029#include "../internal.h"
David Benjaminea72bd02014-12-21 21:27:41 -050030#include "internal.h"
31
32
33typedef struct {
34 EVP_CIPHER_CTX cipher_ctx;
35 HMAC_CTX hmac_ctx;
David Benjamin808f8322017-08-18 14:06:02 -040036 // mac_key is the portion of the key used for the MAC. It is retained
37 // separately for the constant-time CBC code.
David Benjaminea72bd02014-12-21 21:27:41 -050038 uint8_t mac_key[EVP_MAX_MD_SIZE];
39 uint8_t mac_key_len;
David Benjamin808f8322017-08-18 14:06:02 -040040 // implicit_iv is one iff this is a pre-TLS-1.1 CBC cipher without an explicit
41 // IV.
David Benjaminea72bd02014-12-21 21:27:41 -050042 char implicit_iv;
David Benjaminea72bd02014-12-21 21:27:41 -050043} AEAD_TLS_CTX;
44
David Benjaminb34f5102015-02-28 03:59:33 -050045OPENSSL_COMPILE_ASSERT(EVP_MAX_MD_SIZE < 256, mac_key_len_fits_in_uint8_t);
David Benjaminea72bd02014-12-21 21:27:41 -050046
47static void aead_tls_cleanup(EVP_AEAD_CTX *ctx) {
48 AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)ctx->aead_state;
49 EVP_CIPHER_CTX_cleanup(&tls_ctx->cipher_ctx);
50 HMAC_CTX_cleanup(&tls_ctx->hmac_ctx);
51 OPENSSL_cleanse(&tls_ctx->mac_key, sizeof(tls_ctx->mac_key));
David Benjaminea72bd02014-12-21 21:27:41 -050052 OPENSSL_free(tls_ctx);
53 ctx->aead_state = NULL;
54}
55
56static int aead_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len,
David Benjaminb34f5102015-02-28 03:59:33 -050057 size_t tag_len, enum evp_aead_direction_t dir,
David Benjamind03b5ed2015-03-07 00:10:27 -080058 const EVP_CIPHER *cipher, const EVP_MD *md,
59 char implicit_iv) {
David Benjaminea72bd02014-12-21 21:27:41 -050060 if (tag_len != EVP_AEAD_DEFAULT_TAG_LENGTH &&
61 tag_len != EVP_MD_size(md)) {
David Benjamin3570d732015-06-29 00:28:17 -040062 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_UNSUPPORTED_TAG_SIZE);
David Benjaminea72bd02014-12-21 21:27:41 -050063 return 0;
64 }
65
66 if (key_len != EVP_AEAD_key_length(ctx->aead)) {
David Benjamin3570d732015-06-29 00:28:17 -040067 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_KEY_LENGTH);
David Benjaminea72bd02014-12-21 21:27:41 -050068 return 0;
69 }
70
71 size_t mac_key_len = EVP_MD_size(md);
72 size_t enc_key_len = EVP_CIPHER_key_length(cipher);
David Benjaminb34f5102015-02-28 03:59:33 -050073 assert(mac_key_len + enc_key_len +
74 (implicit_iv ? EVP_CIPHER_iv_length(cipher) : 0) == key_len);
David Benjaminea72bd02014-12-21 21:27:41 -050075
76 AEAD_TLS_CTX *tls_ctx = OPENSSL_malloc(sizeof(AEAD_TLS_CTX));
77 if (tls_ctx == NULL) {
David Benjamin3570d732015-06-29 00:28:17 -040078 OPENSSL_PUT_ERROR(CIPHER, ERR_R_MALLOC_FAILURE);
David Benjaminea72bd02014-12-21 21:27:41 -050079 return 0;
80 }
81 EVP_CIPHER_CTX_init(&tls_ctx->cipher_ctx);
82 HMAC_CTX_init(&tls_ctx->hmac_ctx);
David Benjaminb34f5102015-02-28 03:59:33 -050083 assert(mac_key_len <= EVP_MAX_MD_SIZE);
David Benjamin17cf2cb2016-12-13 01:07:13 -050084 OPENSSL_memcpy(tls_ctx->mac_key, key, mac_key_len);
David Benjaminea72bd02014-12-21 21:27:41 -050085 tls_ctx->mac_key_len = (uint8_t)mac_key_len;
David Benjaminea72bd02014-12-21 21:27:41 -050086 tls_ctx->implicit_iv = implicit_iv;
David Benjaminea72bd02014-12-21 21:27:41 -050087
88 ctx->aead_state = tls_ctx;
David Benjaminb34f5102015-02-28 03:59:33 -050089 if (!EVP_CipherInit_ex(&tls_ctx->cipher_ctx, cipher, NULL, &key[mac_key_len],
90 implicit_iv ? &key[mac_key_len + enc_key_len] : NULL,
91 dir == evp_aead_seal) ||
David Benjaminea72bd02014-12-21 21:27:41 -050092 !HMAC_Init_ex(&tls_ctx->hmac_ctx, key, mac_key_len, md, NULL)) {
93 aead_tls_cleanup(ctx);
Adam Langley5aa8a862015-05-11 14:28:12 -070094 ctx->aead_state = NULL;
David Benjaminea72bd02014-12-21 21:27:41 -050095 return 0;
96 }
97 EVP_CIPHER_CTX_set_padding(&tls_ctx->cipher_ctx, 0);
98
99 return 1;
100}
101
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700102static size_t aead_tls_tag_len(const EVP_AEAD_CTX *ctx, const size_t in_len,
103 const size_t extra_in_len) {
104 assert(extra_in_len == 0);
105 AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)ctx->aead_state;
106
107 const size_t hmac_len = HMAC_size(&tls_ctx->hmac_ctx);
108 if (EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) != EVP_CIPH_CBC_MODE) {
109 // The NULL cipher.
110 return hmac_len;
111 }
112
113 const size_t block_size = EVP_CIPHER_CTX_block_size(&tls_ctx->cipher_ctx);
David Benjamin808f8322017-08-18 14:06:02 -0400114 // An overflow of |in_len + hmac_len| doesn't affect the result mod
115 // |block_size|, provided that |block_size| is a smaller power of two.
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700116 assert(block_size != 0 && (block_size & (block_size - 1)) == 0);
117 const size_t pad_len = block_size - (in_len + hmac_len) % block_size;
118 return hmac_len + pad_len;
119}
120
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700121static int aead_tls_seal_scatter(const EVP_AEAD_CTX *ctx, uint8_t *out,
122 uint8_t *out_tag, size_t *out_tag_len,
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700123 const size_t max_out_tag_len,
124 const uint8_t *nonce, const size_t nonce_len,
125 const uint8_t *in, const size_t in_len,
126 const uint8_t *extra_in,
127 const size_t extra_in_len, const uint8_t *ad,
128 const size_t ad_len) {
David Benjaminea72bd02014-12-21 21:27:41 -0500129 AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)ctx->aead_state;
David Benjaminea72bd02014-12-21 21:27:41 -0500130
David Benjaminb34f5102015-02-28 03:59:33 -0500131 if (!tls_ctx->cipher_ctx.encrypt) {
David Benjamin808f8322017-08-18 14:06:02 -0400132 // Unlike a normal AEAD, a TLS AEAD may only be used in one direction.
David Benjamin3570d732015-06-29 00:28:17 -0400133 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_OPERATION);
David Benjaminb34f5102015-02-28 03:59:33 -0500134 return 0;
David Benjaminb34f5102015-02-28 03:59:33 -0500135 }
136
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700137 if (in_len > INT_MAX) {
David Benjamin808f8322017-08-18 14:06:02 -0400138 // EVP_CIPHER takes int as input.
David Benjamin3570d732015-06-29 00:28:17 -0400139 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
David Benjaminea72bd02014-12-21 21:27:41 -0500140 return 0;
141 }
142
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700143 if (max_out_tag_len < aead_tls_tag_len(ctx, in_len, extra_in_len)) {
David Benjamin3570d732015-06-29 00:28:17 -0400144 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL);
David Benjaminea72bd02014-12-21 21:27:41 -0500145 return 0;
146 }
147
148 if (nonce_len != EVP_AEAD_nonce_length(ctx->aead)) {
David Benjamin3570d732015-06-29 00:28:17 -0400149 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_NONCE_SIZE);
David Benjaminea72bd02014-12-21 21:27:41 -0500150 return 0;
151 }
152
David Benjamin7f1d5d52015-01-14 17:24:53 -0500153 if (ad_len != 13 - 2 /* length bytes */) {
David Benjamin3570d732015-06-29 00:28:17 -0400154 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_AD_SIZE);
David Benjaminea72bd02014-12-21 21:27:41 -0500155 return 0;
156 }
157
David Benjamin808f8322017-08-18 14:06:02 -0400158 // To allow for CBC mode which changes cipher length, |ad| doesn't include the
159 // length for legacy ciphers.
David Benjaminea72bd02014-12-21 21:27:41 -0500160 uint8_t ad_extra[2];
161 ad_extra[0] = (uint8_t)(in_len >> 8);
162 ad_extra[1] = (uint8_t)(in_len & 0xff);
163
David Benjamin808f8322017-08-18 14:06:02 -0400164 // Compute the MAC. This must be first in case the operation is being done
165 // in-place.
David Benjaminea72bd02014-12-21 21:27:41 -0500166 uint8_t mac[EVP_MAX_MD_SIZE];
167 unsigned mac_len;
David Benjamin1741a9d2015-12-07 19:52:56 -0500168 if (!HMAC_Init_ex(&tls_ctx->hmac_ctx, NULL, 0, NULL, NULL) ||
169 !HMAC_Update(&tls_ctx->hmac_ctx, ad, ad_len) ||
170 !HMAC_Update(&tls_ctx->hmac_ctx, ad_extra, sizeof(ad_extra)) ||
171 !HMAC_Update(&tls_ctx->hmac_ctx, in, in_len) ||
172 !HMAC_Final(&tls_ctx->hmac_ctx, mac, &mac_len)) {
David Benjaminea72bd02014-12-21 21:27:41 -0500173 return 0;
174 }
David Benjaminea72bd02014-12-21 21:27:41 -0500175
David Benjamin808f8322017-08-18 14:06:02 -0400176 // Configure the explicit IV.
David Benjaminea72bd02014-12-21 21:27:41 -0500177 if (EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) == EVP_CIPH_CBC_MODE &&
178 !tls_ctx->implicit_iv &&
179 !EVP_EncryptInit_ex(&tls_ctx->cipher_ctx, NULL, NULL, NULL, nonce)) {
180 return 0;
181 }
182
David Benjamin808f8322017-08-18 14:06:02 -0400183 // Encrypt the input.
David Benjaminea72bd02014-12-21 21:27:41 -0500184 int len;
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700185 if (!EVP_EncryptUpdate(&tls_ctx->cipher_ctx, out, &len, in, (int)in_len)) {
David Benjaminea72bd02014-12-21 21:27:41 -0500186 return 0;
187 }
David Benjaminea72bd02014-12-21 21:27:41 -0500188
189 unsigned block_size = EVP_CIPHER_CTX_block_size(&tls_ctx->cipher_ctx);
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700190
David Benjamin808f8322017-08-18 14:06:02 -0400191 // Feed the MAC into the cipher in two steps. First complete the final partial
192 // block from encrypting the input and split the result between |out| and
193 // |out_tag|. Then feed the rest.
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700194
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700195 const size_t early_mac_len =
196 (block_size - (in_len % block_size) % block_size);
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700197 if (early_mac_len != 0) {
198 assert(len + block_size - early_mac_len == in_len);
199 uint8_t buf[EVP_MAX_BLOCK_LENGTH];
200 int buf_len;
201 if (!EVP_EncryptUpdate(&tls_ctx->cipher_ctx, buf, &buf_len, mac,
202 (int)early_mac_len)) {
203 return 0;
204 }
205 assert(buf_len == (int)block_size);
206 OPENSSL_memcpy(out + len, buf, block_size - early_mac_len);
207 OPENSSL_memcpy(out_tag, buf + block_size - early_mac_len, early_mac_len);
208 }
209 size_t tag_len = early_mac_len;
210
211 if (!EVP_EncryptUpdate(&tls_ctx->cipher_ctx, out_tag + tag_len, &len,
212 mac + tag_len, mac_len - tag_len)) {
213 return 0;
214 }
215 tag_len += len;
216
David Benjaminea72bd02014-12-21 21:27:41 -0500217 if (block_size > 1) {
218 assert(block_size <= 256);
219 assert(EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) == EVP_CIPH_CBC_MODE);
220
David Benjamin808f8322017-08-18 14:06:02 -0400221 // Compute padding and feed that into the cipher.
David Benjaminea72bd02014-12-21 21:27:41 -0500222 uint8_t padding[256];
223 unsigned padding_len = block_size - ((in_len + mac_len) % block_size);
David Benjamin17cf2cb2016-12-13 01:07:13 -0500224 OPENSSL_memset(padding, padding_len - 1, padding_len);
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700225 if (!EVP_EncryptUpdate(&tls_ctx->cipher_ctx, out_tag + tag_len, &len,
226 padding, (int)padding_len)) {
David Benjaminea72bd02014-12-21 21:27:41 -0500227 return 0;
228 }
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700229 tag_len += len;
David Benjaminea72bd02014-12-21 21:27:41 -0500230 }
231
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700232 if (!EVP_EncryptFinal_ex(&tls_ctx->cipher_ctx, out_tag + tag_len, &len)) {
David Benjaminea72bd02014-12-21 21:27:41 -0500233 return 0;
234 }
David Benjamin808f8322017-08-18 14:06:02 -0400235 assert(len == 0); // Padding is explicit.
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700236 assert(tag_len == aead_tls_tag_len(ctx, in_len, extra_in_len));
David Benjaminea72bd02014-12-21 21:27:41 -0500237
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700238 *out_tag_len = tag_len;
David Benjaminea72bd02014-12-21 21:27:41 -0500239 return 1;
240}
241
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700242static int aead_tls_open(const EVP_AEAD_CTX *ctx, uint8_t *out, size_t *out_len,
243 size_t max_out_len, const uint8_t *nonce,
244 size_t nonce_len, const uint8_t *in, size_t in_len,
David Benjaminea72bd02014-12-21 21:27:41 -0500245 const uint8_t *ad, size_t ad_len) {
246 AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)ctx->aead_state;
247
David Benjaminb34f5102015-02-28 03:59:33 -0500248 if (tls_ctx->cipher_ctx.encrypt) {
David Benjamin808f8322017-08-18 14:06:02 -0400249 // Unlike a normal AEAD, a TLS AEAD may only be used in one direction.
David Benjamin3570d732015-06-29 00:28:17 -0400250 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_OPERATION);
David Benjaminb34f5102015-02-28 03:59:33 -0500251 return 0;
David Benjaminb34f5102015-02-28 03:59:33 -0500252 }
253
David Benjaminea72bd02014-12-21 21:27:41 -0500254 if (in_len < HMAC_size(&tls_ctx->hmac_ctx)) {
David Benjamin3570d732015-06-29 00:28:17 -0400255 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
David Benjaminea72bd02014-12-21 21:27:41 -0500256 return 0;
257 }
258
259 if (max_out_len < in_len) {
David Benjamin808f8322017-08-18 14:06:02 -0400260 // This requires that the caller provide space for the MAC, even though it
261 // will always be removed on return.
David Benjamin3570d732015-06-29 00:28:17 -0400262 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL);
David Benjaminea72bd02014-12-21 21:27:41 -0500263 return 0;
264 }
265
266 if (nonce_len != EVP_AEAD_nonce_length(ctx->aead)) {
David Benjamin3570d732015-06-29 00:28:17 -0400267 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_NONCE_SIZE);
David Benjaminea72bd02014-12-21 21:27:41 -0500268 return 0;
269 }
270
David Benjamin7f1d5d52015-01-14 17:24:53 -0500271 if (ad_len != 13 - 2 /* length bytes */) {
David Benjamin3570d732015-06-29 00:28:17 -0400272 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_AD_SIZE);
David Benjaminea72bd02014-12-21 21:27:41 -0500273 return 0;
274 }
275
276 if (in_len > INT_MAX) {
David Benjamin808f8322017-08-18 14:06:02 -0400277 // EVP_CIPHER takes int as input.
David Benjamin3570d732015-06-29 00:28:17 -0400278 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
David Benjaminea72bd02014-12-21 21:27:41 -0500279 return 0;
280 }
281
David Benjamin808f8322017-08-18 14:06:02 -0400282 // Configure the explicit IV.
David Benjaminea72bd02014-12-21 21:27:41 -0500283 if (EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) == EVP_CIPH_CBC_MODE &&
284 !tls_ctx->implicit_iv &&
285 !EVP_DecryptInit_ex(&tls_ctx->cipher_ctx, NULL, NULL, NULL, nonce)) {
286 return 0;
287 }
288
David Benjamin808f8322017-08-18 14:06:02 -0400289 // Decrypt to get the plaintext + MAC + padding.
David Benjaminea72bd02014-12-21 21:27:41 -0500290 size_t total = 0;
291 int len;
292 if (!EVP_DecryptUpdate(&tls_ctx->cipher_ctx, out, &len, in, (int)in_len)) {
293 return 0;
294 }
295 total += len;
296 if (!EVP_DecryptFinal_ex(&tls_ctx->cipher_ctx, out + total, &len)) {
297 return 0;
298 }
299 total += len;
300 assert(total == in_len);
301
David Benjamin808f8322017-08-18 14:06:02 -0400302 // Remove CBC padding. Code from here on is timing-sensitive with respect to
303 // |padding_ok| and |data_plus_mac_len| for CBC ciphers.
Adam Langley518ba072017-04-20 13:51:11 -0700304 size_t data_plus_mac_len;
305 crypto_word_t padding_ok;
David Benjaminea72bd02014-12-21 21:27:41 -0500306 if (EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) == EVP_CIPH_CBC_MODE) {
David Benjamin3f26a492016-08-09 23:36:43 -0400307 if (!EVP_tls_cbc_remove_padding(
308 &padding_ok, &data_plus_mac_len, out, total,
309 EVP_CIPHER_CTX_block_size(&tls_ctx->cipher_ctx),
David Benjamin643b77e2017-03-16 13:46:54 -0400310 HMAC_size(&tls_ctx->hmac_ctx))) {
David Benjamin808f8322017-08-18 14:06:02 -0400311 // Publicly invalid. This can be rejected in non-constant time.
David Benjamin3570d732015-06-29 00:28:17 -0400312 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
David Benjaminea72bd02014-12-21 21:27:41 -0500313 return 0;
314 }
315 } else {
Adam Langley518ba072017-04-20 13:51:11 -0700316 padding_ok = CONSTTIME_TRUE_W;
David Benjaminea72bd02014-12-21 21:27:41 -0500317 data_plus_mac_len = total;
David Benjamin808f8322017-08-18 14:06:02 -0400318 // |data_plus_mac_len| = |total| = |in_len| at this point. |in_len| has
319 // already been checked against the MAC size at the top of the function.
David Benjaminea72bd02014-12-21 21:27:41 -0500320 assert(data_plus_mac_len >= HMAC_size(&tls_ctx->hmac_ctx));
321 }
David Benjamin643b77e2017-03-16 13:46:54 -0400322 size_t data_len = data_plus_mac_len - HMAC_size(&tls_ctx->hmac_ctx);
David Benjaminea72bd02014-12-21 21:27:41 -0500323
David Benjamin808f8322017-08-18 14:06:02 -0400324 // At this point, if the padding is valid, the first |data_plus_mac_len| bytes
325 // after |out| are the plaintext and MAC. Otherwise, |data_plus_mac_len| is
326 // still large enough to extract a MAC, but it will be irrelevant.
David Benjaminea72bd02014-12-21 21:27:41 -0500327
David Benjamin808f8322017-08-18 14:06:02 -0400328 // To allow for CBC mode which changes cipher length, |ad| doesn't include the
329 // length for legacy ciphers.
David Benjaminea72bd02014-12-21 21:27:41 -0500330 uint8_t ad_fixed[13];
David Benjamin17cf2cb2016-12-13 01:07:13 -0500331 OPENSSL_memcpy(ad_fixed, ad, 11);
David Benjaminea72bd02014-12-21 21:27:41 -0500332 ad_fixed[11] = (uint8_t)(data_len >> 8);
333 ad_fixed[12] = (uint8_t)(data_len & 0xff);
334 ad_len += 2;
335
David Benjamin808f8322017-08-18 14:06:02 -0400336 // Compute the MAC and extract the one in the record.
David Benjaminea72bd02014-12-21 21:27:41 -0500337 uint8_t mac[EVP_MAX_MD_SIZE];
338 size_t mac_len;
339 uint8_t record_mac_tmp[EVP_MAX_MD_SIZE];
340 uint8_t *record_mac;
341 if (EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) == EVP_CIPH_CBC_MODE &&
David Benjaminbbd84442014-12-22 07:23:54 -0500342 EVP_tls_cbc_record_digest_supported(tls_ctx->hmac_ctx.md)) {
343 if (!EVP_tls_cbc_digest_record(tls_ctx->hmac_ctx.md, mac, &mac_len,
344 ad_fixed, out, data_plus_mac_len, total,
345 tls_ctx->mac_key, tls_ctx->mac_key_len)) {
David Benjamin3570d732015-06-29 00:28:17 -0400346 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
David Benjaminea72bd02014-12-21 21:27:41 -0500347 return 0;
348 }
349 assert(mac_len == HMAC_size(&tls_ctx->hmac_ctx));
350
351 record_mac = record_mac_tmp;
David Benjaminbbd84442014-12-22 07:23:54 -0500352 EVP_tls_cbc_copy_mac(record_mac, mac_len, out, data_plus_mac_len, total);
David Benjaminea72bd02014-12-21 21:27:41 -0500353 } else {
David Benjamin808f8322017-08-18 14:06:02 -0400354 // We should support the constant-time path for all CBC-mode ciphers
355 // implemented.
David Benjaminea72bd02014-12-21 21:27:41 -0500356 assert(EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) != EVP_CIPH_CBC_MODE);
357
David Benjaminea72bd02014-12-21 21:27:41 -0500358 unsigned mac_len_u;
David Benjamin1741a9d2015-12-07 19:52:56 -0500359 if (!HMAC_Init_ex(&tls_ctx->hmac_ctx, NULL, 0, NULL, NULL) ||
360 !HMAC_Update(&tls_ctx->hmac_ctx, ad_fixed, ad_len) ||
361 !HMAC_Update(&tls_ctx->hmac_ctx, out, data_len) ||
362 !HMAC_Final(&tls_ctx->hmac_ctx, mac, &mac_len_u)) {
David Benjaminea72bd02014-12-21 21:27:41 -0500363 return 0;
364 }
365 mac_len = mac_len_u;
David Benjaminea72bd02014-12-21 21:27:41 -0500366
367 assert(mac_len == HMAC_size(&tls_ctx->hmac_ctx));
368 record_mac = &out[data_len];
369 }
370
David Benjamin808f8322017-08-18 14:06:02 -0400371 // Perform the MAC check and the padding check in constant-time. It should be
372 // safe to simply perform the padding check first, but it would not be under a
373 // different choice of MAC location on padding failure. See
374 // EVP_tls_cbc_remove_padding.
Adam Langley518ba072017-04-20 13:51:11 -0700375 crypto_word_t good =
David Benjamin643b77e2017-03-16 13:46:54 -0400376 constant_time_eq_int(CRYPTO_memcmp(record_mac, mac, mac_len), 0);
David Benjamin3f26a492016-08-09 23:36:43 -0400377 good &= padding_ok;
David Benjaminea72bd02014-12-21 21:27:41 -0500378 if (!good) {
David Benjamin3570d732015-06-29 00:28:17 -0400379 OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
David Benjaminea72bd02014-12-21 21:27:41 -0500380 return 0;
381 }
382
David Benjamin808f8322017-08-18 14:06:02 -0400383 // End of timing-sensitive code.
David Benjaminea72bd02014-12-21 21:27:41 -0500384
385 *out_len = data_len;
386 return 1;
387}
388
David Benjaminea72bd02014-12-21 21:27:41 -0500389static int aead_aes_128_cbc_sha1_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
David Benjaminb34f5102015-02-28 03:59:33 -0500390 size_t key_len, size_t tag_len,
391 enum evp_aead_direction_t dir) {
392 return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_128_cbc(),
David Benjaminea72bd02014-12-21 21:27:41 -0500393 EVP_sha1(), 0);
394}
395
David Benjaminb34f5102015-02-28 03:59:33 -0500396static int aead_aes_128_cbc_sha1_tls_implicit_iv_init(
397 EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len, size_t tag_len,
398 enum evp_aead_direction_t dir) {
399 return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_128_cbc(),
David Benjaminea72bd02014-12-21 21:27:41 -0500400 EVP_sha1(), 1);
401}
402
403static int aead_aes_128_cbc_sha256_tls_init(EVP_AEAD_CTX *ctx,
404 const uint8_t *key, size_t key_len,
David Benjaminb34f5102015-02-28 03:59:33 -0500405 size_t tag_len,
406 enum evp_aead_direction_t dir) {
407 return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_128_cbc(),
David Benjaminea72bd02014-12-21 21:27:41 -0500408 EVP_sha256(), 0);
409}
410
411static int aead_aes_256_cbc_sha1_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
David Benjaminb34f5102015-02-28 03:59:33 -0500412 size_t key_len, size_t tag_len,
413 enum evp_aead_direction_t dir) {
414 return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_256_cbc(),
David Benjaminea72bd02014-12-21 21:27:41 -0500415 EVP_sha1(), 0);
416}
417
David Benjaminb34f5102015-02-28 03:59:33 -0500418static int aead_aes_256_cbc_sha1_tls_implicit_iv_init(
419 EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len, size_t tag_len,
420 enum evp_aead_direction_t dir) {
421 return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_256_cbc(),
David Benjaminea72bd02014-12-21 21:27:41 -0500422 EVP_sha1(), 1);
423}
424
425static int aead_aes_256_cbc_sha256_tls_init(EVP_AEAD_CTX *ctx,
426 const uint8_t *key, size_t key_len,
David Benjaminb34f5102015-02-28 03:59:33 -0500427 size_t tag_len,
428 enum evp_aead_direction_t dir) {
429 return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_256_cbc(),
David Benjaminea72bd02014-12-21 21:27:41 -0500430 EVP_sha256(), 0);
431}
432
433static int aead_aes_256_cbc_sha384_tls_init(EVP_AEAD_CTX *ctx,
434 const uint8_t *key, size_t key_len,
David Benjaminb34f5102015-02-28 03:59:33 -0500435 size_t tag_len,
436 enum evp_aead_direction_t dir) {
437 return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_256_cbc(),
David Benjaminea72bd02014-12-21 21:27:41 -0500438 EVP_sha384(), 0);
439}
440
441static int aead_des_ede3_cbc_sha1_tls_init(EVP_AEAD_CTX *ctx,
442 const uint8_t *key, size_t key_len,
David Benjaminb34f5102015-02-28 03:59:33 -0500443 size_t tag_len,
444 enum evp_aead_direction_t dir) {
445 return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_des_ede3_cbc(),
David Benjaminea72bd02014-12-21 21:27:41 -0500446 EVP_sha1(), 0);
447}
448
David Benjaminb34f5102015-02-28 03:59:33 -0500449static int aead_des_ede3_cbc_sha1_tls_implicit_iv_init(
450 EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len, size_t tag_len,
451 enum evp_aead_direction_t dir) {
452 return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_des_ede3_cbc(),
David Benjaminea72bd02014-12-21 21:27:41 -0500453 EVP_sha1(), 1);
454}
455
Adam Langleyc2d32802015-11-03 18:36:10 -0800456static int aead_tls_get_iv(const EVP_AEAD_CTX *ctx, const uint8_t **out_iv,
457 size_t *out_iv_len) {
458 const AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX*) ctx->aead_state;
459 const size_t iv_len = EVP_CIPHER_CTX_iv_length(&tls_ctx->cipher_ctx);
460 if (iv_len <= 1) {
461 return 0;
462 }
463
464 *out_iv = tls_ctx->cipher_ctx.iv;
465 *out_iv_len = iv_len;
466 return 1;
467}
468
Matt Braithwaiteaf096752015-09-02 19:48:16 -0700469static int aead_null_sha1_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
470 size_t key_len, size_t tag_len,
471 enum evp_aead_direction_t dir) {
472 return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_enc_null(),
473 EVP_sha1(), 1 /* implicit iv */);
474}
475
David Benjaminea72bd02014-12-21 21:27:41 -0500476static const EVP_AEAD aead_aes_128_cbc_sha1_tls = {
David Benjamin808f8322017-08-18 14:06:02 -0400477 SHA_DIGEST_LENGTH + 16, // key len (SHA1 + AES128)
478 16, // nonce len (IV)
479 16 + SHA_DIGEST_LENGTH, // overhead (padding + SHA1)
480 SHA_DIGEST_LENGTH, // max tag length
481 0, // seal_scatter_supports_extra_in
Martin Kreichgauer74bce292017-06-23 14:49:22 -0700482
David Benjamin808f8322017-08-18 14:06:02 -0400483 NULL, // init
David Benjaminea72bd02014-12-21 21:27:41 -0500484 aead_aes_128_cbc_sha1_tls_init,
485 aead_tls_cleanup,
David Benjaminea72bd02014-12-21 21:27:41 -0500486 aead_tls_open,
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700487 aead_tls_seal_scatter,
David Benjamin808f8322017-08-18 14:06:02 -0400488 NULL, // open_gather
489 NULL, // get_iv
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700490 aead_tls_tag_len,
David Benjaminea72bd02014-12-21 21:27:41 -0500491};
492
493static const EVP_AEAD aead_aes_128_cbc_sha1_tls_implicit_iv = {
David Benjamin808f8322017-08-18 14:06:02 -0400494 SHA_DIGEST_LENGTH + 16 + 16, // key len (SHA1 + AES128 + IV)
495 0, // nonce len
496 16 + SHA_DIGEST_LENGTH, // overhead (padding + SHA1)
497 SHA_DIGEST_LENGTH, // max tag length
498 0, // seal_scatter_supports_extra_in
Martin Kreichgauer74bce292017-06-23 14:49:22 -0700499
David Benjamin808f8322017-08-18 14:06:02 -0400500 NULL, // init
David Benjaminea72bd02014-12-21 21:27:41 -0500501 aead_aes_128_cbc_sha1_tls_implicit_iv_init,
502 aead_tls_cleanup,
David Benjaminea72bd02014-12-21 21:27:41 -0500503 aead_tls_open,
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700504 aead_tls_seal_scatter,
David Benjamin808f8322017-08-18 14:06:02 -0400505 NULL, // open_gather
506 aead_tls_get_iv, // get_iv
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700507 aead_tls_tag_len,
David Benjaminea72bd02014-12-21 21:27:41 -0500508};
509
510static const EVP_AEAD aead_aes_128_cbc_sha256_tls = {
David Benjamin808f8322017-08-18 14:06:02 -0400511 SHA256_DIGEST_LENGTH + 16, // key len (SHA256 + AES128)
512 16, // nonce len (IV)
513 16 + SHA256_DIGEST_LENGTH, // overhead (padding + SHA256)
514 SHA256_DIGEST_LENGTH, // max tag length
515 0, // seal_scatter_supports_extra_in
Martin Kreichgauer74bce292017-06-23 14:49:22 -0700516
David Benjamin808f8322017-08-18 14:06:02 -0400517 NULL, // init
David Benjaminea72bd02014-12-21 21:27:41 -0500518 aead_aes_128_cbc_sha256_tls_init,
519 aead_tls_cleanup,
David Benjaminea72bd02014-12-21 21:27:41 -0500520 aead_tls_open,
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700521 aead_tls_seal_scatter,
David Benjamin808f8322017-08-18 14:06:02 -0400522 NULL, // open_gather
523 NULL, // get_iv
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700524 aead_tls_tag_len,
David Benjaminea72bd02014-12-21 21:27:41 -0500525};
526
527static const EVP_AEAD aead_aes_256_cbc_sha1_tls = {
David Benjamin808f8322017-08-18 14:06:02 -0400528 SHA_DIGEST_LENGTH + 32, // key len (SHA1 + AES256)
529 16, // nonce len (IV)
530 16 + SHA_DIGEST_LENGTH, // overhead (padding + SHA1)
531 SHA_DIGEST_LENGTH, // max tag length
532 0, // seal_scatter_supports_extra_in
Martin Kreichgauer74bce292017-06-23 14:49:22 -0700533
David Benjamin808f8322017-08-18 14:06:02 -0400534 NULL, // init
David Benjaminea72bd02014-12-21 21:27:41 -0500535 aead_aes_256_cbc_sha1_tls_init,
536 aead_tls_cleanup,
David Benjaminea72bd02014-12-21 21:27:41 -0500537 aead_tls_open,
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700538 aead_tls_seal_scatter,
David Benjamin808f8322017-08-18 14:06:02 -0400539 NULL, // open_gather
540 NULL, // get_iv
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700541 aead_tls_tag_len,
David Benjaminea72bd02014-12-21 21:27:41 -0500542};
543
544static const EVP_AEAD aead_aes_256_cbc_sha1_tls_implicit_iv = {
David Benjamin808f8322017-08-18 14:06:02 -0400545 SHA_DIGEST_LENGTH + 32 + 16, // key len (SHA1 + AES256 + IV)
546 0, // nonce len
547 16 + SHA_DIGEST_LENGTH, // overhead (padding + SHA1)
548 SHA_DIGEST_LENGTH, // max tag length
549 0, // seal_scatter_supports_extra_in
Martin Kreichgauer74bce292017-06-23 14:49:22 -0700550
David Benjamin808f8322017-08-18 14:06:02 -0400551 NULL, // init
David Benjaminea72bd02014-12-21 21:27:41 -0500552 aead_aes_256_cbc_sha1_tls_implicit_iv_init,
553 aead_tls_cleanup,
David Benjaminea72bd02014-12-21 21:27:41 -0500554 aead_tls_open,
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700555 aead_tls_seal_scatter,
David Benjamin808f8322017-08-18 14:06:02 -0400556 NULL, // open_gather
557 aead_tls_get_iv, // get_iv
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700558 aead_tls_tag_len,
David Benjaminea72bd02014-12-21 21:27:41 -0500559};
560
561static const EVP_AEAD aead_aes_256_cbc_sha256_tls = {
David Benjamin808f8322017-08-18 14:06:02 -0400562 SHA256_DIGEST_LENGTH + 32, // key len (SHA256 + AES256)
563 16, // nonce len (IV)
564 16 + SHA256_DIGEST_LENGTH, // overhead (padding + SHA256)
565 SHA256_DIGEST_LENGTH, // max tag length
566 0, // seal_scatter_supports_extra_in
Martin Kreichgauer74bce292017-06-23 14:49:22 -0700567
David Benjamin808f8322017-08-18 14:06:02 -0400568 NULL, // init
David Benjaminea72bd02014-12-21 21:27:41 -0500569 aead_aes_256_cbc_sha256_tls_init,
570 aead_tls_cleanup,
David Benjaminea72bd02014-12-21 21:27:41 -0500571 aead_tls_open,
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700572 aead_tls_seal_scatter,
David Benjamin808f8322017-08-18 14:06:02 -0400573 NULL, // open_gather
574 NULL, // get_iv
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700575 aead_tls_tag_len,
David Benjaminea72bd02014-12-21 21:27:41 -0500576};
577
578static const EVP_AEAD aead_aes_256_cbc_sha384_tls = {
David Benjamin808f8322017-08-18 14:06:02 -0400579 SHA384_DIGEST_LENGTH + 32, // key len (SHA384 + AES256)
580 16, // nonce len (IV)
581 16 + SHA384_DIGEST_LENGTH, // overhead (padding + SHA384)
582 SHA384_DIGEST_LENGTH, // max tag length
583 0, // seal_scatter_supports_extra_in
Martin Kreichgauer74bce292017-06-23 14:49:22 -0700584
David Benjamin808f8322017-08-18 14:06:02 -0400585 NULL, // init
David Benjaminea72bd02014-12-21 21:27:41 -0500586 aead_aes_256_cbc_sha384_tls_init,
587 aead_tls_cleanup,
David Benjaminea72bd02014-12-21 21:27:41 -0500588 aead_tls_open,
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700589 aead_tls_seal_scatter,
David Benjamin808f8322017-08-18 14:06:02 -0400590 NULL, // open_gather
591 NULL, // get_iv
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700592 aead_tls_tag_len,
David Benjaminea72bd02014-12-21 21:27:41 -0500593};
594
595static const EVP_AEAD aead_des_ede3_cbc_sha1_tls = {
David Benjamin808f8322017-08-18 14:06:02 -0400596 SHA_DIGEST_LENGTH + 24, // key len (SHA1 + 3DES)
597 8, // nonce len (IV)
598 8 + SHA_DIGEST_LENGTH, // overhead (padding + SHA1)
599 SHA_DIGEST_LENGTH, // max tag length
600 0, // seal_scatter_supports_extra_in
Martin Kreichgauer74bce292017-06-23 14:49:22 -0700601
David Benjamin808f8322017-08-18 14:06:02 -0400602 NULL, // init
David Benjaminea72bd02014-12-21 21:27:41 -0500603 aead_des_ede3_cbc_sha1_tls_init,
604 aead_tls_cleanup,
David Benjaminea72bd02014-12-21 21:27:41 -0500605 aead_tls_open,
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700606 aead_tls_seal_scatter,
David Benjamin808f8322017-08-18 14:06:02 -0400607 NULL, // open_gather
608 NULL, // get_iv
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700609 aead_tls_tag_len,
David Benjaminea72bd02014-12-21 21:27:41 -0500610};
611
612static const EVP_AEAD aead_des_ede3_cbc_sha1_tls_implicit_iv = {
David Benjamin808f8322017-08-18 14:06:02 -0400613 SHA_DIGEST_LENGTH + 24 + 8, // key len (SHA1 + 3DES + IV)
614 0, // nonce len
615 8 + SHA_DIGEST_LENGTH, // overhead (padding + SHA1)
616 SHA_DIGEST_LENGTH, // max tag length
617 0, // seal_scatter_supports_extra_in
Martin Kreichgauer74bce292017-06-23 14:49:22 -0700618
David Benjamin808f8322017-08-18 14:06:02 -0400619 NULL, // init
David Benjaminea72bd02014-12-21 21:27:41 -0500620 aead_des_ede3_cbc_sha1_tls_implicit_iv_init,
621 aead_tls_cleanup,
David Benjaminea72bd02014-12-21 21:27:41 -0500622 aead_tls_open,
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700623 aead_tls_seal_scatter,
David Benjamin808f8322017-08-18 14:06:02 -0400624 NULL, // open_gather
625 aead_tls_get_iv, // get_iv
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700626 aead_tls_tag_len,
David Benjaminea72bd02014-12-21 21:27:41 -0500627};
628
Matt Braithwaiteaf096752015-09-02 19:48:16 -0700629static const EVP_AEAD aead_null_sha1_tls = {
David Benjamin808f8322017-08-18 14:06:02 -0400630 SHA_DIGEST_LENGTH, // key len
631 0, // nonce len
632 SHA_DIGEST_LENGTH, // overhead (SHA1)
633 SHA_DIGEST_LENGTH, // max tag length
634 0, // seal_scatter_supports_extra_in
Martin Kreichgauer74bce292017-06-23 14:49:22 -0700635
David Benjamin808f8322017-08-18 14:06:02 -0400636 NULL, // init
Matt Braithwaiteaf096752015-09-02 19:48:16 -0700637 aead_null_sha1_tls_init,
638 aead_tls_cleanup,
Matt Braithwaiteaf096752015-09-02 19:48:16 -0700639 aead_tls_open,
Martin Kreichgauer18d9f282017-06-06 12:29:48 -0700640 aead_tls_seal_scatter,
David Benjamin808f8322017-08-18 14:06:02 -0400641 NULL, // open_gather
642 NULL, // get_iv
Martin Kreichgauerabbf3652017-07-21 16:27:54 -0700643 aead_tls_tag_len,
Matt Braithwaiteaf096752015-09-02 19:48:16 -0700644};
645
David Benjaminea72bd02014-12-21 21:27:41 -0500646const EVP_AEAD *EVP_aead_aes_128_cbc_sha1_tls(void) {
647 return &aead_aes_128_cbc_sha1_tls;
648}
649
650const EVP_AEAD *EVP_aead_aes_128_cbc_sha1_tls_implicit_iv(void) {
651 return &aead_aes_128_cbc_sha1_tls_implicit_iv;
652}
653
654const EVP_AEAD *EVP_aead_aes_128_cbc_sha256_tls(void) {
655 return &aead_aes_128_cbc_sha256_tls;
656}
657
658const EVP_AEAD *EVP_aead_aes_256_cbc_sha1_tls(void) {
659 return &aead_aes_256_cbc_sha1_tls;
660}
661
662const EVP_AEAD *EVP_aead_aes_256_cbc_sha1_tls_implicit_iv(void) {
663 return &aead_aes_256_cbc_sha1_tls_implicit_iv;
664}
665
666const EVP_AEAD *EVP_aead_aes_256_cbc_sha256_tls(void) {
667 return &aead_aes_256_cbc_sha256_tls;
668}
669
670const EVP_AEAD *EVP_aead_aes_256_cbc_sha384_tls(void) {
671 return &aead_aes_256_cbc_sha384_tls;
672}
673
674const EVP_AEAD *EVP_aead_des_ede3_cbc_sha1_tls(void) {
675 return &aead_des_ede3_cbc_sha1_tls;
676}
677
678const EVP_AEAD *EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv(void) {
679 return &aead_des_ede3_cbc_sha1_tls_implicit_iv;
680}
Matt Braithwaiteaf096752015-09-02 19:48:16 -0700681
682const EVP_AEAD *EVP_aead_null_sha1_tls(void) { return &aead_null_sha1_tls; }