From 2211759cc08779ad0bd1fd471db123eab5bc1457 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 8 Sep 2016 17:06:27 +1000 Subject: [PATCH] hwcrypto aes: Fix bugs w/ ECB decrypt, CFB modes --- components/esp32/hwcrypto/aes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/esp32/hwcrypto/aes.c b/components/esp32/hwcrypto/aes.c index e08486de28..169465822d 100644 --- a/components/esp32/hwcrypto/aes.c +++ b/components/esp32/hwcrypto/aes.c @@ -124,7 +124,7 @@ static inline int esp_aes_setkey_hardware( esp_aes_context *ctx, int mode) if ( mode == ESP_AES_ENCRYPT ) { ets_aes_setkey_enc(ctx->enc.key, ctx->enc.aesbits); } else { - ets_aes_setkey_dec(ctx->enc.key, ctx->enc.aesbits); + ets_aes_setkey_dec(ctx->dec.key, ctx->dec.aesbits); } return 0; } @@ -243,7 +243,7 @@ int esp_aes_crypt_cfb128( esp_aes_context *ctx, size_t n = *iv_off; esp_aes_acquire_hardware(); - esp_aes_setkey_hardware(ctx, mode); + esp_aes_setkey_hardware(ctx, ESP_AES_ENCRYPT); if ( mode == ESP_AES_DECRYPT ) { while ( length-- ) { @@ -290,7 +290,7 @@ int esp_aes_crypt_cfb8( esp_aes_context *ctx, unsigned char ov[17]; esp_aes_acquire_hardware(); - esp_aes_setkey_hardware(ctx, mode); + esp_aes_setkey_hardware(ctx, ESP_AES_ENCRYPT); while ( length-- ) { memcpy( ov, iv, 16 );