aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorareviu <areviu.info@gmail.com>2017-11-13 20:31:01 +0000
committerareviu <areviu.info@gmail.com>2017-11-13 20:31:01 +0000
commitabc49200f7cdd8b9698e767cec7df95a4ec039e2 (patch)
tree9e412a5a8bb4362bf237c935c142806dd662ed22
parent6345e21b5deb23408ef15574904b12df329fa9fe (diff)
downloadChibiOS-abc49200f7cdd8b9698e767cec7df95a4ec039e2.tar.gz
ChibiOS-abc49200f7cdd8b9698e767cec7df95a4ec039e2.tar.bz2
ChibiOS-abc49200f7cdd8b9698e767cec7df95a4ec039e2.zip
added aes and (t)des in dma mode + test suite crypto
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10993 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/hal/ports/SAMA/LLD/CRYPTOv1/sama_aes_lld.c44
-rw-r--r--os/hal/ports/SAMA/LLD/CRYPTOv1/sama_tdes_lld.c233
-rw-r--r--os/hal/ports/SAMA/SAMA5D2x/hal_crypto_lld.c78
-rw-r--r--test/crypto/config.fmpp15
-rw-r--r--test/crypto/configuration.xml2295
-rw-r--r--test/crypto/crypto_test.mk15
-rw-r--r--test/crypto/ref/README.txt2
-rw-r--r--test/crypto/ref/aes_ref.bat17
-rw-r--r--test/crypto/ref/des_ref.bat8
-rw-r--r--test/crypto/ref/gen_cfiles.bat4
-rw-r--r--test/crypto/ref/gen_testref.bat12
-rw-r--r--test/crypto/ref/genfile.py68
-rw-r--r--test/crypto/ref/ref_data.bat7
-rw-r--r--test/crypto/ref/setpath.bat2
-rw-r--r--test/crypto/source/test/cry_test_root.c169
-rw-r--r--test/crypto/source/test/cry_test_root.h78
-rw-r--r--test/crypto/source/test/cry_test_sequence_001.c393
-rw-r--r--test/crypto/source/test/cry_test_sequence_001.h27
-rw-r--r--test/crypto/source/test/cry_test_sequence_002.c393
-rw-r--r--test/crypto/source/test/cry_test_sequence_002.h27
-rw-r--r--test/crypto/source/test/cry_test_sequence_003.c393
-rw-r--r--test/crypto/source/test/cry_test_sequence_003.h27
-rw-r--r--test/crypto/source/test/cry_test_sequence_004.c633
-rw-r--r--test/crypto/source/test/cry_test_sequence_004.h27
-rw-r--r--test/crypto/source/testref/ref_aes.c822
-rw-r--r--test/crypto/source/testref/ref_aes.h31
-rw-r--r--test/crypto/source/testref/ref_des.c353
-rw-r--r--test/crypto/source/testref/ref_des.h24
28 files changed, 6039 insertions, 158 deletions
diff --git a/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_aes_lld.c b/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_aes_lld.c
index 563269d42..f8d9124db 100644
--- a/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_aes_lld.c
+++ b/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_aes_lld.c
@@ -16,10 +16,6 @@
#include "hal.h"
#include "sama_crypto_lld.h"
-
-
-
-
void sama_aes_lld_write_key(const uint32_t * key, const uint32_t * vectors,
uint32_t len) {
@@ -160,6 +156,8 @@ cryerror_t sama_aes_lld_process_polling(CRYDriver *cryp, aesparams *params,
cryerror_t sama_aes_lld_process_dma(CRYDriver *cryp, aesparams *params,
const uint8_t *in, uint8_t *out, size_t indata_len) {
+ cryerror_t ret;
+
osalDbgAssert(cryp->thread == NULL, "already waiting");
//set chunk size
@@ -168,7 +166,7 @@ cryerror_t sama_aes_lld_process_dma(CRYDriver *cryp, aesparams *params,
if ((cryp->config->cfbs != AES_CFBS_128))
cryp->dmachunksize = DMA_CHUNK_SIZE_1;
- //set dma with
+ //set dma width
cryp->dmawith = DMA_DATA_WIDTH_WORD;
if (cryp->config->cfbs == AES_CFBS_16)
@@ -198,6 +196,9 @@ cryerror_t sama_aes_lld_process_dma(CRYDriver *cryp, aesparams *params,
XDMAC_CC_DAM_FIXED_AM |
XDMAC_CC_PERID(PERID_AES_TX);
+ dmaChannelSetMode(cryp->dmarx, cryp->rxdmamode);
+ dmaChannelSetMode(cryp->dmatx, cryp->txdmamode);
+
/* Writing channel */
dmaChannelSetSource(cryp->dmatx, in);
dmaChannelSetDestination(cryp->dmatx, AES->AES_IDATAR);
@@ -209,16 +210,33 @@ cryerror_t sama_aes_lld_process_dma(CRYDriver *cryp, aesparams *params,
dmaChannelSetDestination(cryp->dmarx, out);
dmaChannelSetTransactionSize(cryp->dmarx, ( indata_len / DMA_DATA_WIDTH_TO_BYTE(cryp->dmawith)));
- if (params->encrypt)
- AES->AES_MR |= AES_MR_CIPHER;
- else
- AES->AES_MR &= ~AES_MR_CIPHER;
+ //AES soft reset
+ AES->AES_CR = AES_CR_SWRST;
+
+ //AES set op mode
+ AES->AES_MR |= ((AES_MR_OPMOD_Msk & (params->mode)) | AES_MR_CKEY_PASSWD);
+
+ //AES set key size
+ ret = sama_aes_lld_set_key_size(cryp->key0_size);
+
+ if (ret == CRY_NOERROR) {
- AES->AES_MR |= (((AES_MR_SMOD_Msk & (AES_MR_SMOD_IDATAR0_START)))
- | AES_MR_CKEY_PASSWD);
+ AES->AES_MR |= (AES_MR_CFBS(cryp->config->cfbs) | AES_MR_CKEY_PASSWD);
+
+ sama_aes_lld_write_key(key0_buffer,( const uint32_t *) params->iv, cryp->key0_size);
- //Enable aes interrupt
- AES->AES_IER = AES_IER_DATRDY;
+ if (params->encrypt)
+ AES->AES_MR |= AES_MR_CIPHER;
+ else
+ AES->AES_MR &= ~AES_MR_CIPHER;
+
+ AES->AES_MR |= (((AES_MR_SMOD_Msk & (AES_MR_SMOD_IDATAR0_START)))
+ | AES_MR_CKEY_PASSWD);
+
+ //Enable aes interrupt
+ AES->AES_IER = AES_IER_DATRDY;
+
+ }
osalSysLock();
diff --git a/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_tdes_lld.c b/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_tdes_lld.c
index 2e804cf8e..c6de6fca7 100644
--- a/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_tdes_lld.c
+++ b/os/hal/ports/SAMA/LLD/CRYPTOv1/sama_tdes_lld.c
@@ -1,18 +1,18 @@
/*
- ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
+ ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
#include "hal.h"
#include "sama_crypto_lld.h"
#include "sama_tdes_lld.h"
@@ -135,115 +135,122 @@ cryerror_t sama_tdes_lld_dma(CRYDriver *cryp, tdes_config_t *params,
bool encrypt, const uint8_t *data, size_t data_len, uint8_t * out,
const uint8_t *iv) {
-
uint32_t mode = 0;
uint32_t *vectors = (uint32_t *) iv;
cryp->dmachunksize = DMA_CHUNK_SIZE_1;
- cryp->dmawith = 4;
+
+ cryp->dmawith = DMA_DATA_WIDTH_WORD;
+
if ((params->mode == TDES_MODE_CFB)) {
- if (cryp->config->cfbs == TDES_CFBS_16)
- cryp->dmawith = DMA_DATA_WIDTH_HALF_WORD;
- if (cryp->config->cfbs == TDES_CFBS_8)
- cryp->dmawith = DMA_DATA_WIDTH_BYTE;
+ if (cryp->config->cfbs == TDES_CFBS_16)
+ cryp->dmawith = DMA_DATA_WIDTH_HALF_WORD;
+ if (cryp->config->cfbs == TDES_CFBS_8)
+ cryp->dmawith = DMA_DATA_WIDTH_BYTE;
+ }
+
+ cryp->rxdmamode = XDMAC_CC_TYPE_PER_TRAN |
+ XDMAC_CC_PROT_SEC |
+ XDMAC_CC_MBSIZE_SINGLE |
+ XDMAC_CC_DSYNC_PER2MEM | XDMAC_CC_CSIZE(cryp->dmachunksize) |
+ XDMAC_CC_DWIDTH(cryp->dmawith) |
+ XDMAC_CC_SIF_AHB_IF1 |
+ XDMAC_CC_DIF_AHB_IF0 |
+ XDMAC_CC_SAM_FIXED_AM |
+ XDMAC_CC_DAM_INCREMENTED_AM |
+ XDMAC_CC_PERID(PERID_TDES_RX);
+
+ cryp->txdmamode = XDMAC_CC_TYPE_PER_TRAN |
+ XDMAC_CC_PROT_SEC |
+ XDMAC_CC_MBSIZE_SINGLE |
+ XDMAC_CC_DSYNC_MEM2PER | XDMAC_CC_CSIZE(cryp->dmachunksize) |
+ XDMAC_CC_DWIDTH(cryp->dmawith) |
+ XDMAC_CC_SIF_AHB_IF0 |
+ XDMAC_CC_DIF_AHB_IF1 |
+ XDMAC_CC_SAM_INCREMENTED_AM |
+ XDMAC_CC_DAM_FIXED_AM |
+ XDMAC_CC_PERID(PERID_TDES_TX);
+
+ dmaChannelSetMode(cryp->dmarx, cryp->rxdmamode);
+ dmaChannelSetMode(cryp->dmatx, cryp->txdmamode);
+
+ /* Writing channel */
+ dmaChannelSetSource(cryp->dmatx, data);
+ dmaChannelSetDestination(cryp->dmatx, TDES->TDES_IDATAR);
+ dmaChannelSetTransactionSize(cryp->dmatx,
+ (data_len / DMA_DATA_WIDTH_TO_BYTE(cryp->dmawith)));
+
+ // ( data_len / DMA_DATA_WIDTH_TO_BYTE(cryp->dmawith))
+
+ /* Reading channel */
+ dmaChannelSetSource(cryp->dmarx, TDES->TDES_ODATAR);
+ dmaChannelSetDestination(cryp->dmarx, out);
+ dmaChannelSetTransactionSize(cryp->dmarx,
+ (data_len / DMA_DATA_WIDTH_TO_BYTE(cryp->dmawith)));
+
+ //soft reset
+ TDES->TDES_CR = TDES_CR_SWRST;
+
+ //configure
+ if (encrypt)
+ mode |= TDES_MR_CIPHER_ENCRYPT;
+ else
+ mode |= TDES_MR_CIPHER_DECRYPT;
+
+ if (cryp->key0_size == 16)
+ mode |= (TDES_KEY_TWO << 4);
+ else
+ mode |= (TDES_KEY_THREE << 4);
+
+ mode |= TDES_MR_TDESMOD(params->algo);
+
+ mode |= TDES_MR_SMOD_IDATAR0_START;
+
+ mode |= TDES_MR_OPMOD(params->mode);
+
+ if (cryp->config != NULL) {
+ mode |= TDES_MR_CFBS(cryp->config->cfbs);
}
- cryp->rxdmamode =
- XDMAC_CC_DSYNC_PER2MEM |
- XDMAC_CC_CSIZE(cryp->dmachunksize) |
- XDMAC_CC_DWIDTH(cryp->dmawith) |
- XDMAC_CC_SIF_AHB_IF1 |
- XDMAC_CC_DIF_AHB_IF0 |
- XDMAC_CC_SAM_FIXED_AM |
- XDMAC_CC_DAM_INCREMENTED_AM |
- XDMAC_CC_PERID(PERID_TDES_RX);
-
- cryp->txdmamode =
- XDMAC_CC_DSYNC_MEM2PER |
- XDMAC_CC_CSIZE(cryp->dmachunksize) |
- XDMAC_CC_DWIDTH(cryp->dmawith) |
- XDMAC_CC_SIF_AHB_IF0 |
- XDMAC_CC_DIF_AHB_IF1 |
- XDMAC_CC_SAM_INCREMENTED_AM |
- XDMAC_CC_DAM_FIXED_AM |
- XDMAC_CC_PERID(PERID_TDES_TX);
-
- dmaChannelSetMode(cryp->dmarx, cryp->rxdmamode);
- dmaChannelSetMode(cryp->dmatx, cryp->txdmamode);
-
- /* Writing channel */
- dmaChannelSetSource(cryp->dmatx, data);
- dmaChannelSetDestination(cryp->dmatx, TDES->TDES_IDATAR);
- dmaChannelSetTransactionSize(cryp->dmatx, ( data_len / DMA_DATA_WIDTH_TO_BYTE(cryp->dmawith)) );
-
- // ( data_len / DMA_DATA_WIDTH_TO_BYTE(cryp->dmawith))
-
- /* Reading channel */
- dmaChannelSetSource(cryp->dmarx, TDES->TDES_ODATAR);
- dmaChannelSetDestination(cryp->dmarx, out);
- dmaChannelSetTransactionSize(cryp->dmarx, ( data_len / DMA_DATA_WIDTH_TO_BYTE(cryp->dmawith)) );
-
-
- //soft reset
- TDES->TDES_CR = TDES_CR_SWRST;
- //configure
- if (encrypt)
- mode |= TDES_MR_CIPHER_ENCRYPT;
- else
- mode |= TDES_MR_CIPHER_DECRYPT;
-
- if (cryp->key0_size == 16)
- mode |= (TDES_KEY_TWO << 4);
- else
- mode |= (TDES_KEY_THREE << 4);
-
- mode |= TDES_MR_TDESMOD(params->algo);
-
- mode |= TDES_MR_SMOD(2);
-
- mode |= TDES_MR_OPMOD(params->mode);
-
- TDES->TDES_MR = mode;
-
- //write keys
- /* Write the 64-bit key(s) in the different Key Word Registers,
- * depending on whether one, two or three keys are required. */
-
- TDES->TDES_KEY1WR[0] = key0_buffer[0];
- TDES->TDES_KEY1WR[1] = key0_buffer[1];
-
- if (cryp->key0_size > 8) {
- TDES->TDES_KEY2WR[0] = key0_buffer[2];
- TDES->TDES_KEY2WR[1] = key0_buffer[3];
- } else {
- TDES->TDES_KEY2WR[0] = 0x0;
- TDES->TDES_KEY2WR[1] = 0x0;
- }
- if (cryp->key0_size > 16) {
- TDES->TDES_KEY3WR[0] = key0_buffer[4];
- TDES->TDES_KEY3WR[1] = key0_buffer[5];
- } else {
- TDES->TDES_KEY3WR[0] = 0x0;
- TDES->TDES_KEY3WR[1] = 0x0;
- }
- /* The Initialization Vector Registers apply to all modes except ECB. */
- if (params->mode != TDES_MODE_ECB && vectors != NULL) {
- TDES->TDES_IVR[0] = vectors[0];
- TDES->TDES_IVR[1] = vectors[1];
- }
- if (params->algo == TDES_ALGO_XTEA) {
- TDES->TDES_XTEA_RNDR = TDES_XTEA_RNDR_XTEA_RNDS(32);
- }
-
-
- osalSysLock();
-
- dmaChannelEnable(cryp->dmarx);
- dmaChannelEnable(cryp->dmatx);
-
-
- osalThreadSuspendS(&cryp->thread);
- osalSysUnlock();
+ TDES->TDES_MR = mode;
+
+ //write keys
+ TDES->TDES_KEY1WR[0] = key0_buffer[0];
+ TDES->TDES_KEY1WR[1] = key0_buffer[1];
+
+ if (cryp->key0_size > 8) {
+ TDES->TDES_KEY2WR[0] = key0_buffer[2];
+ TDES->TDES_KEY2WR[1] = key0_buffer[3];
+ } else {
+ TDES->TDES_KEY2WR[0] = 0x0;
+ TDES->TDES_KEY2WR[1] = 0x0;
+ }
+ if (cryp->key0_size > 16) {
+ TDES->TDES_KEY3WR[0] = key0_buffer[4];
+ TDES->TDES_KEY3WR[1] = key0_buffer[5];
+ } else {
+ TDES->TDES_KEY3WR[0] = 0x0;
+ TDES->TDES_KEY3WR[1] = 0x0;
+ }
+ /* The Initialization Vector Registers apply to all modes except ECB. */
+ if (params->mode != TDES_MODE_ECB && vectors != NULL) {
+ TDES->TDES_IVR[0] = vectors[0];
+ TDES->TDES_IVR[1] = vectors[1];
+ }
+ if (params->algo == TDES_ALGO_XTEA) {
+ TDES->TDES_XTEA_RNDR = TDES_XTEA_RNDR_XTEA_RNDS(32);
+ }
+
+//enable interrutps
+ TDES->TDES_IER = TDES_IER_DATRDY;
+
+ osalSysLock();
+
+ dmaChannelEnable(cryp->dmarx);
+ dmaChannelEnable(cryp->dmatx);
+
+ osalThreadSuspendS(&cryp->thread);
+ osalSysUnlock();
return CRY_NOERROR;
}
diff --git a/os/hal/ports/SAMA/SAMA5D2x/hal_crypto_lld.c b/os/hal/ports/SAMA/SAMA5D2x/hal_crypto_lld.c
index 7665f9204..8d8a92009 100644
--- a/os/hal/ports/SAMA/SAMA5D2x/hal_crypto_lld.c
+++ b/os/hal/ports/SAMA/SAMA5D2x/hal_crypto_lld.c
@@ -817,26 +817,24 @@ cryerror_t cry_lld_encrypt_DES(CRYDriver *cryp, crykey_t key_id,
cryerror_t ret = CRY_NOERROR;
- if(key_id != 0 )
+ if (key_id != 0)
return CRY_ERR_INV_KEY_ID;
- if ( ( cryp->config->tdes_algo == TDES_ALGO_SINGLE && cryp->key0_size != 8 ) ||
- ( cryp->config->tdes_algo == TDES_ALGO_TRIPLE && cryp->key0_size != 24 ) )
- return CRY_ERR_INV_KEY_SIZE;
+ if ((cryp->config->tdes_algo == TDES_ALGO_SINGLE && cryp->key0_size != 8)
+ || (cryp->config->tdes_algo == TDES_ALGO_TRIPLE
+ && !(cryp->key0_size == 16 || cryp->key0_size == 24)))
+ return CRY_ERR_INV_KEY_SIZE;
- tdes_config_t params = { cryp->config->tdes_algo,
- 0
- };
+ tdes_config_t params = { cryp->config->tdes_algo, 0 };
- if (!(cryp->enabledPer & TDES_PER)) {
- cryp->enabledPer |= TDES_PER;
- pmcEnableDES();
- }
+ if (!(cryp->enabledPer & TDES_PER)) {
+ cryp->enabledPer |= TDES_PER;
+ pmcEnableDES();
+ }
- ret = sama_tdes_lld_polling(cryp,&params, true, in,
- 8, out,NULL);
+ ret = sama_tdes_lld_polling(cryp, &params, true, in, 8, out, NULL);
- return ret;
+ return ret;
}
/**
@@ -865,21 +863,23 @@ cryerror_t cry_lld_decrypt_DES(CRYDriver *cryp, crykey_t key_id,
const uint8_t *in, uint8_t *out) {
cryerror_t ret = CRY_NOERROR;
- tdes_config_t params = { cryp->config->tdes_algo,
- 0
- };
- if(key_id != 0 )
- return CRY_ERR_INV_KEY_ID;
- if (!(cryp->enabledPer & TDES_PER)) {
- cryp->enabledPer |= TDES_PER;
- pmcEnableDES();
- }
+ tdes_config_t params = { cryp->config->tdes_algo, 0 };
+ if (key_id != 0)
+ return CRY_ERR_INV_KEY_ID;
- ret = sama_tdes_lld_polling(cryp,&params, false, in,
- 8, out,NULL);
+ if ((cryp->config->tdes_algo == TDES_ALGO_SINGLE && cryp->key0_size != 8)
+ || (cryp->config->tdes_algo == TDES_ALGO_TRIPLE
+ && !(cryp->key0_size == 16 || cryp->key0_size == 24)))
+ return CRY_ERR_INV_KEY_SIZE;
+
+ if (!(cryp->enabledPer & TDES_PER)) {
+ cryp->enabledPer |= TDES_PER;
+ pmcEnableDES();
+ }
+ ret = sama_tdes_lld_polling(cryp, &params, false, in, 8, out, NULL);
- return ret;
+ return ret;
}
/**
@@ -911,17 +911,20 @@ cryerror_t cry_lld_encrypt_DES_ECB(CRYDriver *cryp, crykey_t key_id,
cryerror_t ret = CRY_NOERROR;
tdes_config_t params = { cryp->config->tdes_algo, TDES_MODE_ECB };
+
if (key_id != 0)
return CRY_ERR_INV_KEY_ID;
- if (cryp->key0_size != 16 && cryp->key0_size != 24) {
+ if (cryp->config->tdes_algo == TDES_ALGO_SINGLE && cryp->key0_size != 8) {
+ return CRY_ERR_INV_KEY_SIZE;
+ }
+ if (cryp->config->tdes_algo == TDES_ALGO_TRIPLE && !(cryp->key0_size == 16 || cryp->key0_size == 24) ) {
return CRY_ERR_INV_KEY_SIZE;
}
if (!(cryp->enabledPer & TDES_PER)) {
cryp->enabledPer |= TDES_PER;
- pmcEnableDES()
- ;
+ pmcEnableDES();
}
if (cryp->config->transfer_mode == TRANSFER_POLLING)
ret = sama_tdes_lld_polling(cryp, &params, true, in, size, out, NULL);
@@ -963,9 +966,12 @@ cryerror_t cry_lld_decrypt_DES_ECB(CRYDriver *cryp, crykey_t key_id,
if (key_id != 0)
return CRY_ERR_INV_KEY_ID;
- if (cryp->key0_size != 16 && cryp->key0_size != 24) {
- return CRY_ERR_INV_KEY_SIZE;
- }
+ if (cryp->config->tdes_algo == TDES_ALGO_SINGLE && cryp->key0_size != 8) {
+ return CRY_ERR_INV_KEY_SIZE;
+ }
+ if (cryp->config->tdes_algo == TDES_ALGO_TRIPLE && !(cryp->key0_size == 16 || cryp->key0_size == 24) ) {
+ return CRY_ERR_INV_KEY_SIZE;
+ }
if (!(cryp->enabledPer & TDES_PER)) {
cryp->enabledPer |= TDES_PER;
pmcEnableDES()
@@ -1011,9 +1017,13 @@ cryerror_t cry_lld_encrypt_DES_CBC(CRYDriver *cryp, crykey_t key_id,
cryerror_t ret = CRY_NOERROR;
tdes_config_t params = { cryp->config->tdes_algo, TDES_MODE_CBC };
+
if (key_id != 0)
return CRY_ERR_INV_KEY_ID;
+ if (cryp->config->tdes_algo == TDES_ALGO_SINGLE)
+ return CRY_ERR_INV_ALGO;
+
if (cryp->key0_size != 16 && cryp->key0_size != 24) {
return CRY_ERR_INV_KEY_SIZE;
}
@@ -1061,9 +1071,13 @@ cryerror_t cry_lld_decrypt_DES_CBC(CRYDriver *cryp, crykey_t key_id,
cryerror_t ret = CRY_NOERROR;
tdes_config_t params = { cryp->config->tdes_algo, TDES_MODE_CBC };
+
if (key_id != 0)
return CRY_ERR_INV_KEY_ID;
+ if (cryp->config->tdes_algo == TDES_ALGO_SINGLE)
+ return CRY_ERR_INV_ALGO;
+
if (cryp->key0_size != 16 && cryp->key0_size != 24) {
return CRY_ERR_INV_KEY_SIZE;
}
diff --git a/test/crypto/config.fmpp b/test/crypto/config.fmpp
new file mode 100644
index 000000000..62a3641e2
--- /dev/null
+++ b/test/crypto/config.fmpp
@@ -0,0 +1,15 @@
+sourceRoot: ../../tools/ftl/processors/unittest
+outputRoot: source
+dataRoot: .
+
+freemarkerLinks: {
+ ftllibs: ../../tools/ftl/libs
+}
+
+data : {
+ xml:xml (
+ configuration.xml
+ {
+ }
+ )
+}
diff --git a/test/crypto/configuration.xml b/test/crypto/configuration.xml
new file mode 100644
index 000000000..958839811
--- /dev/null
+++ b/test/crypto/configuration.xml
@@ -0,0 +1,2295 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SPC5-Config version="1.0.0">
+ <application name="Crypto Test Suite" version="1.0.0" standalone="true" locked="false">
+ <description>Test Specification for Hal Crypto </description>
+ <component id="org.chibios.spc5.components.portable.generic_startup">
+ <component id="org.chibios.spc5.components.portable.chibios_unitary_tests_engine" />
+ </component>
+ <instances>
+ <instance locked="false" id="org.chibios.spc5.components.portable.generic_startup" />
+ <instance locked="false" id="org.chibios.spc5.components.portable.chibios_unitary_tests_engine">
+ <description>
+ <brief>
+ <value>Chibios Hal Crypto Test Suite.</value>
+ </brief>
+ <copyright>
+ <value><![CDATA[/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/]]></value>
+ </copyright>
+ <introduction>
+ <value>Test suite for ChibiOS Crypto Hal. The purpose of this suite is to perform unit tests on the Hal Crypto and to converge to 100% code coverage through successive improvements.</value>
+ </introduction>
+ </description>
+ <global_data_and_code>
+ <code_prefix>
+ <value>cry_</value>
+ </code_prefix>
+ <global_definitions>
+ <value><![CDATA[
+extern void cryptoTest_setStream(BaseSequentialStream * s);
+extern void cryptoTest_printArray32(bool isLE,const uint32_t *a,size_t len);
+#ifdef LOG_CRYPTO_DATA
+#define SHOW_ENCRYPDATA(w) cryptoTest_printArray32(true,msg_encrypted,w)
+#define SHOW_DECRYPDATA(w) cryptoTest_printArray32(true,msg_decrypted,w)
+#else
+#define SHOW_ENCRYPDATA(w)
+#define SHOW_DECRYPDATA(w)
+#endif
+
+#define TEST_DATA_BYTE_LEN 640
+#define TEST_DATA_WORD_LEN (TEST_DATA_BYTE_LEN / 4)
+
+
+#define TEST_MSG_DATA_BYTE_LEN 640
+#define TEST_MSG_DATA_WORD_LEN (TEST_MSG_DATA_BYTE_LEN / 4)
+
+extern const char test_plain_data[TEST_DATA_BYTE_LEN];
+extern uint32_t msg_clear[TEST_MSG_DATA_WORD_LEN];
+extern uint32_t msg_encrypted[TEST_MSG_DATA_WORD_LEN];
+extern uint32_t msg_decrypted[TEST_MSG_DATA_WORD_LEN];
+extern const uint32_t test_keys[8];
+extern const uint32_t test_vectors[4];
+
+]]></value>
+ </global_definitions>
+ <global_code>
+ <value><![CDATA[
+
+#if CRYPTO_LOG_LEVEL == 1
+#include "chprintf.h"
+#endif
+
+
+
+const uint32_t test_keys[8]=
+{
+ 0x01234567, //KEY 1 low part
+ 0x89ABCDEF, //KEY 1 hi part
+ 0x76543210, //KEY 2 low part
+ 0xFEDCBA98, //KEY 2 hi part
+
+ 0x55AA55AA,
+ 0xAA55AA55,
+ 0x0000FFFF,
+ 0xFFFF0000
+
+};
+
+const uint32_t test_vectors[4]=
+{
+ 0x11223344, //VECTOR 1 low part
+ 0x55667788, //VECTOR 1 hi part
+ 0x11112222,
+ 0x33334444
+
+};
+
+const char test_plain_data[TEST_DATA_BYTE_LEN] ="\
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesen\
+t et pellentesque risus. Sed id gravida elit. Proin eget accumsa\
+n mi. Aliquam vitae dui porta, euismod velit viverra, elementum \
+lacus. Nunc turpis orci, venenatis vel vulputate nec, luctus sit\
+amet urna. Ut et nunc purus. Aliquam erat volutpat. Vestibulum n\
+ulla dolor, cursus vitae cursus eget, dapibus eget sapien. Integ\
+er justo eros, commodo ut massa eu, bibendum elementum tellus. N\
+am quis dolor in libero placerat congue. Sed sodales urna sceler\
+isque dui faucibus, vitae malesuada dui fermentum. Proin ultrici\
+es sit amet justo at ornare. Suspendisse efficitur purus nullam.";
+
+ALIGNED_VAR(4) uint32_t msg_clear[TEST_MSG_DATA_WORD_LEN];
+ALIGNED_VAR(4) uint32_t msg_encrypted[TEST_MSG_DATA_WORD_LEN];
+ALIGNED_VAR(4) uint32_t msg_decrypted[TEST_MSG_DATA_WORD_LEN];
+BaseSequentialStream * ts;
+
+#if CRYPTO_LOG_LEVEL == 1
+static uint32_t toBigEndian(uint32_t v)
+{
+ return (v & 0x000000ff) << 24u |
+ ( (v & 0x0000ff00) << 8u ) |
+ ( (v & 0x00ff0000) >> 8u ) |
+ ( (v & 0xff000000) >> 24u );
+}
+#endif
+
+void cryptoTest_setStream(BaseSequentialStream * s)
+{
+ ts = s;
+}
+
+void cryptoTest_printArray(const uint8_t *a,size_t len)
+{
+#if CRYPTO_LOG_LEVEL == 1
+ for(size_t i=0;i<len;i++)
+ {
+ chprintf(ts,"%02X",a[i]);
+ }
+ chprintf(ts,"\r\n");
+#else
+ (void)a;
+ (void)len;
+#endif
+}
+
+void cryptoTest_printArray32(bool isLE,const uint32_t *a,size_t len)
+{
+#if CRYPTO_LOG_LEVEL == 1
+ uint32_t data;
+
+ for(size_t i=0;i<len;i++)
+ {
+ if (isLE)
+ data = toBigEndian(a[i]);
+ else
+ data = a[i];
+
+ chprintf(ts,"%08X ",data);
+
+ }
+ chprintf(ts,"\r\n");
+#else
+ (void)isLE;
+ (void)a;
+ (void)len;
+#endif
+}
+
+ ]]></value>
+ </global_code>
+ </global_data_and_code>
+
+ <sequences>
+<sequence>
+ <type index="0">
+ <value>Internal Tests</value>
+ </type>
+ <brief>
+ <value>AES ECB</value>
+ </brief>
+ <description>
+ <value>AES ECB</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <shared_code>
+ <value><![CDATA[
+#include <string.h>
+#include "ref_aes.h"
+static const CRYConfig config_Polling = {
+ TRANSFER_POLLING,
+ AES_CFBS_128, //cfbs
+ 0
+};
+
+static const CRYConfig config_DMA = {
+ TRANSFER_DMA,
+ AES_CFBS_128, //cfbs
+ 0
+};
+ ]]></value>
+ </shared_code>
+ <cases>
+ <case>
+ <brief>
+ <value>AES ECB Polling</value>
+ </brief>
+ <description>
+ <value>testing AES ECB with various Keys</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+cryStart(&CRYD1, &config_Polling);
+
+ ]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[cryStop(&CRYD1);]]></value>
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[
+ cryerror_t ret;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key with 16 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,16, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_ECB_128)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 24 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,24, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_ECB_192)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 32 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,32, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_ECB_256)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>AES ECB DMA</value>
+ </brief>
+ <description>
+ <value>testing AES ECB with various Keys</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+cryStart(&CRYD1, &config_DMA);
+
+ ]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[cryStop(&CRYD1);]]></value>
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[
+ cryerror_t ret;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key with 16 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,16, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_ECB_128)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 24 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,24, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_ECB_192)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 32 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,32, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_ECB_256)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ </cases>
+ </sequence>
+
+
+<sequence>
+ <type index="0">
+ <value>Internal Tests</value>
+ </type>
+ <brief>
+ <value>AES CFB</value>
+ </brief>
+ <description>
+ <value>AES CFB</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <shared_code>
+ <value><![CDATA[
+#include <string.h>
+#include "ref_aes.h"
+static const CRYConfig config_Polling = {
+ TRANSFER_POLLING,
+ AES_CFBS_128, //cfbs
+ 0
+};
+
+static const CRYConfig config_DMA = {
+ TRANSFER_DMA,
+ AES_CFBS_128, //cfbs
+ 0
+};
+ ]]></value>
+ </shared_code>
+ <cases>
+ <case>
+ <brief>
+ <value>AES CFB Polling</value>
+ </brief>
+ <description>
+ <value>testing AES CFB with various Keys</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+cryStart(&CRYD1, &config_Polling);
+
+ ]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[cryStop(&CRYD1);]]></value>
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[
+ cryerror_t ret;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key with 16 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,16, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CFB_128)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 24 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,24, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CFB_192)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 32 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,32, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CFB_256)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>AES CFB DMA</value>
+ </brief>
+ <description>
+ <value>testing AES CFB with various Keys</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+cryStart(&CRYD1, &config_DMA);
+
+ ]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[cryStop(&CRYD1);]]></value>
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[
+ cryerror_t ret;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key with 16 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,16, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CFB_128)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 24 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,24, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CFB_192)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 32 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,32, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CFB_256)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ </cases>
+ </sequence>
+
+
+<sequence>
+ <type index="0">
+ <value>Internal Tests</value>
+ </type>
+ <brief>
+ <value>AES CBC</value>
+ </brief>
+ <description>
+ <value>AES CBC</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <shared_code>
+ <value><![CDATA[
+#include <string.h>
+#include "ref_aes.h"
+static const CRYConfig config_Polling = {
+ TRANSFER_POLLING,
+ AES_CFBS_128, //cfbs
+ 0
+};
+
+static const CRYConfig config_DMA = {
+ TRANSFER_DMA,
+ AES_CFBS_128, //cfbs
+ 0
+};
+ ]]></value>
+ </shared_code>
+ <cases>
+ <case>
+ <brief>
+ <value>AES CBC Polling</value>
+ </brief>
+ <description>
+ <value>testing AES CBC with various Keys</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+cryStart(&CRYD1, &config_Polling);
+
+ ]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[cryStop(&CRYD1);]]></value>
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[
+ cryerror_t ret;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key with 16 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,16, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CBC_128)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 24 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,24, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CBC_192)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 32 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,32, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CBC_256)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>AES CBC DMA</value>
+ </brief>
+ <description>
+ <value>testing AES CBC with various Keys</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+cryStart(&CRYD1, &config_DMA);
+
+ ]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[cryStop(&CRYD1);]]></value>
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[
+ cryerror_t ret;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key with 16 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,16, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CBC_128)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 24 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,24, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CBC_192)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 32 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,32, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CBC_256)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
+ </cases>
+ </sequence>
+
+
+<sequence>
+ <type index="0">
+ <value>Internal Tests</value>
+ </type>
+ <brief>
+ <value>(T)DES</value>
+ </brief>
+ <description>
+ <value>(T)DES testing</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <shared_code>
+ <value><![CDATA[
+#include <string.h>
+#include "ref_des.h"
+static const CRYConfig configDES_Polling=
+{
+ TRANSFER_POLLING,
+ 0,
+ TDES_ALGO_SINGLE
+};
+static const CRYConfig configTDES_Polling=
+{
+ TRANSFER_POLLING,
+ 0,
+ TDES_ALGO_TRIPLE
+};
+
+static const CRYConfig configTDES_DMA=
+{
+ TRANSFER_DMA,
+ 0,
+ TDES_ALGO_TRIPLE
+};
+
+ ]]></value>
+ </shared_code>
+ <cases>
+ <case>
+ <brief>
+ <value>DES Polling</value>
+ </brief>
+ <description>
+ <value>testing DES in polled mode</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+cryStart(&CRYD1, &configDES_Polling);
+
+ ]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[cryStop(&CRYD1);]]></value>
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[
+ cryerror_t ret;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key with 8 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,8, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptDES(&CRYD1, 0, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(2);
+
+for (int i = 0; i < 2; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refDES_ECB_8)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptDES(&CRYD1, 0, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(2);
+
+for (int i = 0; i < 2; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+
+
+
+
+
+ </steps>
+ </case>
+
+ <case>
+ <brief>
+ <value>TDES CBC Polling</value>
+ </brief>
+ <description>
+ <value>testing TDES CBC in polled mode</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+cryStart(&CRYD1, &configTDES_Polling);
+
+ ]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[cryStop(&CRYD1);]]></value>
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[
+ cryerror_t ret;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key with 16 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,16, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_CBC_16)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 24 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,24, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_CBC_24)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+
+
+
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>TDES ECB Polling</value>
+ </brief>
+ <description>
+ <value>testing TDES ECB in polling mode</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+cryStart(&CRYD1, &configTDES_Polling);
+
+ ]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[cryStop(&CRYD1);]]></value>
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[
+ cryerror_t ret;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key with 16 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,16, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_ECB_16)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 24 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,24, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_ECB_24)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+
+
+
+ </steps>
+ </case>
+
+
+
+ <case>
+ <brief>
+ <value>TDES CBC DMA</value>
+ </brief>
+ <description>
+ <value>testing TDES CBC in polled mode</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+cryStart(&CRYD1, &configTDES_DMA);
+
+ ]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[cryStop(&CRYD1);]]></value>
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[
+ cryerror_t ret;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key with 16 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,16, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_CBC_16)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 24 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,24, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_CBC_24)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+
+
+
+ </steps>
+ </case>
+ <case>
+ <brief>
+ <value>TDES ECB DMA</value>
+ </brief>
+ <description>
+ <value>testing TDES ECB in DMA mode</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+cryStart(&CRYD1, &configTDES_DMA);
+
+ ]]></value>
+ </setup_code>
+ <teardown_code>
+ <value><![CDATA[cryStop(&CRYD1);]]></value>
+ </teardown_code>
+ <local_variables>
+ <value><![CDATA[
+ cryerror_t ret;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key with 16 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,16, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_ECB_16)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>loading the key with 24 byte size</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,24, (uint8_t *) test_keys);
+
+test_assert(ret == CRY_NOERROR, "failed load transient key");
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Encrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryEncryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_ECB_24)[i], "encrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+ret = cryDecryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+}
+
+]]></value>
+ </code>
+ </step>
+
+
+
+ </steps>
+ </case>
+
+
+ </cases>
+ </sequence>
+
+ </sequences>
+ </instance>
+ </instances>
+ <exportedFeatures />
+ </application>
+</SPC5-Config>
diff --git a/test/crypto/crypto_test.mk b/test/crypto/crypto_test.mk
new file mode 100644
index 000000000..039cff349
--- /dev/null
+++ b/test/crypto/crypto_test.mk
@@ -0,0 +1,15 @@
+# List of all the ChibiOS OS Library test files.
+TESTSRC += ${CHIBIOS}/test/crypto/source/test/cry_test_root.c \
+ ${CHIBIOS}/test/crypto/source/testref/ref_aes.c \
+ ${CHIBIOS}/test/crypto/source/testref/ref_des.c \
+ ${CHIBIOS}/test/crypto/source/test/cry_test_sequence_001.c \
+ ${CHIBIOS}/test/crypto/source/test/cry_test_sequence_002.c \
+ ${CHIBIOS}/test/crypto/source/test/cry_test_sequence_003.c \
+ ${CHIBIOS}/test/crypto/source/test/cry_test_sequence_004.c
+# Required include directories
+TESTINC += ${CHIBIOS}/test/crypto/source/testref \
+ ${CHIBIOS}/test/crypto/source/test
+
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+
+
diff --git a/test/crypto/ref/README.txt b/test/crypto/ref/README.txt
new file mode 100644
index 000000000..6df947b08
--- /dev/null
+++ b/test/crypto/ref/README.txt
@@ -0,0 +1,2 @@
+set path of python and openssl in setpath.bat
+launch gen_testref.bat \ No newline at end of file
diff --git a/test/crypto/ref/aes_ref.bat b/test/crypto/ref/aes_ref.bat
new file mode 100644
index 000000000..05c132c08
--- /dev/null
+++ b/test/crypto/ref/aes_ref.bat
@@ -0,0 +1,17 @@
+
+
+%OPENSSL%\openssl enc -aes-128-ecb -nosalt -nopad -K %K16% -in plaintext -out aes_ecb_128.enc
+%OPENSSL%\openssl enc -aes-192-ecb -nopad -nosalt -K %K24% -in plaintext -out aes_ecb_192.enc
+%OPENSSL%\openssl enc -aes-256-ecb -nopad -nosalt -K %K32% -in plaintext -out aes_ecb_256.enc
+
+%OPENSSL%\openssl enc -aes-128-cbc -nopad -nosalt -K %K16% -iv %IV% -in plaintext -out aes_cbc_128.enc
+%OPENSSL%\openssl enc -aes-192-cbc -nopad -nosalt -K %K24% -iv %IV% -in plaintext -out aes_cbc_192.enc
+%OPENSSL%\openssl enc -aes-256-cbc -nopad -nosalt -K %K32% -iv %IV% -in plaintext -out aes_cbc_256.enc
+
+%OPENSSL%\openssl enc -aes-128-ctr -nopad -nosalt -K %K16% -iv %IV% -in plaintext -out aes_ctr_128.enc
+%OPENSSL%\openssl enc -aes-192-ctr -nopad -nosalt -K %K24% -iv %IV% -in plaintext -out aes_ctr_192.enc
+%OPENSSL%\openssl enc -aes-256-ctr -nopad -nosalt -K %K32% -iv %IV% -in plaintext -out aes_ctr_256.enc
+
+%OPENSSL%\openssl enc -aes-128-cfb -nopad -nosalt -K %K16% -iv %IV% -in plaintext -out aes_cfb_128.enc
+%OPENSSL%\openssl enc -aes-192-cfb -nopad -nosalt -K %K24% -iv %IV% -in plaintext -out aes_cfb_192.enc
+%OPENSSL%\openssl enc -aes-256-cfb -nopad -nosalt -K %K32% -iv %IV% -in plaintext -out aes_cfb_256.enc
diff --git a/test/crypto/ref/des_ref.bat b/test/crypto/ref/des_ref.bat
new file mode 100644
index 000000000..62d031391
--- /dev/null
+++ b/test/crypto/ref/des_ref.bat
@@ -0,0 +1,8 @@
+
+call %OPENSSL%\openssl enc -des-ecb -nopad -nosalt -K %K8% -e -in plaintext -out des_ecb_8.enc
+
+REM TDES
+call %OPENSSL%\openssl enc -des-ede-ecb -nopad -nosalt -K %K16% -e -in plaintext -out tdes_ecb_16.enc
+call %OPENSSL%\openssl enc -des-ede3-ecb -nopad -nosalt -K %K24% -e -in plaintext -out tdes_ecb_24.enc
+call %OPENSSL%\openssl enc -des-ede-cbc -nopad -nosalt -K %K16% -iv %DES_IV% -e -in plaintext -out tdes_cbc_16.enc
+call %OPENSSL%\openssl enc -des-ede3-cbc -nopad -nosalt -K %K24% -iv %DES_IV% -e -in plaintext -out tdes_cbc_24.enc \ No newline at end of file
diff --git a/test/crypto/ref/gen_cfiles.bat b/test/crypto/ref/gen_cfiles.bat
new file mode 100644
index 000000000..d0bc19ff9
--- /dev/null
+++ b/test/crypto/ref/gen_cfiles.bat
@@ -0,0 +1,4 @@
+%PYTHON%\python genfile.py -f aes_ecb_128,aes_ecb_192,aes_ecb_256,aes_cbc_128,aes_cbc_192,aes_cbc_256,aes_ctr_128,aes_ctr_192,aes_ctr_256,aes_cfb_128,aes_cfb_192,aes_cfb_256 -o ref_aes -p ../source/testref
+
+%PYTHON%\python genfile.py -f des_ecb_8,tdes_ecb_16,tdes_ecb_24,tdes_cbc_16,tdes_cbc_24 -o ref_des -p ../source/testref
+
diff --git a/test/crypto/ref/gen_testref.bat b/test/crypto/ref/gen_testref.bat
new file mode 100644
index 000000000..311376773
--- /dev/null
+++ b/test/crypto/ref/gen_testref.bat
@@ -0,0 +1,12 @@
+call setpath.bat
+
+call ref_data.bat
+
+del *.enc
+
+%PYTHON%\python -c "print 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent et pellentesque risus. Sed id gravida elit. Proin eget accumsan mi. Aliquam vitae dui porta, euismod velit viverra, elementum lacus. Nunc turpis orci, venenatis vel vulputate nec, luctus sitamet urna. Ut et nunc purus. Aliquam erat volutpat. Vestibulum nulla dolor, cursus vitae cursus eget, dapibus eget sapien. Integer justo eros, commodo ut massa eu, bibendum elementum tellus. Nam quis dolor in libero placerat congue. Sed sodales urna scelerisque dui faucibus, vitae malesuada dui fermentum. Proin ultricies sit amet justo at ornare. Suspendisse efficitur purus nullam.'.decode('ascii')" > plaintext
+
+call aes_ref.bat
+call des_ref.bat
+
+call gen_cfiles.bat \ No newline at end of file
diff --git a/test/crypto/ref/genfile.py b/test/crypto/ref/genfile.py
new file mode 100644
index 000000000..4bfac9e12
--- /dev/null
+++ b/test/crypto/ref/genfile.py
@@ -0,0 +1,68 @@
+import sys,getopt,string
+
+filenames = None
+fileOut = None
+filePath = None
+blocksize = 1024
+i = 0
+
+license ='/*\n'\
+' ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio\n'\
+'\n'\
+' Licensed under the Apache License, Version 2.0 (the "License");\n'\
+' you may not use this file except in compliance with the License.\n'\
+' You may obtain a copy of the License at\n'\
+'\n'\
+' http://www.apache.org/licenses/LICENSE-2.0\n'\
+'\n'\
+' Unless required by applicable law or agreed to in writing, software\n'\
+' distributed under the License is distributed on an "AS IS" BASIS,\n'\
+' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n'\
+' See the License for the specific language governing permissions and\n'\
+' limitations under the License.\n'\
+'*/\n'
+
+opts,args = getopt.getopt(sys.argv[1:],'f:o:p:')
+for o,a in opts:
+ if o == '-f':
+ filenames = a
+ if o == '-o':
+ fileOut = a
+ if o == '-p':
+ filePath = a
+
+
+filenames = filenames.split(",")
+
+fc = open (filePath+"/"+fileOut+".c","w")
+fh = open (filePath+"/"+fileOut+".h","w")
+fc.write(license)
+fc.write("\n#include \"hal.h\"\n\n")
+fh.write(license)
+fh.write("#ifndef TEST_"+fileOut.upper()+"_H_\n")
+fh.write("#define TEST_"+fileOut.upper()+"_H_\n\n")
+
+for fn in filenames:
+ print "opening ",fn
+ i = 0
+ f = open(fn+".enc","rb")
+ block = f.read(blocksize)
+ d = fn.split("_")
+
+
+
+ fc.write("const uint8_t ref"+d[0].upper()+"_"+d[1].upper()+"_"+d[2].upper()+"[]={\n")
+ fh.write("extern const uint8_t ref"+d[0].upper()+"_"+d[1].upper()+"_"+d[2].upper()+"[];\n")
+ str = ""
+ for ch in block:
+ i += 1
+ str += "0x"+format(ord(ch), '02X')+","
+ if i == 10:
+ str += "\n"
+ i = 0
+ fc.write(str)
+ fc.write("\n};\n")
+fh.write("#endif //TEST_"+fileOut.upper()+"_H_\n")
+
+
+
diff --git a/test/crypto/ref/ref_data.bat b/test/crypto/ref/ref_data.bat
new file mode 100644
index 000000000..9a9ccd362
--- /dev/null
+++ b/test/crypto/ref/ref_data.bat
@@ -0,0 +1,7 @@
+set K8=67452301EFCDAB89
+set K16=67452301EFCDAB891032547698BADCFE
+set K24=67452301EFCDAB891032547698BADCFEAA55AA5555AA55AA
+set K32=67452301EFCDAB891032547698BADCFEAA55AA5555AA55AAFFFF00000000FFFF
+set IV=44332211887766552222111144443333
+set DES_IV=4433221188776655
+
diff --git a/test/crypto/ref/setpath.bat b/test/crypto/ref/setpath.bat
new file mode 100644
index 000000000..196545e16
--- /dev/null
+++ b/test/crypto/ref/setpath.bat
@@ -0,0 +1,2 @@
+set PYTHON=E:\python\Python27
+set OPENSSL=E:\dev\OpenSSL-Win64\bin \ No newline at end of file
diff --git a/test/crypto/source/test/cry_test_root.c b/test/crypto/source/test/cry_test_root.c
new file mode 100644
index 000000000..e80e1d3fb
--- /dev/null
+++ b/test/crypto/source/test/cry_test_root.c
@@ -0,0 +1,169 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @mainpage Test Suite Specification
+ * Test suite for ChibiOS Crypto Hal. The purpose of this suite is to
+ * perform unit tests on the Hal Crypto and to converge to 100% code
+ * coverage through successive improvements.
+ *
+ * <h2>Test Sequences</h2>
+ * - @subpage cry_test_sequence_001
+ * - @subpage cry_test_sequence_002
+ * - @subpage cry_test_sequence_003
+ * - @subpage cry_test_sequence_004
+ * .
+ */
+
+/**
+ * @file cry_test_root.c
+ * @brief Test Suite root structures code.
+ */
+
+#include "hal.h"
+#include "cry_test_root.h"
+
+#if !defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/**
+ * @brief Array of test sequences.
+ */
+const testsequence_t * const cry_test_suite_array[] = {
+ &cry_test_sequence_001,
+ &cry_test_sequence_002,
+ &cry_test_sequence_003,
+ &cry_test_sequence_004,
+ NULL
+};
+
+/**
+ * @brief Test suite root structure.
+ */
+const testsuite_t cry_test_suite = {
+ "Chibios Hal Crypto Test Suite",
+ cry_test_suite_array
+};
+
+/*===========================================================================*/
+/* Shared code. */
+/*===========================================================================*/
+
+
+#if CRYPTO_LOG_LEVEL == 1
+#include "chprintf.h"
+#endif
+
+
+
+const uint32_t test_keys[8]=
+{
+ 0x01234567, //KEY 1 low part
+ 0x89ABCDEF, //KEY 1 hi part
+ 0x76543210, //KEY 2 low part
+ 0xFEDCBA98, //KEY 2 hi part
+
+ 0x55AA55AA,
+ 0xAA55AA55,
+ 0x0000FFFF,
+ 0xFFFF0000
+
+};
+
+const uint32_t test_vectors[4]=
+{
+ 0x11223344, //VECTOR 1 low part
+ 0x55667788, //VECTOR 1 hi part
+ 0x11112222,
+ 0x33334444
+
+};
+
+const char test_plain_data[TEST_DATA_BYTE_LEN] ="\
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesen\
+t et pellentesque risus. Sed id gravida elit. Proin eget accumsa\
+n mi. Aliquam vitae dui porta, euismod velit viverra, elementum \
+lacus. Nunc turpis orci, venenatis vel vulputate nec, luctus sit\
+amet urna. Ut et nunc purus. Aliquam erat volutpat. Vestibulum n\
+ulla dolor, cursus vitae cursus eget, dapibus eget sapien. Integ\
+er justo eros, commodo ut massa eu, bibendum elementum tellus. N\
+am quis dolor in libero placerat congue. Sed sodales urna sceler\
+isque dui faucibus, vitae malesuada dui fermentum. Proin ultrici\
+es sit amet justo at ornare. Suspendisse efficitur purus nullam.";
+
+ALIGNED_VAR(4) uint32_t msg_clear[TEST_MSG_DATA_WORD_LEN];
+ALIGNED_VAR(4) uint32_t msg_encrypted[TEST_MSG_DATA_WORD_LEN];
+ALIGNED_VAR(4) uint32_t msg_decrypted[TEST_MSG_DATA_WORD_LEN];
+BaseSequentialStream * ts;
+
+#if CRYPTO_LOG_LEVEL == 1
+static uint32_t toBigEndian(uint32_t v)
+{
+ return (v & 0x000000ff) << 24u |
+ ( (v & 0x0000ff00) << 8u ) |
+ ( (v & 0x00ff0000) >> 8u ) |
+ ( (v & 0xff000000) >> 24u );
+}
+#endif
+
+void cryptoTest_setStream(BaseSequentialStream * s)
+{
+ ts = s;
+}
+
+void cryptoTest_printArray(const uint8_t *a,size_t len)
+{
+#if CRYPTO_LOG_LEVEL == 1
+ for(size_t i=0;i<len;i++)
+ {
+ chprintf(ts,"%02X",a[i]);
+ }
+ chprintf(ts,"\r\n");
+#else
+ (void)a;
+ (void)len;
+#endif
+}
+
+void cryptoTest_printArray32(bool isLE,const uint32_t *a,size_t len)
+{
+#if CRYPTO_LOG_LEVEL == 1
+ uint32_t data;
+
+ for(size_t i=0;i<len;i++)
+ {
+ if (isLE)
+ data = toBigEndian(a[i]);
+ else
+ data = a[i];
+
+ chprintf(ts,"%08X ",data);
+
+ }
+ chprintf(ts,"\r\n");
+#else
+ (void)isLE;
+ (void)a;
+ (void)len;
+#endif
+}
+
+
+
+#endif /* !defined(__DOXYGEN__) */
diff --git a/test/crypto/source/test/cry_test_root.h b/test/crypto/source/test/cry_test_root.h
new file mode 100644
index 000000000..2bb5ab029
--- /dev/null
+++ b/test/crypto/source/test/cry_test_root.h
@@ -0,0 +1,78 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file cry_test_root.h
+ * @brief Test Suite root structures header.
+ */
+
+#ifndef CRY_TEST_ROOT_H
+#define CRY_TEST_ROOT_H
+
+#include "ch_test.h"
+
+#include "cry_test_sequence_001.h"
+#include "cry_test_sequence_002.h"
+#include "cry_test_sequence_003.h"
+#include "cry_test_sequence_004.h"
+
+#if !defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+extern const testsuite_t cry_test_suite;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Shared definitions. */
+/*===========================================================================*/
+
+extern void cryptoTest_setStream(BaseSequentialStream * s);
+extern void cryptoTest_printArray32(bool isLE,const uint32_t *a,size_t len);
+#ifdef LOG_CRYPTO_DATA
+#define SHOW_ENCRYPDATA(w) cryptoTest_printArray32(true,msg_encrypted,w)
+#define SHOW_DECRYPDATA(w) cryptoTest_printArray32(true,msg_decrypted,w)
+#else
+#define SHOW_ENCRYPDATA(w)
+#define SHOW_DECRYPDATA(w)
+#endif
+
+#define TEST_DATA_BYTE_LEN 640
+#define TEST_DATA_WORD_LEN (TEST_DATA_BYTE_LEN / 4)
+
+
+#define TEST_MSG_DATA_BYTE_LEN 640
+#define TEST_MSG_DATA_WORD_LEN (TEST_MSG_DATA_BYTE_LEN / 4)
+
+extern const char test_plain_data[TEST_DATA_BYTE_LEN];
+extern uint32_t msg_clear[TEST_MSG_DATA_WORD_LEN];
+extern uint32_t msg_encrypted[TEST_MSG_DATA_WORD_LEN];
+extern uint32_t msg_decrypted[TEST_MSG_DATA_WORD_LEN];
+extern const uint32_t test_keys[8];
+extern const uint32_t test_vectors[4];
+
+
+#endif /* !defined(__DOXYGEN__) */
+
+#endif /* CRY_TEST_ROOT_H */
diff --git a/test/crypto/source/test/cry_test_sequence_001.c b/test/crypto/source/test/cry_test_sequence_001.c
new file mode 100644
index 000000000..3a45c786a
--- /dev/null
+++ b/test/crypto/source/test/cry_test_sequence_001.c
@@ -0,0 +1,393 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "hal.h"
+#include "cry_test_root.h"
+
+/**
+ * @file cry_test_sequence_001.c
+ * @brief Test Sequence 001 code.
+ *
+ * @page cry_test_sequence_001 [1] AES ECB
+ *
+ * File: @ref cry_test_sequence_001.c
+ *
+ * <h2>Description</h2>
+ * AES ECB.
+ *
+ * <h2>Test Cases</h2>
+ * - @subpage cry_test_001_001
+ * - @subpage cry_test_001_002
+ * .
+ */
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+#include <string.h>
+#include "ref_aes.h"
+static const CRYConfig config_Polling = {
+ TRANSFER_POLLING,
+ AES_CFBS_128, //cfbs
+ 0
+};
+
+static const CRYConfig config_DMA = {
+ TRANSFER_DMA,
+ AES_CFBS_128, //cfbs
+ 0
+};
+
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+/**
+ * @page cry_test_001_001 [1.1] AES ECB Polling
+ *
+ * <h2>Description</h2>
+ * testing AES ECB with various Keys.
+ *
+ * <h2>Test Steps</h2>
+ * - [1.1.1] loading the key with 16 byte size.
+ * - [1.1.2] Encrypt.
+ * - [1.1.3] Decrypt.
+ * - [1.1.4] loading the key with 24 byte size.
+ * - [1.1.5] Encrypt.
+ * - [1.1.6] Decrypt.
+ * - [1.1.7] loading the key with 32 byte size.
+ * - [1.1.8] Encrypt.
+ * - [1.1.9] Decrypt.
+ * .
+ */
+
+static void cry_test_001_001_setup(void) {
+ memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+ memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ cryStart(&CRYD1, &config_Polling);
+
+
+}
+
+static void cry_test_001_001_teardown(void) {
+ cryStop(&CRYD1);
+}
+
+static void cry_test_001_001_execute(void) {
+ cryerror_t ret;
+
+ /* [1.1.1] loading the key with 16 byte size.*/
+ test_set_step(1);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,16, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [1.1.2] Encrypt.*/
+ test_set_step(2);
+ {
+ ret = cryEncryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_ECB_128)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [1.1.3] Decrypt.*/
+ test_set_step(3);
+ {
+ ret = cryDecryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [1.1.4] loading the key with 24 byte size.*/
+ test_set_step(4);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,24, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [1.1.5] Encrypt.*/
+ test_set_step(5);
+ {
+ ret = cryEncryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_ECB_192)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [1.1.6] Decrypt.*/
+ test_set_step(6);
+ {
+ ret = cryDecryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [1.1.7] loading the key with 32 byte size.*/
+ test_set_step(7);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,32, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [1.1.8] Encrypt.*/
+ test_set_step(8);
+ {
+ ret = cryEncryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_ECB_256)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [1.1.9] Decrypt.*/
+ test_set_step(9);
+ {
+ ret = cryDecryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+}
+
+static const testcase_t cry_test_001_001 = {
+ "AES ECB Polling",
+ cry_test_001_001_setup,
+ cry_test_001_001_teardown,
+ cry_test_001_001_execute
+};
+
+/**
+ * @page cry_test_001_002 [1.2] AES ECB DMA
+ *
+ * <h2>Description</h2>
+ * testing AES ECB with various Keys.
+ *
+ * <h2>Test Steps</h2>
+ * - [1.2.1] loading the key with 16 byte size.
+ * - [1.2.2] Encrypt.
+ * - [1.2.3] Decrypt.
+ * - [1.2.4] loading the key with 24 byte size.
+ * - [1.2.5] Encrypt.
+ * - [1.2.6] Decrypt.
+ * - [1.2.7] loading the key with 32 byte size.
+ * - [1.2.8] Encrypt.
+ * - [1.2.9] Decrypt.
+ * .
+ */
+
+static void cry_test_001_002_setup(void) {
+ memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+ memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ cryStart(&CRYD1, &config_DMA);
+
+
+}
+
+static void cry_test_001_002_teardown(void) {
+ cryStop(&CRYD1);
+}
+
+static void cry_test_001_002_execute(void) {
+ cryerror_t ret;
+
+ /* [1.2.1] loading the key with 16 byte size.*/
+ test_set_step(1);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,16, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [1.2.2] Encrypt.*/
+ test_set_step(2);
+ {
+ ret = cryEncryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_ECB_128)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [1.2.3] Decrypt.*/
+ test_set_step(3);
+ {
+ ret = cryDecryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [1.2.4] loading the key with 24 byte size.*/
+ test_set_step(4);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,24, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [1.2.5] Encrypt.*/
+ test_set_step(5);
+ {
+ ret = cryEncryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_ECB_192)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [1.2.6] Decrypt.*/
+ test_set_step(6);
+ {
+ ret = cryDecryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [1.2.7] loading the key with 32 byte size.*/
+ test_set_step(7);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,32, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [1.2.8] Encrypt.*/
+ test_set_step(8);
+ {
+ ret = cryEncryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_ECB_256)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [1.2.9] Decrypt.*/
+ test_set_step(9);
+ {
+ ret = cryDecryptAES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+}
+
+static const testcase_t cry_test_001_002 = {
+ "AES ECB DMA",
+ cry_test_001_002_setup,
+ cry_test_001_002_teardown,
+ cry_test_001_002_execute
+};
+
+/****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Array of test cases.
+ */
+const testcase_t * const cry_test_sequence_001_array[] = {
+ &cry_test_001_001,
+ &cry_test_001_002,
+ NULL
+};
+
+/**
+ * @brief AES ECB.
+ */
+const testsequence_t cry_test_sequence_001 = {
+ "AES ECB",
+ cry_test_sequence_001_array
+};
diff --git a/test/crypto/source/test/cry_test_sequence_001.h b/test/crypto/source/test/cry_test_sequence_001.h
new file mode 100644
index 000000000..ca55338ea
--- /dev/null
+++ b/test/crypto/source/test/cry_test_sequence_001.h
@@ -0,0 +1,27 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file cry_test_sequence_001.h
+ * @brief Test Sequence 001 header.
+ */
+
+#ifndef CRY_TEST_SEQUENCE_001_H
+#define CRY_TEST_SEQUENCE_001_H
+
+extern const testsequence_t cry_test_sequence_001;
+
+#endif /* CRY_TEST_SEQUENCE_001_H */
diff --git a/test/crypto/source/test/cry_test_sequence_002.c b/test/crypto/source/test/cry_test_sequence_002.c
new file mode 100644
index 000000000..f8fdb739e
--- /dev/null
+++ b/test/crypto/source/test/cry_test_sequence_002.c
@@ -0,0 +1,393 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "hal.h"
+#include "cry_test_root.h"
+
+/**
+ * @file cry_test_sequence_002.c
+ * @brief Test Sequence 002 code.
+ *
+ * @page cry_test_sequence_002 [2] AES CFB
+ *
+ * File: @ref cry_test_sequence_002.c
+ *
+ * <h2>Description</h2>
+ * AES CFB.
+ *
+ * <h2>Test Cases</h2>
+ * - @subpage cry_test_002_001
+ * - @subpage cry_test_002_002
+ * .
+ */
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+#include <string.h>
+#include "ref_aes.h"
+static const CRYConfig config_Polling = {
+ TRANSFER_POLLING,
+ AES_CFBS_128, //cfbs
+ 0
+};
+
+static const CRYConfig config_DMA = {
+ TRANSFER_DMA,
+ AES_CFBS_128, //cfbs
+ 0
+};
+
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+/**
+ * @page cry_test_002_001 [2.1] AES CFB Polling
+ *
+ * <h2>Description</h2>
+ * testing AES CFB with various Keys.
+ *
+ * <h2>Test Steps</h2>
+ * - [2.1.1] loading the key with 16 byte size.
+ * - [2.1.2] Encrypt.
+ * - [2.1.3] Decrypt.
+ * - [2.1.4] loading the key with 24 byte size.
+ * - [2.1.5] Encrypt.
+ * - [2.1.6] Decrypt.
+ * - [2.1.7] loading the key with 32 byte size.
+ * - [2.1.8] Encrypt.
+ * - [2.1.9] Decrypt.
+ * .
+ */
+
+static void cry_test_002_001_setup(void) {
+ memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+ memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ cryStart(&CRYD1, &config_Polling);
+
+
+}
+
+static void cry_test_002_001_teardown(void) {
+ cryStop(&CRYD1);
+}
+
+static void cry_test_002_001_execute(void) {
+ cryerror_t ret;
+
+ /* [2.1.1] loading the key with 16 byte size.*/
+ test_set_step(1);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,16, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [2.1.2] Encrypt.*/
+ test_set_step(2);
+ {
+ ret = cryEncryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CFB_128)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [2.1.3] Decrypt.*/
+ test_set_step(3);
+ {
+ ret = cryDecryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [2.1.4] loading the key with 24 byte size.*/
+ test_set_step(4);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,24, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [2.1.5] Encrypt.*/
+ test_set_step(5);
+ {
+ ret = cryEncryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CFB_192)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [2.1.6] Decrypt.*/
+ test_set_step(6);
+ {
+ ret = cryDecryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [2.1.7] loading the key with 32 byte size.*/
+ test_set_step(7);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,32, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [2.1.8] Encrypt.*/
+ test_set_step(8);
+ {
+ ret = cryEncryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CFB_256)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [2.1.9] Decrypt.*/
+ test_set_step(9);
+ {
+ ret = cryDecryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+}
+
+static const testcase_t cry_test_002_001 = {
+ "AES CFB Polling",
+ cry_test_002_001_setup,
+ cry_test_002_001_teardown,
+ cry_test_002_001_execute
+};
+
+/**
+ * @page cry_test_002_002 [2.2] AES CFB DMA
+ *
+ * <h2>Description</h2>
+ * testing AES CFB with various Keys.
+ *
+ * <h2>Test Steps</h2>
+ * - [2.2.1] loading the key with 16 byte size.
+ * - [2.2.2] Encrypt.
+ * - [2.2.3] Decrypt.
+ * - [2.2.4] loading the key with 24 byte size.
+ * - [2.2.5] Encrypt.
+ * - [2.2.6] Decrypt.
+ * - [2.2.7] loading the key with 32 byte size.
+ * - [2.2.8] Encrypt.
+ * - [2.2.9] Decrypt.
+ * .
+ */
+
+static void cry_test_002_002_setup(void) {
+ memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+ memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ cryStart(&CRYD1, &config_DMA);
+
+
+}
+
+static void cry_test_002_002_teardown(void) {
+ cryStop(&CRYD1);
+}
+
+static void cry_test_002_002_execute(void) {
+ cryerror_t ret;
+
+ /* [2.2.1] loading the key with 16 byte size.*/
+ test_set_step(1);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,16, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [2.2.2] Encrypt.*/
+ test_set_step(2);
+ {
+ ret = cryEncryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CFB_128)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [2.2.3] Decrypt.*/
+ test_set_step(3);
+ {
+ ret = cryDecryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [2.2.4] loading the key with 24 byte size.*/
+ test_set_step(4);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,24, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [2.2.5] Encrypt.*/
+ test_set_step(5);
+ {
+ ret = cryEncryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CFB_192)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [2.2.6] Decrypt.*/
+ test_set_step(6);
+ {
+ ret = cryDecryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [2.2.7] loading the key with 32 byte size.*/
+ test_set_step(7);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,32, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [2.2.8] Encrypt.*/
+ test_set_step(8);
+ {
+ ret = cryEncryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CFB_256)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [2.2.9] Decrypt.*/
+ test_set_step(9);
+ {
+ ret = cryDecryptAES_CFB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+}
+
+static const testcase_t cry_test_002_002 = {
+ "AES CFB DMA",
+ cry_test_002_002_setup,
+ cry_test_002_002_teardown,
+ cry_test_002_002_execute
+};
+
+/****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Array of test cases.
+ */
+const testcase_t * const cry_test_sequence_002_array[] = {
+ &cry_test_002_001,
+ &cry_test_002_002,
+ NULL
+};
+
+/**
+ * @brief AES CFB.
+ */
+const testsequence_t cry_test_sequence_002 = {
+ "AES CFB",
+ cry_test_sequence_002_array
+};
diff --git a/test/crypto/source/test/cry_test_sequence_002.h b/test/crypto/source/test/cry_test_sequence_002.h
new file mode 100644
index 000000000..eb5966111
--- /dev/null
+++ b/test/crypto/source/test/cry_test_sequence_002.h
@@ -0,0 +1,27 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file cry_test_sequence_002.h
+ * @brief Test Sequence 002 header.
+ */
+
+#ifndef CRY_TEST_SEQUENCE_002_H
+#define CRY_TEST_SEQUENCE_002_H
+
+extern const testsequence_t cry_test_sequence_002;
+
+#endif /* CRY_TEST_SEQUENCE_002_H */
diff --git a/test/crypto/source/test/cry_test_sequence_003.c b/test/crypto/source/test/cry_test_sequence_003.c
new file mode 100644
index 000000000..7ef920ef2
--- /dev/null
+++ b/test/crypto/source/test/cry_test_sequence_003.c
@@ -0,0 +1,393 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "hal.h"
+#include "cry_test_root.h"
+
+/**
+ * @file cry_test_sequence_003.c
+ * @brief Test Sequence 003 code.
+ *
+ * @page cry_test_sequence_003 [3] AES CBC
+ *
+ * File: @ref cry_test_sequence_003.c
+ *
+ * <h2>Description</h2>
+ * AES CBC.
+ *
+ * <h2>Test Cases</h2>
+ * - @subpage cry_test_003_001
+ * - @subpage cry_test_003_002
+ * .
+ */
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+#include <string.h>
+#include "ref_aes.h"
+static const CRYConfig config_Polling = {
+ TRANSFER_POLLING,
+ AES_CFBS_128, //cfbs
+ 0
+};
+
+static const CRYConfig config_DMA = {
+ TRANSFER_DMA,
+ AES_CFBS_128, //cfbs
+ 0
+};
+
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+/**
+ * @page cry_test_003_001 [3.1] AES CBC Polling
+ *
+ * <h2>Description</h2>
+ * testing AES CBC with various Keys.
+ *
+ * <h2>Test Steps</h2>
+ * - [3.1.1] loading the key with 16 byte size.
+ * - [3.1.2] Encrypt.
+ * - [3.1.3] Decrypt.
+ * - [3.1.4] loading the key with 24 byte size.
+ * - [3.1.5] Encrypt.
+ * - [3.1.6] Decrypt.
+ * - [3.1.7] loading the key with 32 byte size.
+ * - [3.1.8] Encrypt.
+ * - [3.1.9] Decrypt.
+ * .
+ */
+
+static void cry_test_003_001_setup(void) {
+ memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+ memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ cryStart(&CRYD1, &config_Polling);
+
+
+}
+
+static void cry_test_003_001_teardown(void) {
+ cryStop(&CRYD1);
+}
+
+static void cry_test_003_001_execute(void) {
+ cryerror_t ret;
+
+ /* [3.1.1] loading the key with 16 byte size.*/
+ test_set_step(1);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,16, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [3.1.2] Encrypt.*/
+ test_set_step(2);
+ {
+ ret = cryEncryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CBC_128)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [3.1.3] Decrypt.*/
+ test_set_step(3);
+ {
+ ret = cryDecryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [3.1.4] loading the key with 24 byte size.*/
+ test_set_step(4);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,24, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [3.1.5] Encrypt.*/
+ test_set_step(5);
+ {
+ ret = cryEncryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CBC_192)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [3.1.6] Decrypt.*/
+ test_set_step(6);
+ {
+ ret = cryDecryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [3.1.7] loading the key with 32 byte size.*/
+ test_set_step(7);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,32, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [3.1.8] Encrypt.*/
+ test_set_step(8);
+ {
+ ret = cryEncryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CBC_256)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [3.1.9] Decrypt.*/
+ test_set_step(9);
+ {
+ ret = cryDecryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+}
+
+static const testcase_t cry_test_003_001 = {
+ "AES CBC Polling",
+ cry_test_003_001_setup,
+ cry_test_003_001_teardown,
+ cry_test_003_001_execute
+};
+
+/**
+ * @page cry_test_003_002 [3.2] AES CBC DMA
+ *
+ * <h2>Description</h2>
+ * testing AES CBC with various Keys.
+ *
+ * <h2>Test Steps</h2>
+ * - [3.2.1] loading the key with 16 byte size.
+ * - [3.2.2] Encrypt.
+ * - [3.2.3] Decrypt.
+ * - [3.2.4] loading the key with 24 byte size.
+ * - [3.2.5] Encrypt.
+ * - [3.2.6] Decrypt.
+ * - [3.2.7] loading the key with 32 byte size.
+ * - [3.2.8] Encrypt.
+ * - [3.2.9] Decrypt.
+ * .
+ */
+
+static void cry_test_003_002_setup(void) {
+ memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+ memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ cryStart(&CRYD1, &config_DMA);
+
+
+}
+
+static void cry_test_003_002_teardown(void) {
+ cryStop(&CRYD1);
+}
+
+static void cry_test_003_002_execute(void) {
+ cryerror_t ret;
+
+ /* [3.2.1] loading the key with 16 byte size.*/
+ test_set_step(1);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,16, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [3.2.2] Encrypt.*/
+ test_set_step(2);
+ {
+ ret = cryEncryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CBC_128)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [3.2.3] Decrypt.*/
+ test_set_step(3);
+ {
+ ret = cryDecryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [3.2.4] loading the key with 24 byte size.*/
+ test_set_step(4);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,24, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [3.2.5] Encrypt.*/
+ test_set_step(5);
+ {
+ ret = cryEncryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CBC_192)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [3.2.6] Decrypt.*/
+ test_set_step(6);
+ {
+ ret = cryDecryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [3.2.7] loading the key with 32 byte size.*/
+ test_set_step(7);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,32, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [3.2.8] Encrypt.*/
+ test_set_step(8);
+ {
+ ret = cryEncryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refAES_CBC_256)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [3.2.9] Decrypt.*/
+ test_set_step(9);
+ {
+ ret = cryDecryptAES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+}
+
+static const testcase_t cry_test_003_002 = {
+ "AES CBC DMA",
+ cry_test_003_002_setup,
+ cry_test_003_002_teardown,
+ cry_test_003_002_execute
+};
+
+/****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Array of test cases.
+ */
+const testcase_t * const cry_test_sequence_003_array[] = {
+ &cry_test_003_001,
+ &cry_test_003_002,
+ NULL
+};
+
+/**
+ * @brief AES CBC.
+ */
+const testsequence_t cry_test_sequence_003 = {
+ "AES CBC",
+ cry_test_sequence_003_array
+};
diff --git a/test/crypto/source/test/cry_test_sequence_003.h b/test/crypto/source/test/cry_test_sequence_003.h
new file mode 100644
index 000000000..46bb52fc9
--- /dev/null
+++ b/test/crypto/source/test/cry_test_sequence_003.h
@@ -0,0 +1,27 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file cry_test_sequence_003.h
+ * @brief Test Sequence 003 header.
+ */
+
+#ifndef CRY_TEST_SEQUENCE_003_H
+#define CRY_TEST_SEQUENCE_003_H
+
+extern const testsequence_t cry_test_sequence_003;
+
+#endif /* CRY_TEST_SEQUENCE_003_H */
diff --git a/test/crypto/source/test/cry_test_sequence_004.c b/test/crypto/source/test/cry_test_sequence_004.c
new file mode 100644
index 000000000..2b41f2b91
--- /dev/null
+++ b/test/crypto/source/test/cry_test_sequence_004.c
@@ -0,0 +1,633 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "hal.h"
+#include "cry_test_root.h"
+
+/**
+ * @file cry_test_sequence_004.c
+ * @brief Test Sequence 004 code.
+ *
+ * @page cry_test_sequence_004 [4] (T)DES
+ *
+ * File: @ref cry_test_sequence_004.c
+ *
+ * <h2>Description</h2>
+ * (T)DES testing.
+ *
+ * <h2>Test Cases</h2>
+ * - @subpage cry_test_004_001
+ * - @subpage cry_test_004_002
+ * - @subpage cry_test_004_003
+ * - @subpage cry_test_004_004
+ * - @subpage cry_test_004_005
+ * .
+ */
+
+/****************************************************************************
+ * Shared code.
+ ****************************************************************************/
+
+#include <string.h>
+#include "ref_des.h"
+static const CRYConfig configDES_Polling=
+{
+ TRANSFER_POLLING,
+ 0,
+ TDES_ALGO_SINGLE
+};
+static const CRYConfig configTDES_Polling=
+{
+ TRANSFER_POLLING,
+ 0,
+ TDES_ALGO_TRIPLE
+};
+
+static const CRYConfig configTDES_DMA=
+{
+ TRANSFER_DMA,
+ 0,
+ TDES_ALGO_TRIPLE
+};
+
+
+
+/****************************************************************************
+ * Test cases.
+ ****************************************************************************/
+
+/**
+ * @page cry_test_004_001 [4.1] DES Polling
+ *
+ * <h2>Description</h2>
+ * testing DES in polled mode.
+ *
+ * <h2>Test Steps</h2>
+ * - [4.1.1] loading the key with 8 byte size.
+ * - [4.1.2] Encrypt.
+ * - [4.1.3] Decrypt.
+ * .
+ */
+
+static void cry_test_004_001_setup(void) {
+ memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+ memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ cryStart(&CRYD1, &configDES_Polling);
+
+
+}
+
+static void cry_test_004_001_teardown(void) {
+ cryStop(&CRYD1);
+}
+
+static void cry_test_004_001_execute(void) {
+ cryerror_t ret;
+
+ /* [4.1.1] loading the key with 8 byte size.*/
+ test_set_step(1);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,8, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [4.1.2] Encrypt.*/
+ test_set_step(2);
+ {
+ ret = cryEncryptDES(&CRYD1, 0, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(2);
+
+ for (int i = 0; i < 2; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refDES_ECB_8)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [4.1.3] Decrypt.*/
+ test_set_step(3);
+ {
+ ret = cryDecryptDES(&CRYD1, 0, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(2);
+
+ for (int i = 0; i < 2; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+}
+
+static const testcase_t cry_test_004_001 = {
+ "DES Polling",
+ cry_test_004_001_setup,
+ cry_test_004_001_teardown,
+ cry_test_004_001_execute
+};
+
+/**
+ * @page cry_test_004_002 [4.2] TDES CBC Polling
+ *
+ * <h2>Description</h2>
+ * testing TDES CBC in polled mode.
+ *
+ * <h2>Test Steps</h2>
+ * - [4.2.1] loading the key with 16 byte size.
+ * - [4.2.2] Encrypt.
+ * - [4.2.3] Decrypt.
+ * - [4.2.4] loading the key with 24 byte size.
+ * - [4.2.5] Encrypt.
+ * - [4.2.6] Decrypt.
+ * .
+ */
+
+static void cry_test_004_002_setup(void) {
+ memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+ memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ cryStart(&CRYD1, &configTDES_Polling);
+
+
+}
+
+static void cry_test_004_002_teardown(void) {
+ cryStop(&CRYD1);
+}
+
+static void cry_test_004_002_execute(void) {
+ cryerror_t ret;
+
+ /* [4.2.1] loading the key with 16 byte size.*/
+ test_set_step(1);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,16, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [4.2.2] Encrypt.*/
+ test_set_step(2);
+ {
+ ret = cryEncryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_CBC_16)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [4.2.3] Decrypt.*/
+ test_set_step(3);
+ {
+ ret = cryDecryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [4.2.4] loading the key with 24 byte size.*/
+ test_set_step(4);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,24, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [4.2.5] Encrypt.*/
+ test_set_step(5);
+ {
+ ret = cryEncryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_CBC_24)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [4.2.6] Decrypt.*/
+ test_set_step(6);
+ {
+ ret = cryDecryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+}
+
+static const testcase_t cry_test_004_002 = {
+ "TDES CBC Polling",
+ cry_test_004_002_setup,
+ cry_test_004_002_teardown,
+ cry_test_004_002_execute
+};
+
+/**
+ * @page cry_test_004_003 [4.3] TDES ECB Polling
+ *
+ * <h2>Description</h2>
+ * testing TDES ECB in polling mode.
+ *
+ * <h2>Test Steps</h2>
+ * - [4.3.1] loading the key with 16 byte size.
+ * - [4.3.2] Encrypt.
+ * - [4.3.3] Decrypt.
+ * - [4.3.4] loading the key with 24 byte size.
+ * - [4.3.5] Encrypt.
+ * - [4.3.6] Decrypt.
+ * .
+ */
+
+static void cry_test_004_003_setup(void) {
+ memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+ memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ cryStart(&CRYD1, &configTDES_Polling);
+
+
+}
+
+static void cry_test_004_003_teardown(void) {
+ cryStop(&CRYD1);
+}
+
+static void cry_test_004_003_execute(void) {
+ cryerror_t ret;
+
+ /* [4.3.1] loading the key with 16 byte size.*/
+ test_set_step(1);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,16, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [4.3.2] Encrypt.*/
+ test_set_step(2);
+ {
+ ret = cryEncryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_ECB_16)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [4.3.3] Decrypt.*/
+ test_set_step(3);
+ {
+ ret = cryDecryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [4.3.4] loading the key with 24 byte size.*/
+ test_set_step(4);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,24, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [4.3.5] Encrypt.*/
+ test_set_step(5);
+ {
+ ret = cryEncryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_ECB_24)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [4.3.6] Decrypt.*/
+ test_set_step(6);
+ {
+ ret = cryDecryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+}
+
+static const testcase_t cry_test_004_003 = {
+ "TDES ECB Polling",
+ cry_test_004_003_setup,
+ cry_test_004_003_teardown,
+ cry_test_004_003_execute
+};
+
+/**
+ * @page cry_test_004_004 [4.4] TDES CBC DMA
+ *
+ * <h2>Description</h2>
+ * testing TDES CBC in polled mode.
+ *
+ * <h2>Test Steps</h2>
+ * - [4.4.1] loading the key with 16 byte size.
+ * - [4.4.2] Encrypt.
+ * - [4.4.3] Decrypt.
+ * - [4.4.4] loading the key with 24 byte size.
+ * - [4.4.5] Encrypt.
+ * - [4.4.6] Decrypt.
+ * .
+ */
+
+static void cry_test_004_004_setup(void) {
+ memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+ memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ cryStart(&CRYD1, &configTDES_DMA);
+
+
+}
+
+static void cry_test_004_004_teardown(void) {
+ cryStop(&CRYD1);
+}
+
+static void cry_test_004_004_execute(void) {
+ cryerror_t ret;
+
+ /* [4.4.1] loading the key with 16 byte size.*/
+ test_set_step(1);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,16, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [4.4.2] Encrypt.*/
+ test_set_step(2);
+ {
+ ret = cryEncryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_CBC_16)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [4.4.3] Decrypt.*/
+ test_set_step(3);
+ {
+ ret = cryDecryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [4.4.4] loading the key with 24 byte size.*/
+ test_set_step(4);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,24, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [4.4.5] Encrypt.*/
+ test_set_step(5);
+ {
+ ret = cryEncryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_CBC_24)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [4.4.6] Decrypt.*/
+ test_set_step(6);
+ {
+ ret = cryDecryptDES_CBC(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted,(uint8_t*)test_vectors);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+}
+
+static const testcase_t cry_test_004_004 = {
+ "TDES CBC DMA",
+ cry_test_004_004_setup,
+ cry_test_004_004_teardown,
+ cry_test_004_004_execute
+};
+
+/**
+ * @page cry_test_004_005 [4.5] TDES ECB DMA
+ *
+ * <h2>Description</h2>
+ * testing TDES ECB in DMA mode.
+ *
+ * <h2>Test Steps</h2>
+ * - [4.5.1] loading the key with 16 byte size.
+ * - [4.5.2] Encrypt.
+ * - [4.5.3] Decrypt.
+ * - [4.5.4] loading the key with 24 byte size.
+ * - [4.5.5] Encrypt.
+ * - [4.5.6] Decrypt.
+ * .
+ */
+
+static void cry_test_004_005_setup(void) {
+ memcpy((char*) msg_clear, test_plain_data, TEST_DATA_BYTE_LEN);
+ memset(msg_encrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(msg_decrypted, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ cryStart(&CRYD1, &configTDES_DMA);
+
+
+}
+
+static void cry_test_004_005_teardown(void) {
+ cryStop(&CRYD1);
+}
+
+static void cry_test_004_005_execute(void) {
+ cryerror_t ret;
+
+ /* [4.5.1] loading the key with 16 byte size.*/
+ test_set_step(1);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,16, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [4.5.2] Encrypt.*/
+ test_set_step(2);
+ {
+ ret = cryEncryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_ECB_16)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [4.5.3] Decrypt.*/
+ test_set_step(3);
+ {
+ ret = cryDecryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+
+ /* [4.5.4] loading the key with 24 byte size.*/
+ test_set_step(4);
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_des,24, (uint8_t *) test_keys);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* [4.5.5] Encrypt.*/
+ test_set_step(5);
+ {
+ ret = cryEncryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_clear, (uint8_t*) msg_encrypted);
+
+ test_assert(ret == CRY_NOERROR, "encrypt failed");
+
+ SHOW_ENCRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_encrypted[i] == ((uint32_t*) refTDES_ECB_24)[i], "encrypt mismatch");
+ }
+
+ }
+
+ /* [4.5.6] Decrypt.*/
+ test_set_step(6);
+ {
+ ret = cryDecryptDES_ECB(&CRYD1, 0,TEST_DATA_BYTE_LEN, (uint8_t*) msg_encrypted, (uint8_t*) msg_decrypted);
+
+ test_assert(ret == CRY_NOERROR, "decrypt failed");
+
+ SHOW_DECRYPDATA(TEST_DATA_WORD_LEN);
+
+ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
+ test_assert(msg_decrypted[i] == msg_clear[i], "decrypt mismatch");
+ }
+
+ }
+}
+
+static const testcase_t cry_test_004_005 = {
+ "TDES ECB DMA",
+ cry_test_004_005_setup,
+ cry_test_004_005_teardown,
+ cry_test_004_005_execute
+};
+
+/****************************************************************************
+ * Exported data.
+ ****************************************************************************/
+
+/**
+ * @brief Array of test cases.
+ */
+const testcase_t * const cry_test_sequence_004_array[] = {
+ &cry_test_004_001,
+ &cry_test_004_002,
+ &cry_test_004_003,
+ &cry_test_004_004,
+ &cry_test_004_005,
+ NULL
+};
+
+/**
+ * @brief (T)DES.
+ */
+const testsequence_t cry_test_sequence_004 = {
+ "(T)DES",
+ cry_test_sequence_004_array
+};
diff --git a/test/crypto/source/test/cry_test_sequence_004.h b/test/crypto/source/test/cry_test_sequence_004.h
new file mode 100644
index 000000000..b351fd35d
--- /dev/null
+++ b/test/crypto/source/test/cry_test_sequence_004.h
@@ -0,0 +1,27 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file cry_test_sequence_004.h
+ * @brief Test Sequence 004 header.
+ */
+
+#ifndef CRY_TEST_SEQUENCE_004_H
+#define CRY_TEST_SEQUENCE_004_H
+
+extern const testsequence_t cry_test_sequence_004;
+
+#endif /* CRY_TEST_SEQUENCE_004_H */
diff --git a/test/crypto/source/testref/ref_aes.c b/test/crypto/source/testref/ref_aes.c
new file mode 100644
index 000000000..11c6ef480
--- /dev/null
+++ b/test/crypto/source/testref/ref_aes.c
@@ -0,0 +1,822 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "hal.h"
+
+const uint8_t refAES_ECB_128[]={
+0x65,0x86,0x9F,0x20,0x63,0x89,0x1C,0x2F,0x20,0x5D,
+0x94,0x7F,0x55,0x67,0x58,0xFF,0xE9,0xFE,0x4F,0xD7,
+0x93,0x03,0x43,0xDD,0xD0,0x7E,0xA3,0x37,0x58,0x83,
+0x22,0xA2,0x2D,0x61,0xA0,0x41,0x57,0x31,0x65,0x0F,
+0x7A,0x08,0x8F,0xD8,0x9C,0xA3,0xAB,0xC3,0x8E,0x6E,
+0x16,0x11,0xED,0x0C,0xE4,0xA8,0x6C,0x86,0xBB,0x99,
+0x3F,0x79,0x0A,0xAC,0x9F,0xD6,0xFC,0xCC,0xD9,0x71,
+0x36,0x46,0x6F,0xFA,0xD7,0x61,0xCE,0x1F,0xF0,0x9C,
+0xE8,0xE8,0x18,0x39,0x47,0x74,0x2C,0xCA,0x5A,0xDA,
+0x5A,0x60,0xD3,0xD7,0x22,0xD5,0x3E,0x6A,0xD7,0x28,
+0x59,0xF6,0x1C,0x3D,0x6E,0x02,0x06,0x28,0xE0,0x17,
+0x7B,0x1F,0xC2,0xFD,0xE5,0x7C,0x11,0xE7,0x3D,0xC2,
+0x82,0xC9,0xBB,0x62,0xA8,0xCB,0xF0,0x9A,0x9A,0x9E,
+0x75,0x54,0x49,0xEE,0x97,0x66,0x66,0x00,0x79,0xEC,
+0x9E,0xBF,0x91,0x47,0xCE,0x10,0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xFC,
+0x2B,0x31,0xFA,0xD7,0x0A,0x23,0x48,0x5C,0x5B,0x53,
+0x18,0x5A,0xC6,0x7F,0x14,0x21,0xF0,0xB3,0x89,0xFA,
+0xEA,0xF3,0x62,0x51,0x75,0x09,0xAA,0x5A,0x7A,0x51,
+0x23,0xA4,0x86,0xAF,0xFB,0xFF,0xDE,0x48,0xE2,0xEA,
+0x13,0xFC,0x81,0x36,0x17,0x36,0xED,0xDF,0x71,0x9E,
+0x58,0x65,0xFF,0x95,0xA4,0x95,0xF3,0x3D,0xEC,0xC7,
+0xFF,0x19,0x73,0x89,0x2A,0x59,0x60,0x71,0x81,0x4F,
+0x6B,0xB1,0xE4,0x35,0xCA,0x55,0x3B,0x47,0x24,0xBA,
+0x14,0x76,0x21,0xEE,0x6D,0x97,0x1B,0x27,0x87,0x98,
+0x39,0x11,0xEC,0x86,0x8F,0x21,0x61,0x87,0xF3,0xF9,
+0xC1,0x85,0x5D,0x38,0xE9,0xC5,0x72,0xA1,0xA1,0x39,
+0x75,0x41,0x39,0x36,0x32,0xDF,0x6D,0x16,0x5D,0x8A,
+0x23,0x79,0x58,0x0B,0x08,0xF8,0x6C,0x75,0x00,0x2B,
+0xE1,0x1D,0x24,0xEB,0x3B,0xD2,0x9E,0x50,0x94,0xC5,
+0xE1,0x34,0xD0,0xE9,0x86,0x8E,0x48,0xD8,0x98,0xA4,
+0xA3,0x47,0x44,0xD7,0xA8,0xDB,0xF9,0x7E,0x31,0x58,
+0x14,0x24,0xFF,0x89,0x26,0x0D,0x08,0x12,0xC0,0x07,
+0x94,0x51,0x0F,0xA8,0xF8,0x92,0xCB,0x85,0x19,0x5A,
+0xDD,0xAD,0x4A,0x56,0xBA,0x5F,0x6E,0xAE,0x59,0x78,
+0x0E,0x25,0x03,0x8A,0xA8,0x37,0xA9,0xB5,0x5F,0x08,
+0x5D,0x1D,0xD9,0xBE,0xCE,0x63,0x91,0x9B,0x13,0x01,
+0x7C,0x17,0xCE,0x8C,0x67,0xA7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7D,0x83,
+0x1E,0xAA,0x4B,0x19,0x27,0xC8,0x12,0x1B,0x46,0x77,
+0x9E,0x21,0xC8,0x3B,0xA3,0xFF,0x8B,0x0C,0x0C,0x47,
+0xD9,0xEA,0xA8,0x4F,0x40,0x42,0x5B,0x4A,0xEA,0xF8,
+0x13,0x96,0xAF,0x66,0x90,0xE4,0x8D,0xB8,0x18,0x65,
+0x67,0x21,0x97,0xFA,0xF1,0x67,0x11,0x2E,0x01,0x87,
+0xE1,0x7E,0x18,0x48,0x4F,0x9E,0x84,0xDB,0x50,0xD8,
+0xDB,0x63,0x4B,0x95,0x89,0x42,0x2E,0xE2,0xF6,0xD7,
+0xD6,0xEC,0x92,0x55,0x39,0x25,0x89,0x94,0xE2,0x68,
+0xE3,0x6B,0x76,0x60,0xA0,0xA1,0xA5,0x2F,0xA1,0x92,
+0x8E,0xCE,0xED,0x72,0xA0,0x22,0x66,0x48,0xA2,0x24,
+0xD2,0x1D,0x48,0xF2,0x1C,0xA6,0x2E,0x8E,0x78,0xAB,
+0xDB,0x02,0x10,0x74,0x03,0x9B,0x5E,0x41,0xF0,0xA4,
+0x81,0xF8,0x7B,0xC2,0x87,0x06,0x0F,0xED,0x44,0xAE,
+0xB2,0x44,
+};
+const uint8_t refAES_CFB_128[]={
+0xFF,0x50,0x83,0x66,0x68,0x80,0x52,0xE8,0xAE,0x43,
+0xC1,0xCC,0x8D,0x60,0x9C,0xF9,0x00,0xA8,0x01,0xB3,
+0xCE,0x04,0x10,0xA9,0xFC,0xD8,0x04,0x5E,0x03,0xAF,
+0x4A,0xB6,0xC2,0xE2,0x1E,0xDF,0xFA,0xE0,0x2F,0x90,
+0x8C,0x7A,0xC2,0x99,0xD4,0xA0,0x57,0x10,0xE8,0x03,
+0x53,0x53,0x93,0x1C,0x6F,0x08,0xF0,0x90,0x27,0x1D,
+0xFD,0x31,0xB9,0xD6,0x8C,0x26,0xBA,0x5C,0xD4,0x2A,
+0x9A,0xF6,0x33,0x28,0x23,0xD2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C9,0x62,0xD5,0x97,0x3E,0x05,0xE0,0x7B,0xBD,0x43,
+0xF5,0xD8,0xDE,0x85,0x25,0xDC,0xDC,0x41,0x76,0x04,
+0x6E,0x03,0x07,0xF1,0xA2,0xBA,0x3B,0x3E,0x16,0x63,
+0x09,0x3B,0x4C,0x60,0xC1,0x13,0x63,0xAC,0x31,0x99,
+0xBD,0xFE,0x2C,0x4D,0x03,0xDF,0xAC,0xF5,0x97,0xFF,
+0x28,0xC4,0x7E,0x0C,0x57,0x20,0x12,0xF3,0x34,0x44,
+0xEE,0x1B,0xC5,0x79,0xC1,0x61,0x06,0x38,0x58,0x65,
+0x89,0xFD,0xAF,0x77,0x69,0x49,0xA7,0x40,0x02,0x3F,
+0xD8,0x0F,0x10,0x20,0x0F,0x35,0x19,0x09,0xF1,0xD6,
+0xB9,0x33,0xAF,0xFE,0x81,0x6A,0x75,0x9E,0x98,0x24,
+0x3F,0x6F,0x8F,0x4E,0xFC,0x72,0x08,0x7C,0xAF,0x56,
+0x19,0x90,0x0D,0x56,0xF0,0x80,0x88,0x77,0xAA,0x16,
+0x65,0x55,0x27,0x5B,0x4C,0x23,0x1C,0x04,0x46,0xB0,
+0xA7,0x5D,0x68,0xD0,0x3D,0x8A,0xEF,0x73,0xEA,0xAF,
+0x15,0x1D,0x2A,0xCC,0x86,0x42,0x64,0x54,0xBF,0x05,
+0x98,0xFF,
+};
+const uint8_t refAES_CFB_256[]={
+0x5F,0xD7,0x96,0x16,0x8E,0x0C,0x4E,0xD1,0x60,0x71,
+0xF0,0xD6,0x8A,0x48,0x9C,0x69,0x70,0xB0,0x34,0x77,
+0x3C,0xF7,0x27,0xFE,0xD2,0x46,0x63,0xE5,0x94,0x1A,
+0xFD,0x2A,0xF9,0x81,0x5D,0xE0,0x67,0xB7,0xA9,0x43,
+0x46,0x4F,0xE3,0x43,0xF6,0xBE,0x30,0xEA,0x54,0x49,
+0xAC,0xC4,0xE1,0x45,0xB4,0x2A,0xDF,0x02,0x52,0x90,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,0x59,0xEA,0x21,0xA5,
+0xDC,0xE9,0x12,0x1C,0x21,0x14,0xBC,0x3C,0x47,0xF5,
+0xC1,0xCF,0x87,0x3B,0x52,0x01,0xD3,0x5F,0xDA,0xD5,
+0x57,0x15,0xA8,0x56,0x3A,0x86,0xFE,0x63,0x4F,0x34,
+0x85,0xAE,0x32,0x07,0x29,0x15,0xDA,0xCE,0xB5,0x5A,
+0x07,0xD4,0x8C,0xAE,0x16,0x77,0xFF,0xB8,0xCA,0x08,
+0x8F,0x06,0x96,0xC7,0x8A,0x0D,0xD0,0x95,0x38,0x8D,
+0x34,0x0E,0x57,0x35,0x8B,0xEE,0x17,0x23,0x6D,0x91,
+0xD6,0xEB,0x25,0x74,0x0C,0x0A,0x90,0x30,0x81,0x16,
+0xA5,0xBE,0x83,0xF9,0xC4,0xA1,0xE6,0x44,0x5B,0x8F,
+0xCA,0x4D,0x69,0xA6,0x77,0x3A,0x57,0x1E,0x4A,0x0C,
+0xE8,0x9E,0x73,0xF4,0x35,0x09,0x2C,0x04,0xB4,0x24,
+0xDF,0xED,0xB2,0x6F,0x41,0x54,0xC1,0x7D,0xC5,0xFF,
+0xFE,0xD7,0x20,0x02,0x1F,0x60,0xB8,0xD5,0xFB,0xC6,
+0x1F,0xEA,0x1C,0xDA,0xDD,0x5B,0x73,0x41,0x01,0xF6,
+0x4F,0xF4,0xB2,0xE1,0x30,0xC6,0xEE,0x72,0xF0,0x5D,
+0x34,0x2D,
+};
diff --git a/test/crypto/source/testref/ref_aes.h b/test/crypto/source/testref/ref_aes.h
new file mode 100644
index 000000000..a4e6759fc
--- /dev/null
+++ b/test/crypto/source/testref/ref_aes.h
@@ -0,0 +1,31 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+#ifndef TEST_REF_AES_H_
+#define TEST_REF_AES_H_
+
+extern const uint8_t refAES_ECB_128[];
+extern const uint8_t refAES_ECB_192[];
+extern const uint8_t refAES_ECB_256[];
+extern const uint8_t refAES_CBC_128[];
+extern const uint8_t refAES_CBC_192[];
+extern const uint8_t refAES_CBC_256[];
+extern const uint8_t refAES_CTR_128[];
+extern const uint8_t refAES_CTR_192[];
+extern const uint8_t refAES_CTR_256[];
+extern const uint8_t refAES_CFB_128[];
+extern const uint8_t refAES_CFB_192[];
+extern const uint8_t refAES_CFB_256[];
+#endif //TEST_REF_AES_H_
diff --git a/test/crypto/source/testref/ref_des.c b/test/crypto/source/testref/ref_des.c
new file mode 100644
index 000000000..fca75627c
--- /dev/null
+++ b/test/crypto/source/testref/ref_des.c
@@ -0,0 +1,353 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "hal.h"
+
+const uint8_t refDES_ECB_8[]={
+0x5A,0x45,0xE3,0x30,0x6B,0x7E,0xF0,0x87,0x27,0xE2,
+0x92,0x19,0x09,0xE1,0x4E,0x68,0x84,0x84,0x01,0x45,
+0xED,0x86,0xB4,0x41,0x4A,0xE9,0x1F,0x1A,0xC0,0xE0,
+0x05,0x90,0x9B,0x8A,0x47,0xD7,0x64,0x5D,0xC5,0x92,
+0xB4,0x23,0x6B,0x0E,0x7E,0x4F,0xB8,0x86,0x23,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,0xD1,0x02,0x28,0x23,0xB5,
+0x8F,0x19,0x1E,0x01,0x81,0x4E,0x47,0xCC,0x86,0xB4,
+0x03,0x89,0x10,0xF0,0x7F,0xCD,0x21,0x72,0x22,0x0A,
+0x5B,0xBD,0x70,0xC9,0xC9,0x79,0x79,0x1E,0x16,0x66,
+0x3C,0xF4,0x0A,0x9D,0x50,0x9A,0xCC,0x49,0x27,0x8B,
+0x30,0x8C,0x62,0xFF,0x2C,0xF8,0x79,0xBD,0x4F,0x31,
+0x6E,0xBC,0x5A,0x21,0xB5,0xB2,0xEF,0x1D,0x95,0x19,
+0xCE,0x38,0x7E,0x06,0xA5,0xB8,0x71,0xC2,0x72,0x5F,
+0x2B,0x9F,0x04,0x5E,0x94,0x46,0xD3,0x6D,0xFC,0x88,
+0x06,0xDD,0x79,0xB4,0x23,0x52,0x77,0x2F,0x93,0x17,
+0x0C,0x3D,0x24,0xDD,0x77,0x91,0x27,0xA1,0x50,0x4E,
+0x25,0x99,0x6B,0x11,0x06,0x80,0xC3,0x0C,0x47,0xB1,
+0xDB,0x31,0xDE,0x4D,0x05,0xAF,0x2C,0x73,0x94,0xA3,
+0x79,0xBB,0x03,0xB8,0xBF,0x8F,0x53,0x2E,0xBF,0x5F,
+0xA8,0x23,0x8D,0x34,0x3A,0x28,0xB4,0x02,0xD0,0x95,
+0x78,0x07,0x14,0x55,0x2A,0x2C,0xE0,0x9E,0xA9,0x67,
+0x96,0xFE,0xBB,0xE0,0x4D,0xE5,0x30,0xCB,0xA2,0x83,
+0x6A,0xA9,0x0D,0x96,0xA3,0x24,0x78,0xB1,0xD4,0xF7,
+0x07,0x70,0xE0,0xBE,0x16,0xA0,0xE1,0xB4,0x97,0x06,
+
+};
+const uint8_t refTDES_CBC_24[]={
+0x78,0xCA,0xC6,0x02,0x50,0x7C,0x1F,0x56,0xCB,0x91,
+0x27,0x7B,0xEA,0xD3,0x8F,0x9A,0xF8,0xC9,0x61,0xD0,
+0xAC,0x67,0x4C,0xE3,0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A2,0xA5,0x38,0xB3,0x2C,0xB4,0x1B,0xA6,0xA9,0xC9,
+0x7D,0xB5,0x2E,0xCA,0x13,0x67,0xF7,0x9C,0xF3,0x91,
+0x2D,0xBD,0x2D,0xCE,0x1F,0x22,0xE7,0x2E,0x1E,0xA0,
+0xC7,0x07,0xA6,0x42,0xFF,0xCC,0xC2,0x1A,0x16,0xB6,
+0x7D,0x33,0x93,0x58,0x58,0x17,0xD2,0x59,0xE6,0xD2,
+0x5C,0x5E,0xEF,0x88,0xD1,0x75,0xDA,0x27,0x3E,0xD0,
+0xAF,0xCA,0xDE,0x87,0x93,0x08,0x55,0x5F,0x01,0xC3,
+0x11,0xCB,0xF7,0xD6,0xE1,0x44,0x91,0x96,0x1C,0x8E,
+0xD5,0xFA,0x23,0xE1,0xC0,0xCA,0xA0,0x50,0xCB,0x5E,
+0xCE,0x9D,0xE6,0x7E,0xF5,0x00,0xA5,0x59,0x2D,0x89,
+0x78,0x61,0xAC,0x5B,0xE3,0xC1,0x75,0xB9,0x42,0x29,
+0xE9,0x25,0x1C,0x8B,0x4A,0x08,0xCC,0x06,0xC7,0x5B,
+0x28,0x3C,0xCF,0xF5,0xC3,0x9E,0x56,0x16,0x0C,0x36,
+0x06,0x28,0x3F,0xD3,0x1B,0x86,0xAC,0xF7,0x57,0x7B,
+0xCF,0x3F,0x24,0x3E,0x92,0xB1,0x89,0x8A,0x40,0xDD,
+0x77,0xEA,0x6F,0xE5,0x9C,0x26,0xF9,0xD9,0x75,0x08,
+0x6B,0xD0,0xD1,0xF3,0xDD,0xCB,0x39,0x07,0xCE,0xC0,
+0xAE,0xD1,0xB9,0x4E,0x22,0x21,0xDB,0xC1,0x9D,0xED,
+0x9F,0xE1,0xBA,0x29,0x60,0x18,0xC5,0x7F,0x7B,0x5E,
+
+};
diff --git a/test/crypto/source/testref/ref_des.h b/test/crypto/source/testref/ref_des.h
new file mode 100644
index 000000000..c839084b7
--- /dev/null
+++ b/test/crypto/source/testref/ref_des.h
@@ -0,0 +1,24 @@
+/*
+ ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+#ifndef TEST_REF_DES_H_
+#define TEST_REF_DES_H_
+
+extern const uint8_t refDES_ECB_8[];
+extern const uint8_t refTDES_ECB_16[];
+extern const uint8_t refTDES_ECB_24[];
+extern const uint8_t refTDES_CBC_16[];
+extern const uint8_t refTDES_CBC_24[];
+#endif //TEST_REF_DES_H_