summaryrefslogtreecommitdiff
path: root/cesar/cp2/secu/test/src/test-pbkdf1.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/cp2/secu/test/src/test-pbkdf1.c')
-rw-r--r--cesar/cp2/secu/test/src/test-pbkdf1.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/cesar/cp2/secu/test/src/test-pbkdf1.c b/cesar/cp2/secu/test/src/test-pbkdf1.c
new file mode 100644
index 0000000000..e069ba80b2
--- /dev/null
+++ b/cesar/cp2/secu/test/src/test-pbkdf1.c
@@ -0,0 +1,65 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/test-pbkdf1.c
+ * \brief Test pbkdf1 functions.
+ * \ingroup cp2_secu
+ *
+ */
+#include "common/std.h"
+#include "string.h"
+
+#include "lib/test.h"
+#include "cp2/secu/defs.h"
+#include "cp2/secu/pbkdf1.h"
+#include "cp2/secu/sha256.h"
+
+void
+test_case_pbkdf1 (test_t test)
+{
+ uint i;
+
+ u8 buffer [128] __attribute__((aligned(128))) = "HOMEPLUG_AV123\0";
+ u8 result [128] __attribute__((aligned(128))) = "HOMEPLUG_AV123\0";
+
+ result[14] = 0x08;
+ result[15] = 0x85;
+ result[16] = 0x6D;
+ result[17] = 0xAF;
+ result[18] = 0x7C;
+ result[19] = 0xF5;
+ result[20] = 0x81;
+ result[21] = 0x86;
+
+ for (i = 0; i < 1000; i++)
+ {
+ cp_secu_sha256(result);
+ }
+
+ cp_secu_pbkdf1 (buffer, CP_SECU_SALT_KEY_NMK_HS);
+
+ test_begin (test, "PBKDF1")
+ {
+ test_fail_if (memcmp (buffer, result, CP_SECU_OUTPUT_KEY_SIZE) != 0,
+ "Wrong Hash");
+ }
+ test_end;
+}
+
+int
+main (void)
+{
+ test_t test;
+
+ test_init (test, 0, NULL);
+
+ test_case_pbkdf1 (test);
+
+ test_result (test);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}