aboutsummaryrefslogtreecommitdiffstats
path: root/test/crypto/configuration.xml
diff options
context:
space:
mode:
authorareviu <areviu.info@gmail.com>2018-03-25 09:16:57 +0000
committerareviu <areviu.info@gmail.com>2018-03-25 09:16:57 +0000
commitc44880635c6c6f8b7b026c79ae5ec1e49e38541c (patch)
treeb66a5c2903e3123642b5f20804beb15ff13a7939 /test/crypto/configuration.xml
parent1d3bbc72c326e87bb688cbce39ea93b71b4406d3 (diff)
downloadChibiOS-c44880635c6c6f8b7b026c79ae5ec1e49e38541c.tar.gz
ChibiOS-c44880635c6c6f8b7b026c79ae5ec1e49e38541c.tar.bz2
ChibiOS-c44880635c6c6f8b7b026c79ae5ec1e49e38541c.zip
added gcm for sama crypto
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11851 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'test/crypto/configuration.xml')
-rw-r--r--test/crypto/configuration.xml357
1 files changed, 355 insertions, 2 deletions
diff --git a/test/crypto/configuration.xml b/test/crypto/configuration.xml
index dc894e692..846702494 100644
--- a/test/crypto/configuration.xml
+++ b/test/crypto/configuration.xml
@@ -63,6 +63,13 @@ extern void cryptoTest_printArray32(bool isLE,const uint32_t *a,size_t len);
#define SHA_LEN_2 64
#define SHA_LEN_3 128
+#define TEST_GCM_KEY1_LEN 32
+#define TEST_P_LEN 60
+#define TEST_A_LEN 20
+#define TEST_IV1_LEN 12
+#define TEST_CL_LEN 60
+#define TEST_TL_LEN 16
+
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];
@@ -73,6 +80,9 @@ extern const uint8_t sha_msg0[SHA_LEN_0];
extern const uint8_t sha_msg1[SHA_LEN_1];
extern const uint8_t sha_msg2[SHA_LEN_2];
extern const uint8_t sha_msg3[SHA_LEN_3];
+
+
+
]]></value>
</global_definitions>
<global_code>
@@ -128,6 +138,7 @@ const uint8_t sha_msg2[SHA_LEN_2] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
const uint8_t sha_msg3[SHA_LEN_3] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
+
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];
@@ -2292,6 +2303,9 @@ for (int i = 0; i < TEST_DATA_WORD_LEN; i++) {
</cases>
</sequence>
+
+
+
<sequence>
<type index="0">
<value>Internal Tests</value>
@@ -3286,9 +3300,348 @@ for (int i = 0; i < 16; i++) {
</steps>
</case>
- </cases>
+ </cases>
</sequence>
- </sequences>
+
+<sequence>
+ <type index="0">
+ <value>Internal Tests</value>
+ </type>
+ <brief>
+ <value>GCM</value>
+ </brief>
+ <description>
+ <value>GCM testing</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <shared_code>
+ <value><![CDATA[
+#include <string.h>
+#include "ref_gcm.h"
+#define plaintext msg_clear
+#define cypher msg_encrypted
+#define authtag msg_decrypted
+
+static const CRYConfig config_Polling=
+{
+ TRANSFER_POLLING,
+ 0
+};
+
+static const CRYConfig config_DMA=
+{
+ TRANSFER_DMA,
+ 0
+};
+
+struct test_el_t
+{
+ uint32_t size;
+ const uint8_t * data;
+
+};
+struct test_gcm_t
+{
+ struct test_el_t key;
+ struct test_el_t p;
+ struct test_el_t iv;
+ struct test_el_t aad;
+ struct test_el_t c;
+ struct test_el_t t;
+
+};
+#define TEST_GCM_LEN 3
+
+const struct test_gcm_t test_gcm_k[TEST_GCM_LEN]={
+
+ { {K3_LEN,K3},{P3_LEN,P3},{IV3_LEN,IV3},{AAD3_LEN,A3},{C3_LEN,C3},{T3_LEN,T3} },
+ { {K4_LEN,K4},{P4_LEN,P4},{IV4_LEN,IV4},{AAD4_LEN,A4},{C4_LEN,C4},{T4_LEN,T4} },
+ { {K5_LEN,K5},{P5_LEN,P5},{IV5_LEN,IV5},{AAD5_LEN,A5},{C5_LEN,C5},{T5_LEN,T5} }
+};
+
+
+
+ ]]></value>
+ </shared_code>
+ <cases>
+ <case>
+ <brief>
+ <value>GCM Polling</value>
+ </brief>
+ <description>
+ <value>testing GCM in polled mode</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+ memset(cypher, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(authtag, 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;
+ uint32_t *ref;
+ uint8_t i,len1,len2;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key, encrypt and decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+for (i = 0;i<TEST_GCM_LEN;i++) {
+
+ test_print("gcm test : ");
+ test_printn(i);
+ test_println("");
+ /* loading the key .*/
+
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,test_gcm_k[i].key.size, (uint8_t *) test_gcm_k[i].key.data);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* Encrypt.*/
+
+ {
+
+ ret = cryEncryptAES_GCM(&CRYD1,
+ 0,
+ test_gcm_k[i].p.size,
+ test_gcm_k[i].p.data,
+ (uint8_t*)cypher,
+ test_gcm_k[i].iv.data,
+ test_gcm_k[i].aad.size,
+ test_gcm_k[i].aad.data,
+ (uint8_t*)authtag);
+
+ test_assert(ret == CRY_NOERROR, "failed encryption");
+
+ len1 = test_gcm_k[i].c.size/4;
+ len2 = test_gcm_k[i].t.size/4;
+ SHOW_DATA(cypher,len1);
+ SHOW_DATA(authtag,len2);
+
+ ref = (uint32_t*)test_gcm_k[i].c.data;
+
+ for (uint8_t i = 0; i < len1; i++) {
+ test_assert(ref[i] == cypher[i], "c mismatch");
+ }
+ ref = (uint32_t*)test_gcm_k[i].t.data;
+
+ for (uint8_t i = 0; i < len2; i++) {
+ test_assert(ref[i] == authtag[i], "t mismatch");
+ }
+
+
+
+ }
+
+ /* Decrypt.*/
+
+ {
+
+
+ memset(plaintext, 0, test_gcm_k[i].p.size);
+
+ ret = cryDecryptAES_GCM(&CRYD1,
+ 0,
+ test_gcm_k[i].c.size,
+ (uint8_t*)cypher,
+ (uint8_t*)plaintext,
+ test_gcm_k[i].iv.data,
+ test_gcm_k[i].aad.size,
+ test_gcm_k[i].aad.data,
+ (uint8_t*)authtag);
+
+ test_assert(ret == CRY_NOERROR, "failed decryption");
+
+ len1 = test_gcm_k[i].p.size/4;
+ SHOW_DATA(plaintext,len1);
+
+ ref = (uint32_t*)test_gcm_k[i].p.data;
+
+ for (uint8_t i = 0; i < len1; i++) {
+ test_assert(ref[i] == plaintext[i], "decrypt plain mismatch");
+ }
+
+
+
+ }
+
+ }
+]]></value>
+ </code>
+ </step>
+
+
+
+
+
+
+
+ </steps>
+ </case>
+
+
+ <case>
+ <brief>
+ <value>GCM DMA</value>
+ </brief>
+ <description>
+ <value>testing GCM in DMA mode</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value><![CDATA[
+ memset(cypher, 0xff, TEST_MSG_DATA_BYTE_LEN);
+ memset(authtag, 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;
+ uint32_t *ref;
+ uint8_t i,len1,len2;
+]]></value>
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>loading the key, encrypt and decrypt</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[
+for (i = 0;i<TEST_GCM_LEN;i++) {
+
+ test_print("gcm test : ");
+ test_printn(i);
+ test_println("");
+ /* loading the key .*/
+
+ {
+ ret = cryLoadTransientKey(&CRYD1, (cryalgorithm_t) cry_algo_aes,test_gcm_k[i].key.size, (uint8_t *) test_gcm_k[i].key.data);
+
+ test_assert(ret == CRY_NOERROR, "failed load transient key");
+ }
+
+ /* Encrypt.*/
+
+ {
+
+ ret = cryEncryptAES_GCM(&CRYD1,
+ 0,
+ test_gcm_k[i].p.size,
+ test_gcm_k[i].p.data,
+ (uint8_t*)cypher,
+ test_gcm_k[i].iv.data,
+ test_gcm_k[i].aad.size,
+ test_gcm_k[i].aad.data,
+ (uint8_t*)authtag);
+
+ test_assert(ret == CRY_NOERROR, "failed encryption");
+
+ len1 = test_gcm_k[i].c.size/4;
+ len2 = test_gcm_k[i].t.size/4;
+ SHOW_DATA(cypher,len1);
+ SHOW_DATA(authtag,len2);
+
+ ref = (uint32_t*)test_gcm_k[i].c.data;
+
+ for (uint8_t i = 0; i < len1; i++) {
+ test_assert(ref[i] == cypher[i], "c mismatch");
+ }
+ ref = (uint32_t*)test_gcm_k[i].t.data;
+
+ for (uint8_t i = 0; i < len2; i++) {
+ test_assert(ref[i] == authtag[i], "t mismatch");
+ }
+
+
+
+ }
+
+ /* Decrypt.*/
+
+ {
+
+
+ memset(plaintext, 0, test_gcm_k[i].p.size);
+
+ ret = cryDecryptAES_GCM(&CRYD1,
+ 0,
+ test_gcm_k[i].c.size,
+ (uint8_t*)cypher,
+ (uint8_t*)plaintext,
+ test_gcm_k[i].iv.data,
+ test_gcm_k[i].aad.size,
+ test_gcm_k[i].aad.data,
+ (uint8_t*)authtag);
+
+ test_assert(ret == CRY_NOERROR, "failed decryption");
+
+ len1 = test_gcm_k[i].p.size/4;
+ SHOW_DATA(plaintext,len1);
+
+ ref = (uint32_t*)test_gcm_k[i].p.data;
+
+ for (uint8_t i = 0; i < len1; i++) {
+ test_assert(ref[i] == plaintext[i], "decrypt plain mismatch");
+ }
+
+
+
+ }
+
+ }
+]]></value>
+ </code>
+ </step>
+
+
+
+
+
+
+
+ </steps>
+ </case>
+
+
+ </cases>
+ </sequence>
+
+ </sequences>
</instance>
</instances>
<exportedFeatures />