9
0
Fork 0

Fix issues when AES support was added for the STM32L1. From Juha Niskanen

This commit is contained in:
Gregory Nutt 2015-03-04 06:38:03 -06:00
parent 0cd4089665
commit d08b045f7b
4 changed files with 32 additions and 18 deletions

View File

@ -46,6 +46,7 @@
#include <nuttx/fs/fs.h>
#include <nuttx/syslog/ramlog.h>
#include <nuttx/syslog/syslog_console.h>
#include <nuttx/crypto/crypto.h>
#include <arch/board/board.h>
@ -196,14 +197,6 @@ void up_initialize(void)
devnull_register(); /* Standard /dev/null */
#endif
#if defined(CONFIG_CRYPTO)
up_cryptoinitialize();
#endif
#if defined(CONFIG_CRYPTO_CRYPTODEV)
devcrypto_register(); /* /dev/crypto */
#endif
#if defined(CONFIG_DEV_ZERO)
devzero_register(); /* Standard /dev/zero */
#endif
@ -228,6 +221,18 @@ void up_initialize(void)
ramlog_consoleinit();
#endif
/* Initialize the HW crypto and /dev/crypto */
#if defined(CONFIG_CRYPTO)
up_cryptoinitialize();
#endif
#if CONFIG_NFILE_DESCRIPTORS > 0
#if defined(CONFIG_CRYPTO_CRYPTODEV)
devcrypto_register();
#endif
#endif
/* Initialize the Random Number Generator (RNG) */
#ifdef CONFIG_DEV_RANDOM

View File

@ -54,6 +54,14 @@
#include "testmngr.h"
/*****************************************************************************
* Pre-processor Definitions
*****************************************************************************/
#ifndef ARRAY_SIZE
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
#if defined(CONFIG_CRYPTO_AES)
/****************************************************************************
@ -99,9 +107,15 @@ static int test_aes(void)
{
int i;
AES_CYPHER_TEST(AES_MODE_ECB, "ECB", AES_ENC_TEST_VECTORS, AES_DEC_TEST_VECTORS, aes_enc_tv_template, aes_dec_tv_template)
AES_CYPHER_TEST(AES_MODE_CBC, "CBC", AES_CBC_ENC_TEST_VECTORS, AES_CBC_DEC_TEST_VECTORS, aes_cbc_enc_tv_template, aes_cbc_dec_tv_template)
AES_CYPHER_TEST(AES_MODE_CTR, "CTR", AES_CTR_ENC_TEST_VECTORS, AES_CTR_DEC_TEST_VECTORS, aes_ctr_enc_tv_template, aes_ctr_dec_tv_template)
AES_CYPHER_TEST(AES_MODE_ECB, "ECB", ARRAY_SIZE(aes_enc_tv_template),
ARRAY_SIZE(aes_dec_tv_template), aes_enc_tv_template,
aes_dec_tv_template)
AES_CYPHER_TEST(AES_MODE_CBC, "CBC", ARRAY_SIZE(aes_cbc_enc_tv_template),
ARRAY_SIZE(aes_cbc_dec_tv_template),
aes_cbc_enc_tv_template, aes_cbc_dec_tv_template)
AES_CYPHER_TEST(AES_MODE_CTR, "CTR", ARRAY_SIZE(aes_ctr_enc_tv_template),
ARRAY_SIZE(aes_ctr_dec_tv_template),
aes_ctr_enc_tv_template, aes_ctr_dec_tv_template)
return OK;
}

View File

@ -64,13 +64,6 @@ struct cipher_testvec
/* AES test vectors */
#define AES_ENC_TEST_VECTORS 3
#define AES_DEC_TEST_VECTORS 3
#define AES_CBC_ENC_TEST_VECTORS 4
#define AES_CBC_DEC_TEST_VECTORS 4
#define AES_CTR_ENC_TEST_VECTORS 3
#define AES_CTR_DEC_TEST_VECTORS 3
static struct cipher_testvec aes_enc_tv_template[] =
{
#ifndef CONFIG_CRYPTO_AES128_DISABLE

View File

@ -79,6 +79,8 @@ extern "C"
* Public Function Prototypes
************************************************************************************/
int up_cryptoinitialize(void);
#if defined(CONFIG_CRYPTO_AES)
int up_aesinitialize(void);
int aes_cypher(FAR void *out, FAR const void *in, uint32_t size, FAR const void *iv,