]> git.cryptolib.org Git - arm-crypto-lib.git/commitdiff
adding sha512 to prf_tls12
authorbg <daniel.otte@rub.de>
Fri, 7 Oct 2011 21:20:52 +0000 (23:20 +0200)
committerbg <daniel.otte@rub.de>
Fri, 7 Oct 2011 21:20:52 +0000 (23:20 +0200)
mkfiles/prf_tls12.mk
test_src/main-prf_tls12-test.c

index dcf8d62dc9dfed7ec962fb40a81d238c51ea0b1b..d80c61e7591d878e92f544b4e76f2564c7f0767d 100644 (file)
@@ -5,10 +5,10 @@ ALGO_NAME := PRF_TLS12
 AUX += $(ALGO_NAME)
 
 $(ALGO_NAME)_DIR      := prf_tls12/
-$(ALGO_NAME)_INCDIR   := hmac/ sha1/ sha256/ hfal/
+$(ALGO_NAME)_INCDIR   := hmac/ sha512/ sha256/ hfal/
 $(ALGO_NAME)_OBJ      := prf_tls12.o
-$(ALGO_NAME)_TESTBIN := main-prf_tls12-test.o $(CLI_STD) hfal_sha1.o hfal_sha256.o $(HFAL_STD) \
-                        sha256.o sha1.o hfal-hmac.o
+$(ALGO_NAME)_TESTBIN := main-prf_tls12-test.o $(CLI_STD) hfal_sha512.o hfal_sha256.o $(HFAL_STD) \
+                        sha256.o sha512.o hfal-hmac.o
                         
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index b97d8ea804dca6dc5b5681fd4d9de4a37a0b7613..121031fb526b4320a0ef1712e5a73d210f81d3b5 100644 (file)
@@ -24,7 +24,7 @@
 #include "main-test-common.h"
 #include "prf_tls12.h"
 #include <crypto/hashfunction_descriptor.h>
-#include <crypto/hfal_sha1.h>
+#include <crypto/hfal_sha512.h>
 #include <crypto/hfal_sha256.h>
 const char* algo_name = "PRF-TLS1.2";
 
@@ -62,50 +62,62 @@ Output (100 bytes):
 0060    87 34 7b 66                .4.f
  */
 
-const uint8_t test_secret[] = {
-       0x9b, 0xbe, 0x43, 0x6b, 0xa9, 0x40, 0xf0, 0x17,
-       0xb1, 0x76, 0x52, 0x84, 0x9a, 0x71, 0xdb, 0x35
-};
-
-const uint8_t test_seed[] = {
-       0xa0, 0xba, 0x9f, 0x93, 0x6c, 0xda, 0x31, 0x18,
-       0x27, 0xa6, 0xf7, 0x96, 0xff, 0xd5, 0x19, 0x8c
-};
 
 const char test_label[] = "test label";
 
-void test_prf(const hfdesc_t* hash){
+void test_prf(const hfdesc_t* hash, const void* secret, const void* seed, uint16_t out_length){
        prf_tls12_ctx_t ctx;
-       uint8_t buffer[100];
-       prf_tls12_init_w_label(&ctx, hash, test_secret, 16*8, test_label, strlen(test_label), test_seed, 16*8);
+       uint8_t buffer[out_length];
+       prf_tls12_init_w_label(&ctx, hash, secret, 16*8, test_label, strlen(test_label), seed, 16*8);
        cli_putstr("\r\n== Testing PRF-TLSv1.2 with ");
        cli_putstr(hash->name);
        cli_putstr(" ==\r\n");
-       prf_tls12_fill(buffer, 100, &ctx);
-       cli_hexdump_block(buffer, 100, 4, 8);
+       prf_tls12_fill(buffer, out_length, &ctx);
+       cli_hexdump_block(buffer, out_length, 4, 8);
        prf_tls12_free(&ctx);
 }
 
 void test_sha256(void){
-       test_prf(&sha256_desc);
+       const uint8_t secret[] = {
+               0x9b, 0xbe, 0x43, 0x6b, 0xa9, 0x40, 0xf0, 0x17,
+               0xb1, 0x76, 0x52, 0x84, 0x9a, 0x71, 0xdb, 0x35
+       };
+
+       const uint8_t seed[] = {
+               0xa0, 0xba, 0x9f, 0x93, 0x6c, 0xda, 0x31, 0x18,
+               0x27, 0xa6, 0xf7, 0x96, 0xff, 0xd5, 0x19, 0x8c
+       };
+       test_prf(&sha256_desc, secret, seed, 100);
 }
 
-void test_sha1(void){
-       test_prf(&sha1_desc);
+void test_sha512(void){
+
+
+const uint8_t secret[] = {
+               0xb0, 0x32, 0x35, 0x23, 0xc1, 0x85, 0x35, 0x99,
+               0x58, 0x4d, 0x88, 0x56, 0x8b, 0xbb, 0x05, 0xeb
+       };
+
+const uint8_t seed[] = {
+               0xd4, 0x64, 0x0e, 0x12, 0xe4, 0xbc, 0xdb, 0xfb,
+               0x43, 0x7f, 0x03, 0xe6, 0xae, 0x41, 0x8e, 0xe5,
+       };
+       test_prf(&sha512_desc, secret, seed, 196);
 }
+
 /*****************************************************************************
  *  main                                                                                                                                        *
  *****************************************************************************/
 
 const char echo_test_str[]     = "echo-test";
 const char test_sha256_str[]   = "test-sha256";
-const char test_sha1_str[]     = "test-sha1";
+const char test_sha512_str[]   = "test-sha512";
 //const char performance_str[]   = "performance";
 const char echo_str[]          = "echo";
 
 cmdlist_entry_t cmdlist[] = {
        { test_sha256_str,      NULL, test_sha256                   },
-       { test_sha1_str,        NULL, test_sha1                     },
+       { test_sha512_str,      NULL, test_sha512                   },
 //     { performance_str,      NULL, testrun_performance_bigint    },
        { echo_str,         (void*)1, (void_fpt)echo_ctrl           },
        { NULL,                 NULL, NULL                          }