Skip to content

Instantly share code, notes, and snippets.

@ewust
Created February 7, 2014 22:20
Show Gist options
  • Save ewust/8873193 to your computer and use it in GitHub Desktop.
Save ewust/8873193 to your computer and use it in GitHub Desktop.
if (key)
{ do {
#ifdef BSAES_CAPABLE
if (BSAES_CAPABLE)
{
AES_set_encrypt_key(key,ctx->key_len*8,&gctx->ks);
CRYPTO_gcm128_init(&gctx->gcm,&gctx->ks,
(block128_f)AES_encrypt);
gctx->ctr = (ctr128_f)bsaes_ctr32_encrypt_blocks;
break;
}
else
#endif
#ifdef VPAES_CAPABLE
if (VPAES_CAPABLE)
{
vpaes_set_encrypt_key(key,ctx->key_len*8,&gctx->ks);
CRYPTO_gcm128_init(&gctx->gcm,&gctx->ks,
(block128_f)vpaes_encrypt);
gctx->ctr = NULL;
break;
}
else
#endif
(void)0; /* terminate potentially open 'else' */
AES_set_encrypt_key(key, ctx->key_len * 8, &gctx->ks);
CRYPTO_gcm128_init(&gctx->gcm, &gctx->ks, (block128_f)AES_encrypt);
#ifdef AES_CTR_ASM
gctx->ctr = (ctr128_f)AES_ctr32_encrypt;
#else
gctx->ctr = NULL;
#endif
} while (0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment