# ifndef OPENSSL_NO_OCB
typedef struct {
- AES_KEY ksenc; /* AES key schedule to use for encryption */
- AES_KEY ksdec; /* AES key schedule to use for decryption */
+ union {
+ double align;
+ AES_KEY ks;
+ } ksenc; /* AES key schedule to use for encryption */
+ union {
+ double align;
+ AES_KEY ks;
+ } ksdec; /* AES key schedule to use for decryption */
int key_set; /* Set if key initialised */
int iv_set; /* Set if an iv is set */
OCB128_CONTEXT ocb;
* needs both. We could possibly optimise to remove setting the
* decrypt for an encryption operation.
*/
- aesni_set_encrypt_key(key, ctx->key_len * 8, &octx->ksenc);
- aesni_set_decrypt_key(key, ctx->key_len * 8, &octx->ksdec);
- if (!CRYPTO_ocb128_init(&octx->ocb, &octx->ksenc, &octx->ksdec,
+ aesni_set_encrypt_key(key, ctx->key_len * 8, &octx->ksenc.ks);
+ aesni_set_decrypt_key(key, ctx->key_len * 8, &octx->ksdec.ks);
+ if (!CRYPTO_ocb128_init(&octx->ocb,
+ &octx->ksenc.ks, &octx->ksdec.ks,
(block128_f) aesni_encrypt,
(block128_f) aesni_decrypt))
return 0;
case 128:
xctx->stream = aes128_t4_xts_encrypt;
break;
-# if 0 /* not yet */
- case 192:
- xctx->stream = aes192_t4_xts_encrypt;
- break;
-# endif
case 256:
xctx->stream = aes256_t4_xts_encrypt;
break;
case 128:
xctx->stream = aes128_t4_xts_decrypt;
break;
-# if 0 /* not yet */
- case 192:
- xctx->stream = aes192_t4_xts_decrypt;
- break;
-# endif
case 256:
xctx->stream = aes256_t4_xts_decrypt;
break;
aes_t4_set_encrypt_key(key, bits, &cctx->ks.ks);
CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L,
&cctx->ks, (block128_f) aes_t4_encrypt);
-# if 0 /* not yet */
- switch (bits) {
- case 128:
- cctx->str = enc ? (ccm128_f) aes128_t4_ccm64_encrypt :
- (ccm128_f) ae128_t4_ccm64_decrypt;
- break;
- case 192:
- cctx->str = enc ? (ccm128_f) aes192_t4_ccm64_encrypt :
- (ccm128_f) ae192_t4_ccm64_decrypt;
- break;
- case 256:
- cctx->str = enc ? (ccm128_f) aes256_t4_ccm64_encrypt :
- (ccm128_f) ae256_t4_ccm64_decrypt;
- break;
- default:
- return 0;
- }
-# endif
+ cctx->str = NULL;
cctx->key_set = 1;
}
if (iv) {
* needs both. We could possibly optimise to remove setting the
* decrypt for an encryption operation.
*/
- aes_t4_set_encrypt_key(key, ctx->key_len * 8, &octx->ksenc);
- aes_t4_set_decrypt_key(key, ctx->key_len * 8, &octx->ksdec);
- if (!CRYPTO_ocb128_init(&octx->ocb, &octx->ksenc, &octx->ksdec,
+ aes_t4_set_encrypt_key(key, ctx->key_len * 8, &octx->ksenc.ks);
+ aes_t4_set_decrypt_key(key, ctx->key_len * 8, &octx->ksdec.ks);
+ if (!CRYPTO_ocb128_init(&octx->ocb,
+ &octx->ksenc.ks, &octx->ksdec.ks,
(block128_f) aes_t4_encrypt,
(block128_f) aes_t4_decrypt))
return 0;
gctx->tls_aad_len = -1;
return 1;
- case EVP_CTRL_GCM_SET_IVLEN:
+ case EVP_CTRL_AEAD_SET_IVLEN:
if (arg <= 0)
return 0;
/* Allocate memory for IV if needed */
gctx->ivlen = arg;
return 1;
- case EVP_CTRL_GCM_SET_TAG:
+ case EVP_CTRL_AEAD_SET_TAG:
if (arg <= 0 || arg > 16 || c->encrypt)
return 0;
memcpy(c->buf, ptr, arg);
gctx->taglen = arg;
return 1;
- case EVP_CTRL_GCM_GET_TAG:
+ case EVP_CTRL_AEAD_GET_TAG:
if (arg <= 0 || arg > 16 || !c->encrypt || gctx->taglen < 0)
return 0;
memcpy(ptr, c->buf, arg);
cctx->len_set = 0;
return 1;
- case EVP_CTRL_CCM_SET_IVLEN:
+ case EVP_CTRL_AEAD_SET_IVLEN:
arg = 15 - arg;
case EVP_CTRL_CCM_SET_L:
if (arg < 2 || arg > 8)
cctx->L = arg;
return 1;
- case EVP_CTRL_CCM_SET_TAG:
+ case EVP_CTRL_AEAD_SET_TAG:
if ((arg & 1) || arg < 4 || arg > 16)
return 0;
if ((c->encrypt && ptr) || (!c->encrypt && !ptr))
cctx->M = arg;
return 1;
- case EVP_CTRL_CCM_GET_TAG:
+ case EVP_CTRL_AEAD_GET_TAG:
if (!c->encrypt || !cctx->tag_set)
return 0;
if (!CRYPTO_ccm128_tag(&cctx->ccm, ptr, (size_t)arg))
octx->aad_buf_len = 0;
return 1;
- case EVP_CTRL_SET_IVLEN:
+ case EVP_CTRL_AEAD_SET_IVLEN:
/* IV len must be 1 to 15 */
if (arg <= 0 || arg > 15)
return 0;
octx->ivlen = arg;
return 1;
- case EVP_CTRL_OCB_SET_TAGLEN:
- /* Tag len must be 0 to 16 */
- if (arg < 0 || arg > 16)
- return 0;
-
- octx->taglen = arg;
- return 1;
+ case EVP_CTRL_AEAD_SET_TAG:
+ if (!ptr) {
+ /* Tag len must be 0 to 16 */
+ if (arg < 0 || arg > 16)
+ return 0;
- case EVP_CTRL_SET_TAG:
+ octx->taglen = arg;
+ return 1;
+ }
if (arg != octx->taglen || c->encrypt)
return 0;
memcpy(octx->tag, ptr, arg);
return 1;
- case EVP_CTRL_GET_TAG:
+ case EVP_CTRL_AEAD_GET_TAG:
if (arg != octx->taglen || !c->encrypt)
return 0;
newc = (EVP_CIPHER_CTX *)ptr;
new_octx = newc->cipher_data;
return CRYPTO_ocb128_copy_ctx(&new_octx->ocb, &octx->ocb,
- &new_octx->ksenc, &new_octx->ksdec);
+ &new_octx->ksenc.ks,
+ &new_octx->ksdec.ks);
default:
return -1;
*/
# ifdef VPAES_CAPABLE
if (VPAES_CAPABLE) {
- vpaes_set_encrypt_key(key, ctx->key_len * 8, &octx->ksenc);
- vpaes_set_decrypt_key(key, ctx->key_len * 8, &octx->ksdec);
- if (!CRYPTO_ocb128_init
- (&octx->ocb, &octx->ksenc, &octx->ksdec,
- (block128_f) vpaes_encrypt, (block128_f) vpaes_decrypt))
+ vpaes_set_encrypt_key(key, ctx->key_len * 8, &octx->ksenc.ks);
+ vpaes_set_decrypt_key(key, ctx->key_len * 8, &octx->ksdec.ks);
+ if (!CRYPTO_ocb128_init(&octx->ocb,
+ &octx->ksenc.ks, &octx->ksdec.ks,
+ (block128_f) vpaes_encrypt,
+ (block128_f) vpaes_decrypt))
return 0;
break;
}
# endif
- AES_set_encrypt_key(key, ctx->key_len * 8, &octx->ksenc);
- AES_set_decrypt_key(key, ctx->key_len * 8, &octx->ksdec);
- if (!CRYPTO_ocb128_init(&octx->ocb, &octx->ksenc, &octx->ksdec,
+ AES_set_encrypt_key(key, ctx->key_len * 8, &octx->ksenc.ks);
+ AES_set_decrypt_key(key, ctx->key_len * 8, &octx->ksdec.ks);
+ if (!CRYPTO_ocb128_init(&octx->ocb,
+ &octx->ksenc.ks, &octx->ksdec.ks,
(block128_f) AES_encrypt,
(block128_f) AES_decrypt))
return 0;