Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 1 | /* 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> |
Adam Langley | 4139edb | 2016-01-13 15:00:54 -0800 | [diff] [blame] | 23 | #include <openssl/md5.h> |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 24 | #include <openssl/mem.h> |
| 25 | #include <openssl/sha.h> |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 26 | #include <openssl/type_check.h> |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 27 | |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 28 | #include "../internal.h" |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 29 | #include "internal.h" |
| 30 | |
| 31 | |
| 32 | typedef struct { |
| 33 | EVP_CIPHER_CTX cipher_ctx; |
| 34 | HMAC_CTX hmac_ctx; |
| 35 | /* mac_key is the portion of the key used for the MAC. It is retained |
| 36 | * separately for the constant-time CBC code. */ |
| 37 | uint8_t mac_key[EVP_MAX_MD_SIZE]; |
| 38 | uint8_t mac_key_len; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 39 | /* implicit_iv is one iff this is a pre-TLS-1.1 CBC cipher without an explicit |
| 40 | * IV. */ |
| 41 | char implicit_iv; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 42 | } AEAD_TLS_CTX; |
| 43 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 44 | OPENSSL_COMPILE_ASSERT(EVP_MAX_MD_SIZE < 256, mac_key_len_fits_in_uint8_t); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 45 | |
| 46 | static void aead_tls_cleanup(EVP_AEAD_CTX *ctx) { |
| 47 | AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)ctx->aead_state; |
| 48 | EVP_CIPHER_CTX_cleanup(&tls_ctx->cipher_ctx); |
| 49 | HMAC_CTX_cleanup(&tls_ctx->hmac_ctx); |
| 50 | OPENSSL_cleanse(&tls_ctx->mac_key, sizeof(tls_ctx->mac_key)); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 51 | OPENSSL_free(tls_ctx); |
| 52 | ctx->aead_state = NULL; |
| 53 | } |
| 54 | |
| 55 | static int aead_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len, |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 56 | size_t tag_len, enum evp_aead_direction_t dir, |
| 57 | const EVP_CIPHER *cipher, const EVP_MD *md, |
| 58 | char implicit_iv) { |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 59 | if (tag_len != EVP_AEAD_DEFAULT_TAG_LENGTH && |
| 60 | tag_len != EVP_MD_size(md)) { |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 61 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_UNSUPPORTED_TAG_SIZE); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | if (key_len != EVP_AEAD_key_length(ctx->aead)) { |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 66 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_KEY_LENGTH); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | size_t mac_key_len = EVP_MD_size(md); |
| 71 | size_t enc_key_len = EVP_CIPHER_key_length(cipher); |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 72 | assert(mac_key_len + enc_key_len + |
| 73 | (implicit_iv ? EVP_CIPHER_iv_length(cipher) : 0) == key_len); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 74 | |
| 75 | AEAD_TLS_CTX *tls_ctx = OPENSSL_malloc(sizeof(AEAD_TLS_CTX)); |
| 76 | if (tls_ctx == NULL) { |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 77 | OPENSSL_PUT_ERROR(CIPHER, ERR_R_MALLOC_FAILURE); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 78 | return 0; |
| 79 | } |
| 80 | EVP_CIPHER_CTX_init(&tls_ctx->cipher_ctx); |
| 81 | HMAC_CTX_init(&tls_ctx->hmac_ctx); |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 82 | assert(mac_key_len <= EVP_MAX_MD_SIZE); |
Robert Sloan | 69939df | 2017-01-09 10:53:07 -0800 | [diff] [blame] | 83 | OPENSSL_memcpy(tls_ctx->mac_key, key, mac_key_len); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 84 | tls_ctx->mac_key_len = (uint8_t)mac_key_len; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 85 | tls_ctx->implicit_iv = implicit_iv; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 86 | |
| 87 | ctx->aead_state = tls_ctx; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 88 | if (!EVP_CipherInit_ex(&tls_ctx->cipher_ctx, cipher, NULL, &key[mac_key_len], |
| 89 | implicit_iv ? &key[mac_key_len + enc_key_len] : NULL, |
| 90 | dir == evp_aead_seal) || |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 91 | !HMAC_Init_ex(&tls_ctx->hmac_ctx, key, mac_key_len, md, NULL)) { |
| 92 | aead_tls_cleanup(ctx); |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 93 | ctx->aead_state = NULL; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 94 | return 0; |
| 95 | } |
| 96 | EVP_CIPHER_CTX_set_padding(&tls_ctx->cipher_ctx, 0); |
| 97 | |
| 98 | return 1; |
| 99 | } |
| 100 | |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 101 | static int aead_tls_seal(const EVP_AEAD_CTX *ctx, uint8_t *out, |
| 102 | size_t *out_len, size_t max_out_len, |
| 103 | const uint8_t *nonce, size_t nonce_len, |
| 104 | const uint8_t *in, size_t in_len, |
| 105 | const uint8_t *ad, size_t ad_len) { |
| 106 | AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)ctx->aead_state; |
| 107 | size_t total = 0; |
| 108 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 109 | if (!tls_ctx->cipher_ctx.encrypt) { |
| 110 | /* Unlike a normal AEAD, a TLS AEAD may only be used in one direction. */ |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 111 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_OPERATION); |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 112 | return 0; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 115 | if (in_len + EVP_AEAD_max_overhead(ctx->aead) < in_len || |
| 116 | in_len > INT_MAX) { |
| 117 | /* EVP_CIPHER takes int as input. */ |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 118 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | if (max_out_len < in_len + EVP_AEAD_max_overhead(ctx->aead)) { |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 123 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | if (nonce_len != EVP_AEAD_nonce_length(ctx->aead)) { |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 128 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_NONCE_SIZE); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | if (ad_len != 13 - 2 /* length bytes */) { |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 133 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_AD_SIZE); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 134 | return 0; |
| 135 | } |
| 136 | |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 137 | /* To allow for CBC mode which changes cipher length, |ad| doesn't include the |
| 138 | * length for legacy ciphers. */ |
| 139 | uint8_t ad_extra[2]; |
| 140 | ad_extra[0] = (uint8_t)(in_len >> 8); |
| 141 | ad_extra[1] = (uint8_t)(in_len & 0xff); |
| 142 | |
| 143 | /* Compute the MAC. This must be first in case the operation is being done |
| 144 | * in-place. */ |
| 145 | uint8_t mac[EVP_MAX_MD_SIZE]; |
| 146 | unsigned mac_len; |
Adam Langley | 4139edb | 2016-01-13 15:00:54 -0800 | [diff] [blame] | 147 | if (!HMAC_Init_ex(&tls_ctx->hmac_ctx, NULL, 0, NULL, NULL) || |
| 148 | !HMAC_Update(&tls_ctx->hmac_ctx, ad, ad_len) || |
| 149 | !HMAC_Update(&tls_ctx->hmac_ctx, ad_extra, sizeof(ad_extra)) || |
| 150 | !HMAC_Update(&tls_ctx->hmac_ctx, in, in_len) || |
| 151 | !HMAC_Final(&tls_ctx->hmac_ctx, mac, &mac_len)) { |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 152 | return 0; |
| 153 | } |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 154 | |
| 155 | /* Configure the explicit IV. */ |
| 156 | if (EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) == EVP_CIPH_CBC_MODE && |
| 157 | !tls_ctx->implicit_iv && |
| 158 | !EVP_EncryptInit_ex(&tls_ctx->cipher_ctx, NULL, NULL, NULL, nonce)) { |
| 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | /* Encrypt the input. */ |
| 163 | int len; |
| 164 | if (!EVP_EncryptUpdate(&tls_ctx->cipher_ctx, out, &len, in, |
| 165 | (int)in_len)) { |
| 166 | return 0; |
| 167 | } |
| 168 | total = len; |
| 169 | |
| 170 | /* Feed the MAC into the cipher. */ |
| 171 | if (!EVP_EncryptUpdate(&tls_ctx->cipher_ctx, out + total, &len, mac, |
| 172 | (int)mac_len)) { |
| 173 | return 0; |
| 174 | } |
| 175 | total += len; |
| 176 | |
| 177 | unsigned block_size = EVP_CIPHER_CTX_block_size(&tls_ctx->cipher_ctx); |
| 178 | if (block_size > 1) { |
| 179 | assert(block_size <= 256); |
| 180 | assert(EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) == EVP_CIPH_CBC_MODE); |
| 181 | |
| 182 | /* Compute padding and feed that into the cipher. */ |
| 183 | uint8_t padding[256]; |
| 184 | unsigned padding_len = block_size - ((in_len + mac_len) % block_size); |
Robert Sloan | 69939df | 2017-01-09 10:53:07 -0800 | [diff] [blame] | 185 | OPENSSL_memset(padding, padding_len - 1, padding_len); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 186 | if (!EVP_EncryptUpdate(&tls_ctx->cipher_ctx, out + total, &len, padding, |
| 187 | (int)padding_len)) { |
| 188 | return 0; |
| 189 | } |
| 190 | total += len; |
| 191 | } |
| 192 | |
| 193 | if (!EVP_EncryptFinal_ex(&tls_ctx->cipher_ctx, out + total, &len)) { |
| 194 | return 0; |
| 195 | } |
| 196 | total += len; |
| 197 | |
| 198 | *out_len = total; |
| 199 | return 1; |
| 200 | } |
| 201 | |
| 202 | static int aead_tls_open(const EVP_AEAD_CTX *ctx, uint8_t *out, |
| 203 | size_t *out_len, size_t max_out_len, |
| 204 | const uint8_t *nonce, size_t nonce_len, |
| 205 | const uint8_t *in, size_t in_len, |
| 206 | const uint8_t *ad, size_t ad_len) { |
| 207 | AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)ctx->aead_state; |
| 208 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 209 | if (tls_ctx->cipher_ctx.encrypt) { |
| 210 | /* Unlike a normal AEAD, a TLS AEAD may only be used in one direction. */ |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 211 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_OPERATION); |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 212 | return 0; |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 215 | if (in_len < HMAC_size(&tls_ctx->hmac_ctx)) { |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 216 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | if (max_out_len < in_len) { |
| 221 | /* This requires that the caller provide space for the MAC, even though it |
| 222 | * will always be removed on return. */ |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 223 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 224 | return 0; |
| 225 | } |
| 226 | |
| 227 | if (nonce_len != EVP_AEAD_nonce_length(ctx->aead)) { |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 228 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_NONCE_SIZE); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 229 | return 0; |
| 230 | } |
| 231 | |
| 232 | if (ad_len != 13 - 2 /* length bytes */) { |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 233 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_AD_SIZE); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 234 | return 0; |
| 235 | } |
| 236 | |
| 237 | if (in_len > INT_MAX) { |
| 238 | /* EVP_CIPHER takes int as input. */ |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 239 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 240 | return 0; |
| 241 | } |
| 242 | |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 243 | /* Configure the explicit IV. */ |
| 244 | if (EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) == EVP_CIPH_CBC_MODE && |
| 245 | !tls_ctx->implicit_iv && |
| 246 | !EVP_DecryptInit_ex(&tls_ctx->cipher_ctx, NULL, NULL, NULL, nonce)) { |
| 247 | return 0; |
| 248 | } |
| 249 | |
| 250 | /* Decrypt to get the plaintext + MAC + padding. */ |
| 251 | size_t total = 0; |
| 252 | int len; |
| 253 | if (!EVP_DecryptUpdate(&tls_ctx->cipher_ctx, out, &len, in, (int)in_len)) { |
| 254 | return 0; |
| 255 | } |
| 256 | total += len; |
| 257 | if (!EVP_DecryptFinal_ex(&tls_ctx->cipher_ctx, out + total, &len)) { |
| 258 | return 0; |
| 259 | } |
| 260 | total += len; |
| 261 | assert(total == in_len); |
| 262 | |
| 263 | /* Remove CBC padding. Code from here on is timing-sensitive with respect to |
| 264 | * |padding_ok| and |data_plus_mac_len| for CBC ciphers. */ |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 265 | size_t data_plus_mac_len; |
| 266 | crypto_word_t padding_ok; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 267 | if (EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) == EVP_CIPH_CBC_MODE) { |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 268 | if (!EVP_tls_cbc_remove_padding( |
| 269 | &padding_ok, &data_plus_mac_len, out, total, |
| 270 | EVP_CIPHER_CTX_block_size(&tls_ctx->cipher_ctx), |
Robert Sloan | 6f79a50 | 2017-04-03 09:16:40 -0700 | [diff] [blame] | 271 | HMAC_size(&tls_ctx->hmac_ctx))) { |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 272 | /* Publicly invalid. This can be rejected in non-constant time. */ |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 273 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 274 | return 0; |
| 275 | } |
| 276 | } else { |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 277 | padding_ok = CONSTTIME_TRUE_W; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 278 | data_plus_mac_len = total; |
| 279 | /* |data_plus_mac_len| = |total| = |in_len| at this point. |in_len| has |
| 280 | * already been checked against the MAC size at the top of the function. */ |
| 281 | assert(data_plus_mac_len >= HMAC_size(&tls_ctx->hmac_ctx)); |
| 282 | } |
Robert Sloan | 6f79a50 | 2017-04-03 09:16:40 -0700 | [diff] [blame] | 283 | size_t data_len = data_plus_mac_len - HMAC_size(&tls_ctx->hmac_ctx); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 284 | |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 285 | /* At this point, if the padding is valid, the first |data_plus_mac_len| bytes |
| 286 | * after |out| are the plaintext and MAC. Otherwise, |data_plus_mac_len| is |
| 287 | * still large enough to extract a MAC, but it will be irrelevant. */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 288 | |
| 289 | /* To allow for CBC mode which changes cipher length, |ad| doesn't include the |
| 290 | * length for legacy ciphers. */ |
| 291 | uint8_t ad_fixed[13]; |
Robert Sloan | 69939df | 2017-01-09 10:53:07 -0800 | [diff] [blame] | 292 | OPENSSL_memcpy(ad_fixed, ad, 11); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 293 | ad_fixed[11] = (uint8_t)(data_len >> 8); |
| 294 | ad_fixed[12] = (uint8_t)(data_len & 0xff); |
| 295 | ad_len += 2; |
| 296 | |
| 297 | /* Compute the MAC and extract the one in the record. */ |
| 298 | uint8_t mac[EVP_MAX_MD_SIZE]; |
| 299 | size_t mac_len; |
| 300 | uint8_t record_mac_tmp[EVP_MAX_MD_SIZE]; |
| 301 | uint8_t *record_mac; |
| 302 | if (EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) == EVP_CIPH_CBC_MODE && |
| 303 | EVP_tls_cbc_record_digest_supported(tls_ctx->hmac_ctx.md)) { |
| 304 | if (!EVP_tls_cbc_digest_record(tls_ctx->hmac_ctx.md, mac, &mac_len, |
| 305 | ad_fixed, out, data_plus_mac_len, total, |
| 306 | tls_ctx->mac_key, tls_ctx->mac_key_len)) { |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 307 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 308 | return 0; |
| 309 | } |
| 310 | assert(mac_len == HMAC_size(&tls_ctx->hmac_ctx)); |
| 311 | |
| 312 | record_mac = record_mac_tmp; |
| 313 | EVP_tls_cbc_copy_mac(record_mac, mac_len, out, data_plus_mac_len, total); |
| 314 | } else { |
| 315 | /* We should support the constant-time path for all CBC-mode ciphers |
| 316 | * implemented. */ |
| 317 | assert(EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) != EVP_CIPH_CBC_MODE); |
| 318 | |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 319 | unsigned mac_len_u; |
Adam Langley | 4139edb | 2016-01-13 15:00:54 -0800 | [diff] [blame] | 320 | if (!HMAC_Init_ex(&tls_ctx->hmac_ctx, NULL, 0, NULL, NULL) || |
| 321 | !HMAC_Update(&tls_ctx->hmac_ctx, ad_fixed, ad_len) || |
| 322 | !HMAC_Update(&tls_ctx->hmac_ctx, out, data_len) || |
| 323 | !HMAC_Final(&tls_ctx->hmac_ctx, mac, &mac_len_u)) { |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 324 | return 0; |
| 325 | } |
| 326 | mac_len = mac_len_u; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 327 | |
| 328 | assert(mac_len == HMAC_size(&tls_ctx->hmac_ctx)); |
| 329 | record_mac = &out[data_len]; |
| 330 | } |
| 331 | |
| 332 | /* Perform the MAC check and the padding check in constant-time. It should be |
| 333 | * safe to simply perform the padding check first, but it would not be under a |
| 334 | * different choice of MAC location on padding failure. See |
| 335 | * EVP_tls_cbc_remove_padding. */ |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 336 | crypto_word_t good = |
Robert Sloan | 6f79a50 | 2017-04-03 09:16:40 -0700 | [diff] [blame] | 337 | constant_time_eq_int(CRYPTO_memcmp(record_mac, mac, mac_len), 0); |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 338 | good &= padding_ok; |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 339 | if (!good) { |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 340 | OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT); |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | /* End of timing-sensitive code. */ |
| 345 | |
| 346 | *out_len = data_len; |
| 347 | return 1; |
| 348 | } |
| 349 | |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 350 | static int aead_aes_128_cbc_sha1_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key, |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 351 | size_t key_len, size_t tag_len, |
| 352 | enum evp_aead_direction_t dir) { |
| 353 | return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_128_cbc(), |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 354 | EVP_sha1(), 0); |
| 355 | } |
| 356 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 357 | static int aead_aes_128_cbc_sha1_tls_implicit_iv_init( |
| 358 | EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len, size_t tag_len, |
| 359 | enum evp_aead_direction_t dir) { |
| 360 | return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_128_cbc(), |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 361 | EVP_sha1(), 1); |
| 362 | } |
| 363 | |
| 364 | static int aead_aes_128_cbc_sha256_tls_init(EVP_AEAD_CTX *ctx, |
| 365 | const uint8_t *key, size_t key_len, |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 366 | size_t tag_len, |
| 367 | enum evp_aead_direction_t dir) { |
| 368 | return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_128_cbc(), |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 369 | EVP_sha256(), 0); |
| 370 | } |
| 371 | |
| 372 | static int aead_aes_256_cbc_sha1_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key, |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 373 | size_t key_len, size_t tag_len, |
| 374 | enum evp_aead_direction_t dir) { |
| 375 | return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_256_cbc(), |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 376 | EVP_sha1(), 0); |
| 377 | } |
| 378 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 379 | static int aead_aes_256_cbc_sha1_tls_implicit_iv_init( |
| 380 | EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len, size_t tag_len, |
| 381 | enum evp_aead_direction_t dir) { |
| 382 | return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_256_cbc(), |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 383 | EVP_sha1(), 1); |
| 384 | } |
| 385 | |
| 386 | static int aead_aes_256_cbc_sha256_tls_init(EVP_AEAD_CTX *ctx, |
| 387 | const uint8_t *key, size_t key_len, |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 388 | size_t tag_len, |
| 389 | enum evp_aead_direction_t dir) { |
| 390 | return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_256_cbc(), |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 391 | EVP_sha256(), 0); |
| 392 | } |
| 393 | |
| 394 | static int aead_aes_256_cbc_sha384_tls_init(EVP_AEAD_CTX *ctx, |
| 395 | const uint8_t *key, size_t key_len, |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 396 | size_t tag_len, |
| 397 | enum evp_aead_direction_t dir) { |
| 398 | return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_256_cbc(), |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 399 | EVP_sha384(), 0); |
| 400 | } |
| 401 | |
| 402 | static int aead_des_ede3_cbc_sha1_tls_init(EVP_AEAD_CTX *ctx, |
| 403 | const uint8_t *key, size_t key_len, |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 404 | size_t tag_len, |
| 405 | enum evp_aead_direction_t dir) { |
| 406 | return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_des_ede3_cbc(), |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 407 | EVP_sha1(), 0); |
| 408 | } |
| 409 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 410 | static int aead_des_ede3_cbc_sha1_tls_implicit_iv_init( |
| 411 | EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len, size_t tag_len, |
| 412 | enum evp_aead_direction_t dir) { |
| 413 | return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_des_ede3_cbc(), |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 414 | EVP_sha1(), 1); |
| 415 | } |
| 416 | |
Adam Langley | fad6327 | 2015-11-12 12:15:39 -0800 | [diff] [blame] | 417 | static int aead_tls_get_iv(const EVP_AEAD_CTX *ctx, const uint8_t **out_iv, |
| 418 | size_t *out_iv_len) { |
| 419 | const AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX*) ctx->aead_state; |
| 420 | const size_t iv_len = EVP_CIPHER_CTX_iv_length(&tls_ctx->cipher_ctx); |
| 421 | if (iv_len <= 1) { |
| 422 | return 0; |
| 423 | } |
| 424 | |
| 425 | *out_iv = tls_ctx->cipher_ctx.iv; |
| 426 | *out_iv_len = iv_len; |
| 427 | return 1; |
| 428 | } |
| 429 | |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 430 | static int aead_null_sha1_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key, |
| 431 | size_t key_len, size_t tag_len, |
| 432 | enum evp_aead_direction_t dir) { |
| 433 | return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_enc_null(), |
| 434 | EVP_sha1(), 1 /* implicit iv */); |
| 435 | } |
| 436 | |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 437 | static const EVP_AEAD aead_aes_128_cbc_sha1_tls = { |
| 438 | SHA_DIGEST_LENGTH + 16, /* key len (SHA1 + AES128) */ |
| 439 | 16, /* nonce len (IV) */ |
| 440 | 16 + SHA_DIGEST_LENGTH, /* overhead (padding + SHA1) */ |
| 441 | SHA_DIGEST_LENGTH, /* max tag length */ |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 442 | NULL, /* init */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 443 | aead_aes_128_cbc_sha1_tls_init, |
| 444 | aead_tls_cleanup, |
| 445 | aead_tls_seal, |
| 446 | aead_tls_open, |
Adam Langley | fad6327 | 2015-11-12 12:15:39 -0800 | [diff] [blame] | 447 | NULL, /* get_iv */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 448 | }; |
| 449 | |
| 450 | static const EVP_AEAD aead_aes_128_cbc_sha1_tls_implicit_iv = { |
| 451 | SHA_DIGEST_LENGTH + 16 + 16, /* key len (SHA1 + AES128 + IV) */ |
| 452 | 0, /* nonce len */ |
| 453 | 16 + SHA_DIGEST_LENGTH, /* overhead (padding + SHA1) */ |
| 454 | SHA_DIGEST_LENGTH, /* max tag length */ |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 455 | NULL, /* init */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 456 | aead_aes_128_cbc_sha1_tls_implicit_iv_init, |
| 457 | aead_tls_cleanup, |
| 458 | aead_tls_seal, |
| 459 | aead_tls_open, |
Adam Langley | fad6327 | 2015-11-12 12:15:39 -0800 | [diff] [blame] | 460 | aead_tls_get_iv, /* get_iv */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 461 | }; |
| 462 | |
| 463 | static const EVP_AEAD aead_aes_128_cbc_sha256_tls = { |
| 464 | SHA256_DIGEST_LENGTH + 16, /* key len (SHA256 + AES128) */ |
| 465 | 16, /* nonce len (IV) */ |
| 466 | 16 + SHA256_DIGEST_LENGTH, /* overhead (padding + SHA256) */ |
Kenny Root | e99801b | 2015-11-06 15:31:15 -0800 | [diff] [blame] | 467 | SHA256_DIGEST_LENGTH, /* max tag length */ |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 468 | NULL, /* init */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 469 | aead_aes_128_cbc_sha256_tls_init, |
| 470 | aead_tls_cleanup, |
| 471 | aead_tls_seal, |
| 472 | aead_tls_open, |
Adam Langley | fad6327 | 2015-11-12 12:15:39 -0800 | [diff] [blame] | 473 | NULL, /* get_iv */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 474 | }; |
| 475 | |
| 476 | static const EVP_AEAD aead_aes_256_cbc_sha1_tls = { |
| 477 | SHA_DIGEST_LENGTH + 32, /* key len (SHA1 + AES256) */ |
| 478 | 16, /* nonce len (IV) */ |
| 479 | 16 + SHA_DIGEST_LENGTH, /* overhead (padding + SHA1) */ |
| 480 | SHA_DIGEST_LENGTH, /* max tag length */ |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 481 | NULL, /* init */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 482 | aead_aes_256_cbc_sha1_tls_init, |
| 483 | aead_tls_cleanup, |
| 484 | aead_tls_seal, |
| 485 | aead_tls_open, |
Adam Langley | fad6327 | 2015-11-12 12:15:39 -0800 | [diff] [blame] | 486 | NULL, /* get_iv */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 487 | }; |
| 488 | |
| 489 | static const EVP_AEAD aead_aes_256_cbc_sha1_tls_implicit_iv = { |
| 490 | SHA_DIGEST_LENGTH + 32 + 16, /* key len (SHA1 + AES256 + IV) */ |
| 491 | 0, /* nonce len */ |
| 492 | 16 + SHA_DIGEST_LENGTH, /* overhead (padding + SHA1) */ |
| 493 | SHA_DIGEST_LENGTH, /* max tag length */ |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 494 | NULL, /* init */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 495 | aead_aes_256_cbc_sha1_tls_implicit_iv_init, |
| 496 | aead_tls_cleanup, |
| 497 | aead_tls_seal, |
| 498 | aead_tls_open, |
Adam Langley | fad6327 | 2015-11-12 12:15:39 -0800 | [diff] [blame] | 499 | aead_tls_get_iv, /* get_iv */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 500 | }; |
| 501 | |
| 502 | static const EVP_AEAD aead_aes_256_cbc_sha256_tls = { |
| 503 | SHA256_DIGEST_LENGTH + 32, /* key len (SHA256 + AES256) */ |
| 504 | 16, /* nonce len (IV) */ |
| 505 | 16 + SHA256_DIGEST_LENGTH, /* overhead (padding + SHA256) */ |
Kenny Root | e99801b | 2015-11-06 15:31:15 -0800 | [diff] [blame] | 506 | SHA256_DIGEST_LENGTH, /* max tag length */ |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 507 | NULL, /* init */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 508 | aead_aes_256_cbc_sha256_tls_init, |
| 509 | aead_tls_cleanup, |
| 510 | aead_tls_seal, |
| 511 | aead_tls_open, |
Adam Langley | fad6327 | 2015-11-12 12:15:39 -0800 | [diff] [blame] | 512 | NULL, /* get_iv */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 513 | }; |
| 514 | |
| 515 | static const EVP_AEAD aead_aes_256_cbc_sha384_tls = { |
| 516 | SHA384_DIGEST_LENGTH + 32, /* key len (SHA384 + AES256) */ |
| 517 | 16, /* nonce len (IV) */ |
| 518 | 16 + SHA384_DIGEST_LENGTH, /* overhead (padding + SHA384) */ |
Kenny Root | e99801b | 2015-11-06 15:31:15 -0800 | [diff] [blame] | 519 | SHA384_DIGEST_LENGTH, /* max tag length */ |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 520 | NULL, /* init */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 521 | aead_aes_256_cbc_sha384_tls_init, |
| 522 | aead_tls_cleanup, |
| 523 | aead_tls_seal, |
| 524 | aead_tls_open, |
Adam Langley | fad6327 | 2015-11-12 12:15:39 -0800 | [diff] [blame] | 525 | NULL, /* get_iv */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 526 | }; |
| 527 | |
| 528 | static const EVP_AEAD aead_des_ede3_cbc_sha1_tls = { |
| 529 | SHA_DIGEST_LENGTH + 24, /* key len (SHA1 + 3DES) */ |
| 530 | 8, /* nonce len (IV) */ |
| 531 | 8 + SHA_DIGEST_LENGTH, /* overhead (padding + SHA1) */ |
| 532 | SHA_DIGEST_LENGTH, /* max tag length */ |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 533 | NULL, /* init */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 534 | aead_des_ede3_cbc_sha1_tls_init, |
| 535 | aead_tls_cleanup, |
| 536 | aead_tls_seal, |
| 537 | aead_tls_open, |
Adam Langley | fad6327 | 2015-11-12 12:15:39 -0800 | [diff] [blame] | 538 | NULL, /* get_iv */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 539 | }; |
| 540 | |
| 541 | static const EVP_AEAD aead_des_ede3_cbc_sha1_tls_implicit_iv = { |
| 542 | SHA_DIGEST_LENGTH + 24 + 8, /* key len (SHA1 + 3DES + IV) */ |
| 543 | 0, /* nonce len */ |
| 544 | 8 + SHA_DIGEST_LENGTH, /* overhead (padding + SHA1) */ |
| 545 | SHA_DIGEST_LENGTH, /* max tag length */ |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 546 | NULL, /* init */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 547 | aead_des_ede3_cbc_sha1_tls_implicit_iv_init, |
| 548 | aead_tls_cleanup, |
| 549 | aead_tls_seal, |
| 550 | aead_tls_open, |
Adam Langley | fad6327 | 2015-11-12 12:15:39 -0800 | [diff] [blame] | 551 | aead_tls_get_iv, /* get_iv */ |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 552 | }; |
| 553 | |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 554 | static const EVP_AEAD aead_null_sha1_tls = { |
| 555 | SHA_DIGEST_LENGTH, /* key len */ |
| 556 | 0, /* nonce len */ |
| 557 | SHA_DIGEST_LENGTH, /* overhead (SHA1) */ |
| 558 | SHA_DIGEST_LENGTH, /* max tag length */ |
| 559 | NULL, /* init */ |
| 560 | aead_null_sha1_tls_init, |
| 561 | aead_tls_cleanup, |
| 562 | aead_tls_seal, |
| 563 | aead_tls_open, |
Adam Langley | fad6327 | 2015-11-12 12:15:39 -0800 | [diff] [blame] | 564 | NULL, /* get_iv */ |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 565 | }; |
| 566 | |
Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 567 | const EVP_AEAD *EVP_aead_aes_128_cbc_sha1_tls(void) { |
| 568 | return &aead_aes_128_cbc_sha1_tls; |
| 569 | } |
| 570 | |
| 571 | const EVP_AEAD *EVP_aead_aes_128_cbc_sha1_tls_implicit_iv(void) { |
| 572 | return &aead_aes_128_cbc_sha1_tls_implicit_iv; |
| 573 | } |
| 574 | |
| 575 | const EVP_AEAD *EVP_aead_aes_128_cbc_sha256_tls(void) { |
| 576 | return &aead_aes_128_cbc_sha256_tls; |
| 577 | } |
| 578 | |
| 579 | const EVP_AEAD *EVP_aead_aes_256_cbc_sha1_tls(void) { |
| 580 | return &aead_aes_256_cbc_sha1_tls; |
| 581 | } |
| 582 | |
| 583 | const EVP_AEAD *EVP_aead_aes_256_cbc_sha1_tls_implicit_iv(void) { |
| 584 | return &aead_aes_256_cbc_sha1_tls_implicit_iv; |
| 585 | } |
| 586 | |
| 587 | const EVP_AEAD *EVP_aead_aes_256_cbc_sha256_tls(void) { |
| 588 | return &aead_aes_256_cbc_sha256_tls; |
| 589 | } |
| 590 | |
| 591 | const EVP_AEAD *EVP_aead_aes_256_cbc_sha384_tls(void) { |
| 592 | return &aead_aes_256_cbc_sha384_tls; |
| 593 | } |
| 594 | |
| 595 | const EVP_AEAD *EVP_aead_des_ede3_cbc_sha1_tls(void) { |
| 596 | return &aead_des_ede3_cbc_sha1_tls; |
| 597 | } |
| 598 | |
| 599 | const EVP_AEAD *EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv(void) { |
| 600 | return &aead_des_ede3_cbc_sha1_tls_implicit_iv; |
| 601 | } |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 602 | |
| 603 | const EVP_AEAD *EVP_aead_null_sha1_tls(void) { return &aead_null_sha1_tls; } |