diff --git a/sys/crypto/aesni/aesni.c b/sys/crypto/aesni/aesni.c index 709d1558ee84..4debbae12c2b 100644 --- a/sys/crypto/aesni/aesni.c +++ b/sys/crypto/aesni/aesni.c @@ -560,8 +560,15 @@ aesni_cipher_setup(struct aesni_session *ses, const struct crypto_session_params *csp) { struct fpu_kern_ctx *ctx; + uint8_t *schedbase; int kt, ctxidx, error; + schedbase = (uint8_t *)roundup2((uintptr_t)ses->schedules, + AES_SCHED_ALIGN); + ses->enc_schedule = schedbase; + ses->dec_schedule = schedbase + AES_SCHED_LEN; + ses->xts_schedule = schedbase + AES_SCHED_LEN * 2; + switch (csp->csp_auth_alg) { case CRYPTO_SHA1_HMAC: ses->hmac = true; diff --git a/sys/crypto/aesni/aesni.h b/sys/crypto/aesni/aesni.h index ef1a6635f6ad..284bf6fba0fc 100644 --- a/sys/crypto/aesni/aesni.h +++ b/sys/crypto/aesni/aesni.h @@ -47,11 +47,13 @@ #define AES192_ROUNDS 12 #define AES256_ROUNDS 14 #define AES_SCHED_LEN ((AES256_ROUNDS + 1) * AES_BLOCK_LEN) +#define AES_SCHED_ALIGN 16 struct aesni_session { - uint8_t enc_schedule[AES_SCHED_LEN] __aligned(16); - uint8_t dec_schedule[AES_SCHED_LEN] __aligned(16); - uint8_t xts_schedule[AES_SCHED_LEN] __aligned(16); + uint8_t schedules[3 * AES_SCHED_LEN + AES_SCHED_ALIGN]; + uint8_t *enc_schedule; + uint8_t *dec_schedule; + uint8_t *xts_schedule; int rounds; /* uint8_t *ses_ictx; */ /* uint8_t *ses_octx; */