aboutsummaryrefslogtreecommitdiff
path: root/sys/opencrypto
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2023-07-27 19:44:52 +0000
committerMark Johnston <markj@FreeBSD.org>2023-07-27 19:44:52 +0000
commit96c2538121390c872f68ac48f97b35fb973c11dc (patch)
tree0df275f3df8dfeeadc534b561ddf86942323a578 /sys/opencrypto
parent1be56e0bb1e8bd8373e446ff9386bcdd764935aa (diff)
downloadsrc-96c2538121390c872f68ac48f97b35fb973c11dc.tar.gz
src-96c2538121390c872f68ac48f97b35fb973c11dc.zip
Diffstat (limited to 'sys/opencrypto')
-rw-r--r--sys/opencrypto/cbc_mac.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/sys/opencrypto/cbc_mac.c b/sys/opencrypto/cbc_mac.c
index 9a030cd54173..cfba24eeab31 100644
--- a/sys/opencrypto/cbc_mac.c
+++ b/sys/opencrypto/cbc_mac.c
@@ -40,19 +40,16 @@ static void
xor_and_encrypt(struct aes_cbc_mac_ctx *ctx,
const uint8_t *src, uint8_t *dst)
{
- const uint64_t *b1;
- uint64_t *b2;
- uint64_t temp_block[CCM_CBC_BLOCK_LEN/sizeof(uint64_t)];
+#define NWORDS (CCM_CBC_BLOCK_LEN / sizeof(uint64_t))
+ uint64_t b1[NWORDS], b2[NWORDS], temp[NWORDS];
- b1 = (const uint64_t*)src;
- b2 = (uint64_t*)dst;
+ memcpy(b1, src, CCM_CBC_BLOCK_LEN);
+ memcpy(b2, dst, CCM_CBC_BLOCK_LEN);
- for (size_t count = 0;
- count < CCM_CBC_BLOCK_LEN/sizeof(uint64_t);
- count++) {
- temp_block[count] = b1[count] ^ b2[count];
- }
- rijndaelEncrypt(ctx->keysched, ctx->rounds, (void*)temp_block, dst);
+ for (size_t count = 0; count < NWORDS; count++)
+ temp[count] = b1[count] ^ b2[count];
+ rijndaelEncrypt(ctx->keysched, ctx->rounds, (void *)temp, dst);
+#undef NWORDS
}
void