summaryrefslogtreecommitdiff
path: root/cesar/cp/test/src/test_secu.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/cp/test/src/test_secu.c')
-rw-r--r--cesar/cp/test/src/test_secu.c570
1 files changed, 570 insertions, 0 deletions
diff --git a/cesar/cp/test/src/test_secu.c b/cesar/cp/test/src/test_secu.c
new file mode 100644
index 0000000000..6532344d07
--- /dev/null
+++ b/cesar/cp/test/src/test_secu.c
@@ -0,0 +1,570 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/test/test_secu.c
+ * \brief unit tests for secu module
+ * \ingroup cp_test
+ */
+
+#include "common/std.h"
+#include "cp/test/inc/test_secu.h"
+
+/*
+ * Test de la fonction sha2
+ */
+
+/*
+ * FIPS-180-2 test vectors
+ */
+
+//static const char sha2_test_str[3][57] =
+static char sha2_test_str[3][57] =
+ {
+ { "abc" },
+ { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" },
+ { "" }
+ };
+
+static const unsigned char sha2_test_sum[6][32] = {
+/*
+ * SHA-224 test vectors
+ */
+{ 0x23, 0x09, 0x7D, 0x22, 0x34, 0x05, 0xD8, 0x22, 0x86, 0x42, 0xA4, 0x77,
+ 0xBD, 0xA2, 0x55, 0xB3, 0x2A, 0xAD, 0xBC, 0xE4, 0xBD, 0xA0, 0xB3,
+ 0xF7, 0xE3, 0x6C, 0x9D, 0xA7 }, { 0x75, 0x38, 0x8B, 0x16, 0x51, 0x27,
+ 0x76, 0xCC, 0x5D, 0xBA, 0x5D, 0xA1, 0xFD, 0x89, 0x01, 0x50, 0xB0,
+ 0xC6, 0x45, 0x5C, 0xB4, 0xF5, 0x8B, 0x19, 0x52, 0x52, 0x25, 0x25 }, {
+ 0x20, 0x79, 0x46, 0x55, 0x98, 0x0C, 0x91, 0xD8, 0xBB, 0xB4, 0xC1,
+ 0xEA, 0x97, 0x61, 0x8A, 0x4B, 0xF0, 0x3F, 0x42, 0x58, 0x19, 0x48,
+ 0xB2, 0xEE, 0x4E, 0xE7, 0xAD, 0x67 },
+
+/*
+ * SHA-256 test vectors
+ */
+{ 0xBA, 0x78, 0x16, 0xBF, 0x8F, 0x01, 0xCF, 0xEA, 0x41, 0x41, 0x40, 0xDE,
+ 0x5D, 0xAE, 0x22, 0x23, 0xB0, 0x03, 0x61, 0xA3, 0x96, 0x17, 0x7A,
+ 0x9C, 0xB4, 0x10, 0xFF, 0x61, 0xF2, 0x00, 0x15, 0xAD }, { 0x24, 0x8D,
+ 0x6A, 0x61, 0xD2, 0x06, 0x38, 0xB8, 0xE5, 0xC0, 0x26, 0x93, 0x0C,
+ 0x3E, 0x60, 0x39, 0xA3, 0x3C, 0xE4, 0x59, 0x64, 0xFF, 0x21, 0x67,
+ 0xF6, 0xEC, 0xED, 0xD4, 0x19, 0xDB, 0x06, 0xC1 }, { 0xCD, 0xC7, 0x6E,
+ 0x5C, 0x99, 0x14, 0xFB, 0x92, 0x81, 0xA1, 0xC7, 0xE2, 0x84, 0xD7,
+ 0x3E, 0x67, 0xF1, 0x80, 0x9A, 0x48, 0xA4, 0x97, 0x20, 0x0E, 0x04,
+ 0x6D, 0x39, 0xCC, 0xC7, 0x11, 0x2C, 0xD0 } };
+
+/*
+ * Checkup routine
+ */
+int sha2_self_test (void)
+{
+ //int verbose = 0;
+ int i, j, k;
+ unsigned char buf[1000];
+ unsigned char sha2sum[32];
+ sha2_context ctx;
+
+ memset (buf, 'a', 1000);
+
+ for (i = 0; i < 6; i++)
+ {
+ j = i % 3;
+ k = i < 3;
+
+ sha2_starts ( &ctx, k );
+ if (j < 2)
+ sha2_update ( &ctx, (unsigned char *)sha2_test_str[j],
+ strlen (sha2_test_str[j]) );
+ else
+ {
+ for (j = 0; j < 1000; j++)
+ sha2_update ( &ctx, buf, 1000);
+ }
+ sha2_finish ( &ctx, sha2sum );
+ if (memcmp (sha2sum, sha2_test_sum[i], 32 - k * 4) != 0)
+ {
+ return ( 1 );
+ }
+ }
+ return ( 0 );
+}
+
+int sha2_self_test_wikipedia (void)
+// these test vector were found on wikipedia
+{
+ unsigned int i;
+ int j, errcount = 0;
+ unsigned char output[SHA256_OUTPUT_SIZE];
+ unsigned char samples[3][44] = { {
+ "The quick brown fox jumps over the lazy dog" }, {
+ "The quick brown fox jumps over the lazy cog" }, { "" } };
+ unsigned char samplesres[3][SHA256_OUTPUT_SIZE] = { { 0xd7, 0xa8, 0xfb,
+ 0xb3, 0x07, 0xd7, 0x80, 0x94, 0x69, 0xca, 0x9a, 0xbc, 0xb0, 0x08,
+ 0x2e, 0x4f, 0x8d, 0x56, 0x51, 0xe4, 0x6d, 0x3c, 0xdb, 0x76, 0x2d,
+ 0x02, 0xd0, 0xbf, 0x37, 0xc9, 0xe5, 0x92 }, { 0xe4, 0xc4, 0xd8,
+ 0xf3, 0xbf, 0x76, 0xb6, 0x92, 0xde, 0x79, 0x1a, 0x17, 0x3e, 0x05,
+ 0x32, 0x11, 0x50, 0xf7, 0xa3, 0x45, 0xb4, 0x64, 0x84, 0xfe, 0x42,
+ 0x7f, 0x6a, 0xcc, 0x7e, 0xcc, 0x81, 0xbe }, { 0xe3, 0xb0, 0xc4,
+ 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f,
+ 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4,
+ 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55 } };
+
+ for (i=0; i<COUNT (samples) ; i++)
+ {
+ if (i!=2)
+ sha2 (samples[i], 43, output, 0);
+ else
+ sha2 (samples[i], 0, output, 0);
+ for (j=0; j<32; j++)
+ {
+ if (output[j] != samplesres[i][j])
+ errcount++;
+ }
+ }
+ return (errcount);
+}
+
+/*
+ * Test of secu_check_password_validity
+ */
+struct pwd_test_t
+{
+ pwd_type_t pwd_type;
+ unsigned char password[MAX_PWD_SIZE + 1];
+ unsigned int exp_result;
+};
+
+int secu_check_password_validity_test (void)
+{
+ struct pwd_test_t pwd_test[]=
+ {
+ { 0x32, "abcd efgh ijkl mnop", Failure }, // type de mot de passe incorrect
+ { PWD_DPW, "abcd efgh ijkl m", Success }, // le plus petit mot de passe DPW
+ { PWD_NPW, "abcd efg", Success }, // le plus petit mot de passe NPW
+ { PWD_DPW, "abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd", Success }, // le plus grand mot de passe
+ { PWD_DPW, "abcd efgh ijkl ", PWD_WrongSize }, // mot de passe DPW trop petit
+ { PWD_NPW, "abcd ef", PWD_WrongSize }, // mot de passe NPW trop petit
+ { PWD_DPW, "abcd efgh ijkl m\x1F", PWD_ForbidenChar }, // mot de passe avec caractère incorrect
+ { PWD_DPW, "abcd efgh ijkl m\x80", PWD_ForbidenChar } // mot de passe avec caractère incorrect
+ };
+ unsigned int i;
+ for (i=0 ; i<COUNT (pwd_test) ; i++)
+ {
+ if (secu_check_password_validity (pwd_test[i].pwd_type, pwd_test[i].password)
+ != pwd_test[i].exp_result)
+ return Failure;
+ }
+ return 0;
+}
+
+/*
+ * Test secu_pbkdf1
+ */
+struct pbkdf1_test_t
+{
+ u8 input[MAX_PWD_SIZE + 1];
+ int input_len;
+ u8 salt[SALT_SIZE];
+ int salt_len;
+ int it_count;
+ u8 exp_output_key[OUTPUT_KEY_SIZE];
+};
+
+int
+secu_pbkdf1_test (void)
+{
+ unsigned int i;
+ u8 output_key[OUTPUT_KEY_SIZE];
+ struct pbkdf1_test_t pbkdf1_test[]=
+ {
+ { "hello world how are you?",
+ 24,
+ { 0x58, 0x56, 0x52, 0xf6, 0x9c, 0x04, 0xb5, 0x72 },
+ 8,
+ 1000,
+ { 0x84, 0x33, 0x45, 0x96, 0xab, 0xe5, 0x1e, 0x60, 0x7e, 0x63, 0x8f, 0x4b, 0x2d, 0x8c, 0x51, 0x68 }
+ } //
+ };
+ for(i=0 ; i<COUNT(pbkdf1_test) ; i++)
+ {
+ secu_pbkdf1(pbkdf1_test[i].input, pbkdf1_test[i].input_len, pbkdf1_test[i].salt, pbkdf1_test[i].salt_len, pbkdf1_test[i].it_count, output_key);
+ if(memcmp( output_key, pbkdf1_test[i].exp_output_key, OUTPUT_KEY_SIZE)) return Failure;
+ }
+ return 0;
+}
+
+/*
+ * Test des fonctions AES
+ */
+
+/*
+ * AES-ECB test vectors (source: NIST, rijndael-vals.zip)
+ */
+
+/*
+ * Checkup routine
+ */
+int aes_self_test (void)
+{
+ //int verbose = 0;
+ int i, j, u, v;
+ aes_context ctx;
+ unsigned char buf[32];
+
+ uint8 aes_enc_test[3][16] = { { 0xC3, 0x4C, 0x05, 0x2C, 0xC0, 0xDA, 0x8D,
+ 0x73, 0x45, 0x1A, 0xFE, 0x5F, 0x03, 0xBE, 0x29, 0x7F }, { 0xF3,
+ 0xF6, 0x75, 0x2A, 0xE8, 0xD7, 0x83, 0x11, 0x38, 0xF0, 0x41, 0x56,
+ 0x06, 0x31, 0xB1, 0x14 }, { 0x8B, 0x79, 0xEE, 0xCC, 0x93, 0xA0,
+ 0xEE, 0x5D, 0xFF, 0x30, 0xB4, 0xEA, 0x21, 0x63, 0x6D, 0xA4 } };
+
+ uint8 aes_dec_test[3][16] = { { 0x44, 0x41, 0x6A, 0xC2, 0xD1, 0xF5, 0x3C,
+ 0x58, 0x33, 0x03, 0x91, 0x7E, 0x6B, 0xE9, 0xEB, 0xE0 }, { 0x48,
+ 0xE3, 0x1E, 0x9E, 0x25, 0x67, 0x18, 0xF2, 0x92, 0x29, 0x31, 0x9C,
+ 0x19, 0xF1, 0x5B, 0xA4 }, { 0x05, 0x8C, 0xCF, 0xFD, 0xBB, 0xCB,
+ 0x38, 0x2D, 0x1F, 0x6F, 0x56, 0x58, 0x5D, 0x8A, 0x4A, 0xDE } };
+
+ for (i = 0; i < 6; i++)
+ {
+ u = i >> 1;
+ v = i & 1;
+
+ memset (buf, 0, 32);
+ aes_set_key ( &ctx, buf, 128 + u * 64);
+ for (j = 0; j < 10000; j++)
+ {
+ if (v == 0)
+ aes_encrypt ( &ctx, buf, buf );
+ if (v == 1)
+ aes_decrypt ( &ctx, buf, buf );
+ }
+ if ( (v == 0&& memcmp (buf, aes_enc_test[u], 16) != 0) ||(v == 1
+ && memcmp (buf, aes_dec_test[u], 16) != 0))
+ {
+ return ( 1 );
+ }
+ }
+ return ( 0 );
+}
+/*
+ * test of aes function, with test vectors provided by NIS
+ */
+#define AES_TEXT_SIZE 112
+struct T_aes_test
+{
+ unsigned char Key[AES_KEY_SIZE];
+ unsigned char IV[16];
+ unsigned char PlainText[AES_TEXT_SIZE];
+ int len;
+ unsigned char CypherText[AES_TEXT_SIZE];
+};
+
+int aes_avs_test (void)
+{
+ aes_context ctx;
+ unsigned char AESOutput[AES_TEXT_SIZE];
+ unsigned char tmp[AES_TEXT_SIZE];
+ unsigned int i;
+ struct T_aes_test aes_test[]=
+ {
+ { // élément de test http://www.faqs.org/rfcs/rfc3602.html case #1
+ { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b, 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
+ { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30, 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
+ { "Single block msg" },
+ 16,
+ {0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8, 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a }
+ },
+ { // élément de test http://www.faqs.org/rfcs/rfc3602.html case #4
+ { 0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74, 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49 },
+ { 0x8c, 0xe8, 0x2e, 0xef, 0xbe, 0xa0, 0xda, 0x3c, 0x44, 0x69, 0x9e, 0xd7, 0xdb, 0x51, 0xb7, 0xd9 },
+ { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf },
+ 64,
+ { 0xc3, 0x0e, 0x32, 0xff, 0xed, 0xc0, 0x77, 0x4e, 0x6a, 0xff, 0x6a, 0xf0, 0x86, 0x9f, 0x71, 0xaa,
+ 0x0f, 0x3a, 0xf0, 0x7a, 0x9a, 0x31, 0xa9, 0xc6, 0x84, 0xdb, 0x20, 0x7e, 0xb0, 0xef, 0x8e, 0x4e,
+ 0x35, 0x90, 0x7a, 0xa6, 0x32, 0xc3, 0xff, 0xdf, 0x86, 0x8b, 0xb7, 0xb2, 0x9d, 0x3d, 0x46, 0xad,
+ 0x83, 0xce, 0x9f, 0x9a, 0x10, 0x2e, 0xe9, 0x9d, 0x49, 0xa5, 0x3e, 0x87, 0xf4, 0xc3, 0xda, 0x55 }
+ }
+
+ };
+ // teste une valeur de clé incorrecte
+ aes_set_key ( &ctx, aes_test[0].Key, 1);
+
+ // vérifie le fonctionnement de l'encryptage/décryptage AES
+ // sans le mode CBC
+ aes_set_key ( &ctx, aes_test[0].Key, AES_KEY_SIZE*8);
+ aes_encrypt ( &ctx, aes_test[0].PlainText, AESOutput);
+ memset(tmp, 0, sizeof(tmp));
+ aes_decrypt ( &ctx, AESOutput, tmp);
+ if (memcmp (tmp, aes_test[0].PlainText, aes_test[0].len) != 0)
+ {
+ return 1;
+ }
+
+ // test du mode CBC
+ for (i=0; i<COUNT (aes_test) ; i++)
+ {
+ aes_set_key ( &ctx, aes_test[i].Key, AES_KEY_SIZE*8);
+ memcpy(tmp, aes_test[i].IV, sizeof(aes_test[i].IV));
+ aes_cbc_encrypt (&ctx, tmp, aes_test[i].PlainText, AESOutput, aes_test[i].len);
+ if (memcmp (aes_test[i].CypherText, AESOutput, aes_test[i].len) != 0)
+ {
+ return 3;
+ }
+
+ aes_set_key ( &ctx, aes_test[i].Key, AES_KEY_SIZE*8);
+ memset(tmp, 0, sizeof(tmp));
+ aes_cbc_decrypt (&ctx, aes_test[i].IV, aes_test[i].CypherText, tmp, aes_test[i].len);
+ if (memcmp (aes_test[i].PlainText, tmp, aes_test[i].len) != 0)
+ {
+ return 4;
+ }
+ }
+ return 0;
+}
+
+/*
+ * test de void SECU_Init(T_SEC *p_sec)
+ */
+int secu_init_test (void)
+{
+ cp_secu_t sec;
+
+ secu_init (&sec);
+
+ return 0;
+}
+/*
+ * test de E_SecuErrCode SECU_Hash(E_PWDType PWDType, u8 in[], u8 out[])
+ */
+int secu_hash_test (void)
+{
+ u8 out[AES_KEY_SIZE];
+ u8 pwd[] = "Hello world! what's up ?";
+ return secu_hash (PWD_DPW, pwd, strlen(pwd), out);
+}
+
+/*
+ * test de E_SecuErrCode SECU_GenAESKey(u8 Key[])
+ */
+int secu_gen_aes_key_test (void)
+{
+ u8 key[AES_KEY_SIZE];
+ E_ErrCode r;
+ unsigned int i;
+ u8 ExpRes[] = { 0x18, 0x72, 0xce, 0x0, 0x56, 0xcb, 0xf2, 0xdf, 0x33,
+ 0x5a, 0x6, 0x9c, 0x6b, 0x41, 0x2d, 0x26 };
+
+ r = secu_gen_aes_key (key);
+ if (r != 0)
+ return r;
+ for (i=0; i<COUNT (ExpRes) ; i++)
+ if (key[i] != ExpRes[i])
+ return Failure;
+ return 0;
+}
+
+/*
+ * test de E_SecuErrCode SECU_GenNonce(T_SEC *p_sec)
+ */
+int secu_gen_nonce_test (void)
+{
+ tei_t tei = 1;
+ cp_secu_t sec;
+ protocol_run_t p_run;
+
+ secu_init (&sec);
+ secu_gen_nonce (tei);
+ p_run.pid = 0;
+ p_run.nonce = 0xce7218; // résultat obtenu avec la clé par défaut de SECU_GenAESKey()
+ if (secu_check_protocol_run_param(tei, p_run) != NONCE_INCORRECT)
+ return 0;
+ else
+ return 1;
+}
+
+struct npw2nmk_test_t
+{
+ char npw[65];
+ u8 expected_nmk[16];
+};
+
+int secu_npw2nmk_test (void)
+{
+ struct npw2nmk_test_t data = {
+ "HomePlugAV0123",
+ { 0xB5, 0x93, 0x19, 0xD7, 0xE8, 0x15, 0x7B, 0xA0, 0x01, 0xB0, 0x18, 0x66, 0x9C, 0xCE, 0xE3, 0x0D }
+ };
+ u8 nmk[16];
+ int i;
+ bool verbose = true;
+
+ memset((char*)nmk,0x00,sizeof(nmk));
+ secu_npw2nmk(data.npw,nmk);
+
+ for (i = 0; i < 16; i++)
+ {
+ if (nmk[i] != data.expected_nmk[i])
+ {
+ if (verbose)
+ {
+ printf("hashed NMK from \"%s\" NPW : 0x",data.npw);
+ for (i = 0; i < 16; i++)
+ {
+ printf("%02X",nmk[i]);
+ }
+ printf("\n");
+ printf("different from expected one : 0x");
+ for (i = 0; i < 16; i++)
+ {
+ printf("%02X",data.expected_nmk[i]);
+ }
+ printf("\n");
+ }
+ return 1;
+ }
+ }
+ return 0;
+}
+
+struct nmk2nid_test_t
+{
+ u8 nmk[16];
+ u8 sl;
+ u8 expected_nid[7];
+};
+
+int secu_nmk2nid_test (void)
+{
+ struct nmk2nid_test_t data = {
+ { 0xB5, 0x93, 0x19, 0xD7, 0xE8, 0x15, 0x7B, 0xA0, 0x01, 0xB0, 0x18, 0x66, 0x9C, 0xCE, 0xE3, 0x0D },
+ 1,
+ { 0x02, 0x6B, 0xCB, 0xA5, 0x35, 0x4E, 0x18 }
+ };
+ u8 nid[7];
+ int i;
+ bool verbose = true;
+
+ memset((char*)nid,0x00,sizeof(nid));
+ secu_nmk2nid(data.nmk,data.sl,nid);
+
+ for (i = 0; i < 7; i++)
+ {
+ if (nid[i] != data.expected_nid[i])
+ {
+ if (verbose)
+ {
+ printf("hashed NID from 0x");
+ for (i = 0; i < 7; i++)
+ {
+ printf("%02X",nid[i]);
+ }
+ printf(" NMK\n");
+ printf("different from expected one : 0x");
+ for (i = 0; i < 7; i++)
+ {
+ printf("%02X",data.expected_nid[i]);
+ }
+ printf("\n");
+ }
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/*
+ * test des protocol-run
+ */
+int secu_protocol_run_test (void)
+{
+ cp_secu_t STA_sec;
+ protocol_run_t Msg;
+ cp_pid_t PID = PROV_STA_WITH_NMK_U_UKE;
+ tei_t tei_cco = 1, tei_sta = 2;
+
+ secu_init (&STA_sec);
+
+ // cco start a new protocol-run
+ secu_start_new_protocol_run (tei_cco, PID, &Msg);
+ // check that parameters are correctly set
+ if (Msg.pid != PROV_STA_WITH_NMK_U_UKE)
+ return 2;
+ // le CCO demande les paramètres du pr en cours
+ if (secu_gen_protocol_run_param (tei_cco, false, &Msg) != 0)
+ return 3;
+ // la STA reçoit le premier message du pr
+ if (secu_check_protocol_run_param (tei_sta, Msg) != 0)
+ return 4;
+ // la STA génère un nouveau message
+ if (secu_gen_protocol_run_param (tei_sta, false, &Msg) != 0)
+ return 5;
+ // et le renvoie au CCO
+ if (secu_check_protocol_run_param (tei_cco, Msg) != 0)
+ return 6;
+ // le CCO refait un message
+ if (secu_gen_protocol_run_param (tei_cco, false, &Msg) != 0)
+ return 7;
+ // et le renvoie à la STA
+ if (secu_check_protocol_run_param (tei_sta, Msg) != 0)
+ return 8;
+ // la STA génère le dernier message du protocol run
+ if (secu_gen_protocol_run_param (tei_sta, true, &Msg) != 0)
+ return 9;
+ // et le renvoie au CCO
+ if (secu_check_protocol_run_param (tei_cco, Msg) != 0)
+ return 10;
+ // le CCO ne peut plus renvoyer de messages
+ if (secu_gen_protocol_run_param (tei_cco, false, &Msg)
+ != PRN_NotInitialised)
+ return 11;
+
+ return 0;
+}
+
+struct T_SecuTest
+{
+ int(*func) (void);
+ char FuncName[30];
+};
+
+int secu_test (bool verbose)
+{
+ unsigned int i;
+ int res, return_value = 0;
+ struct T_SecuTest SecuTest[]=
+ {
+ { sha2_self_test, "sha2 (1)" },
+ { sha2_self_test_wikipedia, "sha2 (2)" },
+ { secu_check_password_validity_test, "check_password_validity" },
+ { secu_pbkdf1_test, "pbkdf1" },
+ { aes_self_test, "aes (1)" },
+ { aes_avs_test, "aes (2)" },
+ { secu_init_test, "secu_init" },
+ { secu_hash_test, "secu_hash" },
+ { secu_gen_aes_key_test, "secu_gen_aes_key" },
+ { secu_gen_nonce_test, "secu_gen_nonce" },
+ { secu_protocol_run_test, "secu_protocol_run" },
+ { secu_npw2nmk_test, "secu_npw2nmk" },
+ { secu_nmk2nid_test, "secu_nmk2nid" }
+ };
+
+ printf ("test du module secu\n");
+ for (i=0; i<COUNT (SecuTest) ; i++)
+ {
+ res = SecuTest[i].func ();
+ if(verbose || (res != 0))
+ {
+ printf (" %-50s", SecuTest[i].FuncName);
+ if (res == 0) printf ("OK\n");
+ else printf ("FAILED : %i\n", res);
+ }
+ if(res != 0) return_value++;
+ }
+ if (i != COUNT(SecuTest)) return 1;
+ return return_value;
+}