From 72926b1eed7f7fd76b93b7a2814140c8f84240a1 Mon Sep 17 00:00:00 2001 From: toddouska Date: Mon, 25 Mar 2013 11:35:33 -0700 Subject: [PATCH] make sure blake2 calls denote it's the 'b' version, blake2b --- ctaocrypt/benchmark/benchmark.c | 16 ++++++++-------- ctaocrypt/src/blake2b.c | 22 +++++++++++----------- ctaocrypt/test/test.c | 24 ++++++++++++------------ cyassl/ctaocrypt/blake2.h | 14 +++++++------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/ctaocrypt/benchmark/benchmark.c b/ctaocrypt/benchmark/benchmark.c index 40e9eddaa..0f55aca7c 100644 --- a/ctaocrypt/benchmark/benchmark.c +++ b/ctaocrypt/benchmark/benchmark.c @@ -625,18 +625,18 @@ void bench_ripemd(void) #ifdef HAVE_BLAKE2 void bench_blake2(void) { - Blake2 b2; - byte digest[32]; - double start, total, persec; - int i; + Blake2b b2b; + byte digest[64]; + double start, total, persec; + int i; - InitBlake2(&b2, 32); + InitBlake2b(&b2b, 64); start = current_time(1); for(i = 0; i < numBlocks; i++) - Blake2Update(&b2, plain, sizeof(plain)); + Blake2bUpdate(&b2b, plain, sizeof(plain)); - Blake2Final(&b2, digest, 32); + Blake2bFinal(&b2b, digest, 64); total = current_time(0) - start; persec = 1 / total * numBlocks; @@ -645,7 +645,7 @@ void bench_blake2(void) persec = persec / 1024; #endif - printf("BLAKE2 %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, + printf("BLAKE2b %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, blockType, total, persec); } #endif diff --git a/ctaocrypt/src/blake2b.c b/ctaocrypt/src/blake2b.c index e43e8bdfa..0f962a77a 100644 --- a/ctaocrypt/src/blake2b.c +++ b/ctaocrypt/src/blake2b.c @@ -434,28 +434,28 @@ int main( int argc, char **argv ) /* CTaoCrypt API */ -/* Init Blake2 digest, track size incase final doesn't want to "remember" */ -int InitBlake2(Blake2* b2, word32 digestSz) +/* Init Blake2b digest, track size incase final doesn't want to "remember" */ +int InitBlake2b(Blake2b* b2b, word32 digestSz) { - b2->digestSz = digestSz; + b2b->digestSz = digestSz; - return blake2b_init(b2->S, (byte)digestSz); + return blake2b_init(b2b->S, (byte)digestSz); } -/* Blake2 Update */ -int Blake2Update(Blake2* b2, const byte* data, word32 sz) +/* Blake2b Update */ +int Blake2bUpdate(Blake2b* b2b, const byte* data, word32 sz) { - return blake2b_update(b2->S, data, sz); + return blake2b_update(b2b->S, data, sz); } -/* Blake2 Final, if pass in zero size we use init digestSz */ -int Blake2Final(Blake2* b2, byte* final, word32 requestSz) +/* Blake2b Final, if pass in zero size we use init digestSz */ +int Blake2bFinal(Blake2b* b2b, byte* final, word32 requestSz) { - word32 sz = requestSz ? requestSz : b2->digestSz; + word32 sz = requestSz ? requestSz : b2b->digestSz; - return blake2b_final(b2->S, final, (byte)sz); + return blake2b_final(b2b->S, final, (byte)sz); } diff --git a/ctaocrypt/test/test.c b/ctaocrypt/test/test.c index 80cb7ced4..4fe94eec9 100644 --- a/ctaocrypt/test/test.c +++ b/ctaocrypt/test/test.c @@ -146,7 +146,7 @@ int pbkdf2_test(void); int ecc_test(void); #endif #ifdef HAVE_BLAKE2 - int blake2_test(void); + int blake2b_test(void); #endif #ifdef HAVE_LIBZ int compress_test(void); @@ -247,10 +247,10 @@ void ctaocrypt_test(void* args) #endif #ifdef HAVE_BLAKE2 - if ( (ret = blake2_test()) ) - err_sys("BLAKE2 test failed!\n", ret); + if ( (ret = blake2b_test()) ) + err_sys("BLAKE2b test failed!\n", ret); else - printf( "BLAKE2 test passed!\n"); + printf( "BLAKE2b test passed!\n"); #endif #ifndef NO_HMAC @@ -835,20 +835,20 @@ static const byte blake2b_vec[BLAKE2_TESTS][BLAKE2B_OUTBYTES] = -int blake2_test(void) +int blake2b_test(void) { - Blake2 b2; - byte digest[64]; - byte input[64]; - int i; + Blake2b b2b; + byte digest[64]; + byte input[64]; + int i; for (i = 0; i < (int)sizeof(input); i++) input[i] = (byte)i; for (i = 0; i < BLAKE2_TESTS; i++) { - InitBlake2(&b2, 64); - Blake2Update(&b2, input, i); - Blake2Final(&b2, digest, 64); + InitBlake2b(&b2b, 64); + Blake2bUpdate(&b2b, input, i); + Blake2bFinal(&b2b, digest, 64); if (memcmp(digest, blake2b_vec[i], 64) != 0) { return -300 - i; diff --git a/cyassl/ctaocrypt/blake2.h b/cyassl/ctaocrypt/blake2.h index 6127d5346..9023de35b 100644 --- a/cyassl/ctaocrypt/blake2.h +++ b/cyassl/ctaocrypt/blake2.h @@ -30,20 +30,20 @@ /* in bytes, variable digest size up to 512 bits (64 bytes) */ enum { - BLAKE2_ID = 7 /* hash type unique */ + BLAKE2B_ID = 7 /* hash type unique */ }; -/* BLAKE2 digest */ -typedef struct Blake2 { +/* BLAKE2b digest */ +typedef struct Blake2b { blake2b_state S[1]; /* our state */ word32 digestSz; /* digest size used on init */ -} Blake2; +} Blake2b; -CYASSL_API int InitBlake2(Blake2*, word32); -CYASSL_API int Blake2Update(Blake2*, const byte*, word32); -CYASSL_API int Blake2Final(Blake2*, byte*, word32); +CYASSL_API int InitBlake2b(Blake2b*, word32); +CYASSL_API int Blake2bUpdate(Blake2b*, const byte*, word32); +CYASSL_API int Blake2bFinal(Blake2b*, byte*, word32);