Branch data Line data Source code
1 : : /*
2 : : * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 : : *
4 : : * Licensed under the Apache License, Version 2.0 (the "License").
5 : : * You may not use this file except in compliance with the License.
6 : : * A copy of the License is located at
7 : : *
8 : : * http://aws.amazon.com/apache2.0
9 : : *
10 : : * or in the "license" file accompanying this file. This file is distributed
11 : : * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 : : * express or implied. See the License for the specific language governing
13 : : * permissions and limitations under the License.
14 : : */
15 : :
16 : : #include <openssl/aes.h>
17 : : #include <openssl/evp.h>
18 : : #include <openssl/sha.h>
19 : :
20 : : #include "crypto/s2n_cipher.h"
21 : : #include "crypto/s2n_fips.h"
22 : : #include "crypto/s2n_openssl.h"
23 : : #include "tls/s2n_crypto.h"
24 : : #include "utils/s2n_blob.h"
25 : : #include "utils/s2n_safety.h"
26 : :
27 : : /* LibreSSL and BoringSSL support the cipher, but the interface is different from Openssl's. We
28 : : * should define a separate s2n_cipher struct for LibreSSL and BoringSSL.
29 : : */
30 : : #if !defined(LIBRESSL_VERSION_NUMBER) && !defined(OPENSSL_IS_BORINGSSL)
31 : : /* Symbols for AES-SHA1-CBC composite ciphers were added in Openssl 1.0.1
32 : : * These composite ciphers exhibit erratic behavior in LibreSSL releases.
33 : : */
34 : : #if S2N_OPENSSL_VERSION_AT_LEAST(1, 0, 1)
35 : : #define S2N_AES_SHA1_COMPOSITE_AVAILABLE
36 : : #endif
37 : : #if defined(AWSLC_API_VERSION) && (AWSLC_API_VERSION <= 17)
38 : : #undef S2N_AES_SHA1_COMPOSITE_AVAILABLE
39 : : #endif
40 : : /* Symbols for AES-SHA256-CBC composite ciphers were added in Openssl 1.0.2
41 : : * See https://www.openssl.org/news/cl102.txt
42 : : * These composite ciphers exhibit erratic behavior in LibreSSL releases.
43 : : */
44 : : #if S2N_OPENSSL_VERSION_AT_LEAST(1, 0, 2)
45 : : #define S2N_AES_SHA256_COMPOSITE_AVAILABLE
46 : : #endif
47 : : #if defined(AWSLC_API_VERSION) && (AWSLC_API_VERSION <= 17)
48 : : #undef S2N_AES_SHA256_COMPOSITE_AVAILABLE
49 : : #endif
50 : : #endif
51 : :
52 : : /* Silly accessors, but we avoid using version macro guards in multiple places */
53 : : static const EVP_CIPHER *s2n_evp_aes_128_cbc_hmac_sha1(void)
54 : 50656 : {
55 : 50656 : #if defined(S2N_AES_SHA1_COMPOSITE_AVAILABLE)
56 : 50656 : return EVP_aes_128_cbc_hmac_sha1();
57 : : #else
58 : : return NULL;
59 : : #endif
60 : 50656 : }
61 : :
62 : : static const EVP_CIPHER *s2n_evp_aes_256_cbc_hmac_sha1(void)
63 : 50387 : {
64 : 50387 : #if defined(S2N_AES_SHA1_COMPOSITE_AVAILABLE)
65 : 50387 : return EVP_aes_256_cbc_hmac_sha1();
66 : : #else
67 : : return NULL;
68 : : #endif
69 : 50387 : }
70 : :
71 : : static const EVP_CIPHER *s2n_evp_aes_128_cbc_hmac_sha256(void)
72 : 50236 : {
73 : 50236 : #if defined(S2N_AES_SHA256_COMPOSITE_AVAILABLE)
74 : 50236 : return EVP_aes_128_cbc_hmac_sha256();
75 : : #else
76 : : return NULL;
77 : : #endif
78 : 50236 : }
79 : :
80 : : static const EVP_CIPHER *s2n_evp_aes_256_cbc_hmac_sha256(void)
81 : 49299 : {
82 : 49299 : #if defined(S2N_AES_SHA256_COMPOSITE_AVAILABLE)
83 : 49299 : return EVP_aes_256_cbc_hmac_sha256();
84 : : #else
85 : : return NULL;
86 : : #endif
87 : 49299 : }
88 : :
89 : : static bool s2n_composite_cipher_aes128_sha_available(void)
90 : 1402 : {
91 : : /* EVP_aes_128_cbc_hmac_sha1() returns NULL if the implementations aren't available.
92 : : * See https://github.com/openssl/openssl/blob/master/crypto/evp/e_aes_cbc_hmac_sha1.c#L952
93 : : *
94 : : * Composite ciphers cannot be used when FIPS mode is set. Ciphers require the
95 : : * EVP_CIPH_FLAG_FIPS OpenSSL flag to be set for use when in FIPS mode, and composite
96 : : * ciphers cause OpenSSL errors due to the lack of the flag.
97 : : */
98 [ + - ][ + - ]: 1402 : return (!s2n_is_in_fips_mode() && s2n_evp_aes_128_cbc_hmac_sha1() ? true : false);
99 : 1402 : }
100 : :
101 : : static bool s2n_composite_cipher_aes256_sha_available(void)
102 : 1401 : {
103 : : /* Composite ciphers cannot be used when FIPS mode is set. Ciphers require the
104 : : * EVP_CIPH_FLAG_FIPS OpenSSL flag to be set for use when in FIPS mode, and composite
105 : : * ciphers cause OpenSSL errors due to the lack of the flag.
106 : : */
107 [ + - ][ + - ]: 1401 : return (!s2n_is_in_fips_mode() && s2n_evp_aes_256_cbc_hmac_sha1() ? true : false);
108 : 1401 : }
109 : :
110 : : static bool s2n_composite_cipher_aes128_sha256_available(void)
111 : 1402 : {
112 : : /* Composite ciphers cannot be used when FIPS mode is set. Ciphers require the
113 : : * EVP_CIPH_FLAG_FIPS OpenSSL flag to be set for use when in FIPS mode, and composite
114 : : * ciphers cause OpenSSL errors due to the lack of the flag.
115 : : */
116 [ + - ][ + - ]: 1402 : return (!s2n_is_in_fips_mode() && s2n_evp_aes_128_cbc_hmac_sha256() ? true : false);
117 : 1402 : }
118 : :
119 : : static bool s2n_composite_cipher_aes256_sha256_available(void)
120 : 701 : {
121 : : /* Composite ciphers cannot be used when FIPS mode is set. Ciphers require the
122 : : * EVP_CIPH_FLAG_FIPS OpenSSL flag to be set for use when in FIPS mode, and composite
123 : : * ciphers cause OpenSSL errors due to the lack of the flag.
124 : : */
125 [ + - ][ + - ]: 701 : return (!s2n_is_in_fips_mode() && s2n_evp_aes_256_cbc_hmac_sha256() ? true : false);
126 : 701 : }
127 : :
128 : : static int s2n_composite_cipher_aes_sha_initial_hmac(struct s2n_session_key *key, uint8_t *sequence_number, uint8_t content_type,
129 : : uint16_t protocol_version, uint16_t payload_and_eiv_len, int *extra)
130 : 271597 : {
131 : : /* BoringSSL and AWS-LC(AWSLC_API_VERSION <= 17) do not support these composite ciphers with the existing EVP API, and they took out the
132 : : * constants used below. This method should never be called with BoringSSL or AWS-LC(AWSLC_API_VERSION <= 17) because the isAvaliable checked
133 : : * will fail. Instead of defining a possibly dangerous default or hard coding this to 0x16 error out with BoringSSL and AWS-LC(AWSLC_API_VERSION <= 17).
134 : : */
135 : : #if defined(OPENSSL_IS_BORINGSSL) || (defined(AWSLC_API_VERSION) && (AWSLC_API_VERSION <= 17))
136 : : POSIX_BAIL(S2N_ERR_UNIMPLEMENTED);
137 : : #else
138 : 271597 : uint8_t ctrl_buf[S2N_TLS12_AAD_LEN] = { 0 };
139 : 271597 : struct s2n_blob ctrl_blob = { 0 };
140 [ - + ]: 271597 : POSIX_GUARD(s2n_blob_init(&ctrl_blob, ctrl_buf, S2N_TLS12_AAD_LEN));
141 : 271597 : struct s2n_stuffer ctrl_stuffer = { 0 };
142 [ - + ]: 271597 : POSIX_GUARD(s2n_stuffer_init(&ctrl_stuffer, &ctrl_blob));
143 : :
144 [ - + ]: 271597 : POSIX_GUARD(s2n_stuffer_write_bytes(&ctrl_stuffer, sequence_number, S2N_TLS_SEQUENCE_NUM_LEN));
145 [ - + ]: 271597 : POSIX_GUARD(s2n_stuffer_write_uint8(&ctrl_stuffer, content_type));
146 [ - + ]: 271597 : POSIX_GUARD(s2n_stuffer_write_uint16(&ctrl_stuffer, protocol_version));
147 [ - + ]: 271597 : POSIX_GUARD(s2n_stuffer_write_uint16(&ctrl_stuffer, payload_and_eiv_len));
148 : :
149 : : /* This will unnecessarily mangle the input buffer, which is fine since it's temporary
150 : : * Return value will be length of digest, padding, and padding length byte.
151 : : * See https://github.com/openssl/openssl/blob/master/crypto/evp/e_aes_cbc_hmac_sha1.c#L814
152 : : * and https://github.com/openssl/openssl/blob/4f0c475719defd7c051964ef9964cc6e5b3a63bf/ssl/record/ssl3_record.c#L743
153 : : */
154 : 271597 : int ctrl_ret = EVP_CIPHER_CTX_ctrl(key->evp_cipher_ctx, EVP_CTRL_AEAD_TLS1_AAD, S2N_TLS12_AAD_LEN, ctrl_buf);
155 : :
156 [ - + ][ # # ]: 271597 : S2N_ERROR_IF(ctrl_ret <= 0, S2N_ERR_INITIAL_HMAC);
157 : :
158 : 271597 : *extra = ctrl_ret;
159 : 271597 : return 0;
160 : 271597 : #endif
161 : 271597 : }
162 : :
163 : : static int s2n_composite_cipher_aes_sha_encrypt(struct s2n_session_key *key, struct s2n_blob *iv, struct s2n_blob *in, struct s2n_blob *out)
164 : 163985 : {
165 [ # # ][ - + ]: 163985 : POSIX_ENSURE_EQ(out->size, in->size);
166 : :
167 [ - + ][ # # ]: 163985 : POSIX_GUARD_OSSL(EVP_EncryptInit_ex(key->evp_cipher_ctx, NULL, NULL, NULL, iv->data), S2N_ERR_KEY_INIT);
168 : :
169 : : /* len is set by EVP_EncryptUpdate and checked post operation */
170 : 163985 : int len = 0;
171 [ - + ][ # # ]: 163985 : POSIX_GUARD_OSSL(EVP_EncryptUpdate(key->evp_cipher_ctx, out->data, &len, in->data, in->size), S2N_ERR_ENCRYPT);
172 : :
173 [ - + ][ # # ]: 163985 : POSIX_ENSURE((int64_t) len == (int64_t) in->size, S2N_ERR_ENCRYPT);
174 : :
175 : 163985 : return 0;
176 : 163985 : }
177 : :
178 : : static int s2n_composite_cipher_aes_sha_decrypt(struct s2n_session_key *key, struct s2n_blob *iv, struct s2n_blob *in, struct s2n_blob *out)
179 : 107612 : {
180 [ - + ][ # # ]: 107612 : POSIX_ENSURE_EQ(out->size, in->size);
181 [ # # ][ - + ]: 107612 : POSIX_GUARD_OSSL(EVP_DecryptInit_ex(key->evp_cipher_ctx, NULL, NULL, NULL, iv->data), S2N_ERR_KEY_INIT);
182 : :
183 : 107612 : int len = 0;
184 [ # # ][ - + ]: 107612 : POSIX_GUARD_OSSL(EVP_DecryptUpdate(key->evp_cipher_ctx, out->data, &len, in->data, in->size), S2N_ERR_DECRYPT);
185 [ # # ][ - + ]: 107612 : POSIX_ENSURE((int64_t) len == (int64_t) in->size, S2N_ERR_DECRYPT);
186 : :
187 : 107612 : return 0;
188 : 107612 : }
189 : :
190 : : static int s2n_composite_cipher_aes_sha_set_mac_write_key(struct s2n_session_key *key, uint8_t *mac_key, uint32_t mac_size)
191 : 98240 : {
192 [ # # ][ - + ]: 98240 : POSIX_ENSURE_EQ(mac_size, SHA_DIGEST_LENGTH);
193 : :
194 : : /* This ctrl returns 1 on success, unlike EVP_CTRL_AEAD_TLS1_AAD, which returns a length. */
195 [ - + ][ # # ]: 98240 : POSIX_GUARD_OSSL(EVP_CIPHER_CTX_ctrl(key->evp_cipher_ctx, EVP_CTRL_AEAD_SET_MAC_KEY, mac_size, mac_key), S2N_ERR_KEY_INIT);
196 : :
197 : 98240 : return 0;
198 : 98240 : }
199 : :
200 : : static int s2n_composite_cipher_aes_sha256_set_mac_write_key(struct s2n_session_key *key, uint8_t *mac_key, uint32_t mac_size)
201 : 97432 : {
202 [ - + ][ # # ]: 97432 : POSIX_ENSURE_EQ(mac_size, SHA256_DIGEST_LENGTH);
203 : :
204 : : /* This ctrl returns 1 on success, unlike EVP_CTRL_AEAD_TLS1_AAD, which returns a length. */
205 [ # # ][ - + ]: 97432 : POSIX_GUARD_OSSL(EVP_CIPHER_CTX_ctrl(key->evp_cipher_ctx, EVP_CTRL_AEAD_SET_MAC_KEY, mac_size, mac_key), S2N_ERR_KEY_INIT);
206 : :
207 : 97432 : return 0;
208 : 97432 : }
209 : :
210 : : static S2N_RESULT s2n_composite_cipher_aes128_sha_set_encryption_key(struct s2n_session_key *key, struct s2n_blob *in)
211 : 24627 : {
212 [ - + ][ # # ]: 24627 : RESULT_ENSURE_EQ(in->size, 16);
213 : :
214 [ - + ][ # # ]: 24627 : RESULT_GUARD_OSSL(EVP_EncryptInit_ex(key->evp_cipher_ctx, s2n_evp_aes_128_cbc_hmac_sha1(), NULL, in->data, NULL), S2N_ERR_KEY_INIT);
215 : : /* Padding must be disabled after key init to take effect. */
216 [ # # ][ - + ]: 24627 : RESULT_GUARD_OSSL(EVP_CIPHER_CTX_set_padding(key->evp_cipher_ctx, 0), S2N_ERR_KEY_INIT);
217 : :
218 : 24627 : return S2N_RESULT_OK;
219 : 24627 : }
220 : :
221 : : static S2N_RESULT s2n_composite_cipher_aes128_sha_set_decryption_key(struct s2n_session_key *key, struct s2n_blob *in)
222 : 24627 : {
223 [ - + ][ # # ]: 24627 : RESULT_ENSURE_EQ(in->size, 16);
224 : :
225 [ - + ][ # # ]: 24627 : RESULT_GUARD_OSSL(EVP_DecryptInit_ex(key->evp_cipher_ctx, s2n_evp_aes_128_cbc_hmac_sha1(), NULL, in->data, NULL), S2N_ERR_KEY_INIT);
226 : : /* Padding must be disabled after key init to take effect. */
227 [ - + ][ # # ]: 24627 : RESULT_GUARD_OSSL(EVP_CIPHER_CTX_set_padding(key->evp_cipher_ctx, 0), S2N_ERR_KEY_INIT);
228 : :
229 : 24627 : return S2N_RESULT_OK;
230 : 24627 : }
231 : :
232 : : static S2N_RESULT s2n_composite_cipher_aes256_sha_set_encryption_key(struct s2n_session_key *key, struct s2n_blob *in)
233 : 24493 : {
234 [ # # ][ - + ]: 24493 : RESULT_ENSURE_EQ(in->size, 32);
235 : :
236 [ # # ][ - + ]: 24493 : RESULT_GUARD_OSSL(EVP_EncryptInit_ex(key->evp_cipher_ctx, s2n_evp_aes_256_cbc_hmac_sha1(), NULL, in->data, NULL), S2N_ERR_KEY_INIT);
237 : : /* Padding must be disabled after key init to take effect. */
238 [ - + ][ # # ]: 24493 : RESULT_GUARD_OSSL(EVP_CIPHER_CTX_set_padding(key->evp_cipher_ctx, 0), S2N_ERR_KEY_INIT);
239 : :
240 : 24493 : return S2N_RESULT_OK;
241 : 24493 : }
242 : :
243 : : static S2N_RESULT s2n_composite_cipher_aes256_sha_set_decryption_key(struct s2n_session_key *key, struct s2n_blob *in)
244 : 24493 : {
245 [ # # ][ - + ]: 24493 : RESULT_ENSURE_EQ(in->size, 32);
246 : :
247 [ - + ][ # # ]: 24493 : RESULT_GUARD_OSSL(EVP_DecryptInit_ex(key->evp_cipher_ctx, s2n_evp_aes_256_cbc_hmac_sha1(), NULL, in->data, NULL), S2N_ERR_KEY_INIT);
248 : : /* Padding must be disabled after key init to take effect. */
249 [ - + ][ # # ]: 24493 : RESULT_GUARD_OSSL(EVP_CIPHER_CTX_set_padding(key->evp_cipher_ctx, 0), S2N_ERR_KEY_INIT);
250 : :
251 : 24493 : return S2N_RESULT_OK;
252 : 24493 : }
253 : :
254 : : static S2N_RESULT s2n_composite_cipher_aes128_sha256_set_encryption_key(struct s2n_session_key *key, struct s2n_blob *in)
255 : 24417 : {
256 [ - + ][ # # ]: 24417 : RESULT_ENSURE_EQ(in->size, 16);
257 : :
258 [ # # ][ - + ]: 24417 : RESULT_GUARD_OSSL(EVP_EncryptInit_ex(key->evp_cipher_ctx, s2n_evp_aes_128_cbc_hmac_sha256(), NULL, in->data, NULL), S2N_ERR_KEY_INIT);
259 : : /* Padding must be disabled after key init to take effect. */
260 [ - + ][ # # ]: 24417 : RESULT_GUARD_OSSL(EVP_CIPHER_CTX_set_padding(key->evp_cipher_ctx, 0), S2N_ERR_KEY_INIT);
261 : :
262 : 24417 : return S2N_RESULT_OK;
263 : 24417 : }
264 : :
265 : : static S2N_RESULT s2n_composite_cipher_aes128_sha256_set_decryption_key(struct s2n_session_key *key, struct s2n_blob *in)
266 : 24417 : {
267 [ - + ][ # # ]: 24417 : RESULT_ENSURE_EQ(in->size, 16);
268 : :
269 [ # # ][ - + ]: 24417 : RESULT_GUARD_OSSL(EVP_DecryptInit_ex(key->evp_cipher_ctx, s2n_evp_aes_128_cbc_hmac_sha256(), NULL, in->data, NULL), S2N_ERR_KEY_INIT);
270 : : /* Padding must be disabled after key init to take effect. */
271 [ # # ][ - + ]: 24417 : RESULT_GUARD_OSSL(EVP_CIPHER_CTX_set_padding(key->evp_cipher_ctx, 0), S2N_ERR_KEY_INIT);
272 : :
273 : 24417 : return S2N_RESULT_OK;
274 : 24417 : }
275 : :
276 : : static S2N_RESULT s2n_composite_cipher_aes256_sha256_set_encryption_key(struct s2n_session_key *key, struct s2n_blob *in)
277 : 24299 : {
278 [ - + ][ # # ]: 24299 : RESULT_ENSURE_EQ(in->size, 32);
279 : :
280 [ # # ][ - + ]: 24299 : RESULT_GUARD_OSSL(EVP_EncryptInit_ex(key->evp_cipher_ctx, s2n_evp_aes_256_cbc_hmac_sha256(), NULL, in->data, NULL), S2N_ERR_KEY_INIT);
281 : : /* Padding must be disabled after key init to take effect. */
282 [ - + ][ # # ]: 24299 : RESULT_GUARD_OSSL(EVP_CIPHER_CTX_set_padding(key->evp_cipher_ctx, 0), S2N_ERR_KEY_INIT);
283 : :
284 : 24299 : return S2N_RESULT_OK;
285 : 24299 : }
286 : :
287 : : static S2N_RESULT s2n_composite_cipher_aes256_sha256_set_decryption_key(struct s2n_session_key *key, struct s2n_blob *in)
288 : 24299 : {
289 [ - + ][ # # ]: 24299 : RESULT_ENSURE_EQ(in->size, 32);
290 : :
291 [ # # ][ - + ]: 24299 : RESULT_GUARD_OSSL(EVP_DecryptInit_ex(key->evp_cipher_ctx, s2n_evp_aes_256_cbc_hmac_sha256(), NULL, in->data, NULL), S2N_ERR_KEY_INIT);
292 : : /* Padding must be disabled after key init to take effect. */
293 [ # # ][ - + ]: 24299 : RESULT_GUARD_OSSL(EVP_CIPHER_CTX_set_padding(key->evp_cipher_ctx, 0), S2N_ERR_KEY_INIT);
294 : :
295 : 24299 : return S2N_RESULT_OK;
296 : 24299 : }
297 : :
298 : : static S2N_RESULT s2n_composite_cipher_aes_sha_init(struct s2n_session_key *key)
299 : 1540 : {
300 [ # # ][ - + ]: 1540 : RESULT_EVP_CTX_INIT(key->evp_cipher_ctx);
301 : :
302 : 1540 : return S2N_RESULT_OK;
303 : 1540 : }
304 : :
305 : : static S2N_RESULT s2n_composite_cipher_aes_sha_destroy_key(struct s2n_session_key *key)
306 : 388342 : {
307 : 388342 : EVP_CIPHER_CTX_cleanup(key->evp_cipher_ctx);
308 : :
309 : 388342 : return S2N_RESULT_OK;
310 : 388342 : }
311 : :
312 : : const struct s2n_cipher s2n_aes128_sha = {
313 : : .key_material_size = 16,
314 : : .type = S2N_COMPOSITE,
315 : : .io.comp = {
316 : : .block_size = 16,
317 : : .record_iv_size = 16,
318 : : .mac_key_size = SHA_DIGEST_LENGTH,
319 : : .decrypt = s2n_composite_cipher_aes_sha_decrypt,
320 : : .encrypt = s2n_composite_cipher_aes_sha_encrypt,
321 : : .set_mac_write_key = s2n_composite_cipher_aes_sha_set_mac_write_key,
322 : : .initial_hmac = s2n_composite_cipher_aes_sha_initial_hmac },
323 : : .is_available = s2n_composite_cipher_aes128_sha_available,
324 : : .init = s2n_composite_cipher_aes_sha_init,
325 : : .set_encryption_key = s2n_composite_cipher_aes128_sha_set_encryption_key,
326 : : .set_decryption_key = s2n_composite_cipher_aes128_sha_set_decryption_key,
327 : : .destroy_key = s2n_composite_cipher_aes_sha_destroy_key,
328 : : };
329 : :
330 : : const struct s2n_cipher s2n_aes256_sha = {
331 : : .key_material_size = 32,
332 : : .type = S2N_COMPOSITE,
333 : : .io.comp = {
334 : : .block_size = 16,
335 : : .record_iv_size = 16,
336 : : .mac_key_size = SHA_DIGEST_LENGTH,
337 : : .decrypt = s2n_composite_cipher_aes_sha_decrypt,
338 : : .encrypt = s2n_composite_cipher_aes_sha_encrypt,
339 : : .set_mac_write_key = s2n_composite_cipher_aes_sha_set_mac_write_key,
340 : : .initial_hmac = s2n_composite_cipher_aes_sha_initial_hmac },
341 : : .is_available = s2n_composite_cipher_aes256_sha_available,
342 : : .init = s2n_composite_cipher_aes_sha_init,
343 : : .set_encryption_key = s2n_composite_cipher_aes256_sha_set_encryption_key,
344 : : .set_decryption_key = s2n_composite_cipher_aes256_sha_set_decryption_key,
345 : : .destroy_key = s2n_composite_cipher_aes_sha_destroy_key,
346 : : };
347 : :
348 : : const struct s2n_cipher s2n_aes128_sha256 = {
349 : : .key_material_size = 16,
350 : : .type = S2N_COMPOSITE,
351 : : .io.comp = {
352 : : .block_size = 16,
353 : : .record_iv_size = 16,
354 : : .mac_key_size = SHA256_DIGEST_LENGTH,
355 : : .decrypt = s2n_composite_cipher_aes_sha_decrypt,
356 : : .encrypt = s2n_composite_cipher_aes_sha_encrypt,
357 : : .set_mac_write_key = s2n_composite_cipher_aes_sha256_set_mac_write_key,
358 : : .initial_hmac = s2n_composite_cipher_aes_sha_initial_hmac },
359 : : .is_available = s2n_composite_cipher_aes128_sha256_available,
360 : : .init = s2n_composite_cipher_aes_sha_init,
361 : : .set_encryption_key = s2n_composite_cipher_aes128_sha256_set_encryption_key,
362 : : .set_decryption_key = s2n_composite_cipher_aes128_sha256_set_decryption_key,
363 : : .destroy_key = s2n_composite_cipher_aes_sha_destroy_key,
364 : : };
365 : :
366 : : const struct s2n_cipher s2n_aes256_sha256 = {
367 : : .key_material_size = 32,
368 : : .type = S2N_COMPOSITE,
369 : : .io.comp = {
370 : : .block_size = 16,
371 : : .record_iv_size = 16,
372 : : .mac_key_size = SHA256_DIGEST_LENGTH,
373 : : .decrypt = s2n_composite_cipher_aes_sha_decrypt,
374 : : .encrypt = s2n_composite_cipher_aes_sha_encrypt,
375 : : .set_mac_write_key = s2n_composite_cipher_aes_sha256_set_mac_write_key,
376 : : .initial_hmac = s2n_composite_cipher_aes_sha_initial_hmac },
377 : : .is_available = s2n_composite_cipher_aes256_sha256_available,
378 : : .init = s2n_composite_cipher_aes_sha_init,
379 : : .set_encryption_key = s2n_composite_cipher_aes256_sha256_set_encryption_key,
380 : : .set_decryption_key = s2n_composite_cipher_aes256_sha256_set_decryption_key,
381 : : .destroy_key = s2n_composite_cipher_aes_sha_destroy_key,
382 : : };
|