OLD | NEW |
---|---|
1 /* | 1 /* |
2 * aes_gcm_ossl.c | 2 * aes_gcm_ossl.c |
3 * | 3 * |
4 * AES Galois Counter Mode | 4 * AES Galois Counter Mode |
5 * | 5 * |
6 * John A. Foley | 6 * John A. Foley |
7 * Cisco Systems, Inc. | 7 * Cisco Systems, Inc. |
8 * | 8 * |
9 */ | 9 */ |
10 | 10 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 */ | 260 */ |
261 err_status_t aes_gcm_openssl_set_aad (aes_gcm_ctx_t *c, unsigned char *aad, | 261 err_status_t aes_gcm_openssl_set_aad (aes_gcm_ctx_t *c, unsigned char *aad, |
262 unsigned int aad_len) | 262 unsigned int aad_len) |
263 { | 263 { |
264 int rv; | 264 int rv; |
265 | 265 |
266 /* | 266 /* |
267 * Set dummy tag, OpenSSL requires the Tag to be set before | 267 * Set dummy tag, OpenSSL requires the Tag to be set before |
268 * processing AAD | 268 * processing AAD |
269 */ | 269 */ |
270 EVP_CIPHER_CTX_ctrl(&c->ctx, EVP_CTRL_GCM_SET_TAG, c->tag_len, aad); | 270 unsigned char dummy_tag[GCM_AUTH_TAG_LEN]; |
271 memset(dummy_tag, 0x0, GCM_AUTH_TAG_LEN); | |
272 EVP_CIPHER_CTX_ctrl(&c->ctx, EVP_CTRL_GCM_SET_TAG, c->tag_len, &dummy_tag); | |
tommi
2016/07/26 08:47:14
does sizeof(dummy_tag) have to match c->tag_len?
joachim
2016/07/26 09:08:38
Yes, but it has to be between 1 and 16 bytes (see
tommi
2016/07/26 09:45:09
Acknowledged.
| |
271 | 273 |
272 rv = EVP_Cipher(&c->ctx, NULL, aad, aad_len); | 274 rv = EVP_Cipher(&c->ctx, NULL, aad, aad_len); |
273 if (rv != aad_len) { | 275 if (rv != aad_len) { |
274 return (err_status_algo_fail); | 276 return (err_status_algo_fail); |
275 } else { | 277 } else { |
276 return (err_status_ok); | 278 return (err_status_ok); |
277 } | 279 } |
278 } | 280 } |
279 | 281 |
280 /* | 282 /* |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
561 (cipher_decrypt_func_t) aes_gcm_openssl_decrypt, | 563 (cipher_decrypt_func_t) aes_gcm_openssl_decrypt, |
562 (cipher_set_iv_func_t) aes_gcm_openssl_set_iv, | 564 (cipher_set_iv_func_t) aes_gcm_openssl_set_iv, |
563 (cipher_get_tag_func_t) aes_gcm_openssl_get_tag, | 565 (cipher_get_tag_func_t) aes_gcm_openssl_get_tag, |
564 (char*) aes_gcm_256_openssl_description, | 566 (char*) aes_gcm_256_openssl_description, |
565 (int) 0, /* instance count */ | 567 (int) 0, /* instance count */ |
566 (cipher_test_case_t*) &aes_gcm_test_case_1, | 568 (cipher_test_case_t*) &aes_gcm_test_case_1, |
567 (debug_module_t*) &mod_aes_gcm, | 569 (debug_module_t*) &mod_aes_gcm, |
568 (cipher_type_id_t) AES_256_GCM | 570 (cipher_type_id_t) AES_256_GCM |
569 }; | 571 }; |
570 | 572 |
OLD | NEW |