Changeset View
Changeset View
Standalone View
Standalone View
sys/opencrypto/cbc_mac.c
Show All 26 Lines | |||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/endian.h> | #include <sys/endian.h> | ||||
#include <opencrypto/cbc_mac.h> | #include <opencrypto/cbc_mac.h> | ||||
#include <opencrypto/xform_auth.h> | #include <opencrypto/xform_auth.h> | ||||
#include <crypto/openssl/arm/arm_arch.h> | |||||
/* | /* | ||||
* Given two CCM_CBC_BLOCK_LEN blocks, xor | * Given two CCM_CBC_BLOCK_LEN blocks, xor | ||||
* them into dst, and then encrypt dst. | * them into dst, and then encrypt dst. | ||||
*/ | */ | ||||
static void | static void | ||||
xor_and_encrypt(struct aes_cbc_mac_ctx *ctx, | xor_and_encrypt(struct aes_cbc_mac_ctx *ctx, | ||||
const uint8_t *src, uint8_t *dst) | const uint8_t *src, uint8_t *dst) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | AES_CBC_MAC_Update(void *vctx, const void *vdata, u_int length) | ||||
while (length != 0) { | while (length != 0) { | ||||
uint8_t *ptr; | uint8_t *ptr; | ||||
/* | /* | ||||
* If there is no partial block and the length is at | * If there is no partial block and the length is at | ||||
* least a full block, encrypt the full block without | * least a full block, encrypt the full block without | ||||
* copying to the staging block. | * copying to the staging block. | ||||
*/ | */ | ||||
if (!(OPENSSL_armcap_P & ARMV7_NEON)) { | |||||
if (ctx->blockIndex == 0 && length >= CCM_CBC_BLOCK_LEN) { | if (ctx->blockIndex == 0 && length >= CCM_CBC_BLOCK_LEN) { | ||||
xor_and_encrypt(ctx, data, ctx->block); | xor_and_encrypt(ctx, data, ctx->block); | ||||
length -= CCM_CBC_BLOCK_LEN; | length -= CCM_CBC_BLOCK_LEN; | ||||
data += CCM_CBC_BLOCK_LEN; | data += CCM_CBC_BLOCK_LEN; | ||||
continue; | continue; | ||||
} | } | ||||
} | |||||
copy_amt = MIN(sizeof(ctx->staging_block) - ctx->blockIndex, | copy_amt = MIN(sizeof(ctx->staging_block) - ctx->blockIndex, | ||||
length); | length); | ||||
ptr = ctx->staging_block + ctx->blockIndex; | ptr = ctx->staging_block + ctx->blockIndex; | ||||
bcopy(data, ptr, copy_amt); | bcopy(data, ptr, copy_amt); | ||||
data += copy_amt; | data += copy_amt; | ||||
ctx->blockIndex += copy_amt; | ctx->blockIndex += copy_amt; | ||||
length -= copy_amt; | length -= copy_amt; | ||||
if (ctx->blockIndex == sizeof(ctx->staging_block)) { | if (ctx->blockIndex == sizeof(ctx->staging_block)) { | ||||
Show All 35 Lines |