Fossil SCM

The default SHA3 hash size is 256, not 224. Fix the comments and the (unused) default initialization in the SHA3Init() routine.

drh 2017-03-08 13:01 trunk
Commit 4a31a093a3058acd8003793d4b0b5eab16892fe1
1 file changed +2 -2
+2 -2
--- src/sha3.c
+++ src/sha3.c
@@ -378,18 +378,18 @@
378378
}
379379
380380
/*
381381
** Initialize a new hash. iSize determines the size of the hash
382382
** in bits and should be one of 224, 256, 384, or 512. Or iSize
383
-** can be zero to use the default hash size of 224 bits.
383
+** can be zero to use the default hash size of 256 bits.
384384
*/
385385
static void SHA3Init(SHA3Context *p, int iSize){
386386
memset(p, 0, sizeof(*p));
387387
if( iSize>=128 && iSize<=512 ){
388388
p->nRate = (1600 - ((iSize + 31)&~31)*2)/8;
389389
}else{
390
- p->nRate = 144;
390
+ p->nRate = (1600 - 2*256)/8;
391391
}
392392
#if SHA3_BYTEORDER==1234
393393
/* Known to be little-endian at compile-time. No-op */
394394
#elif SHA3_BYTEORDER==4321
395395
p->ixMask = 7; /* Big-endian */
396396
--- src/sha3.c
+++ src/sha3.c
@@ -378,18 +378,18 @@
378 }
379
380 /*
381 ** Initialize a new hash. iSize determines the size of the hash
382 ** in bits and should be one of 224, 256, 384, or 512. Or iSize
383 ** can be zero to use the default hash size of 224 bits.
384 */
385 static void SHA3Init(SHA3Context *p, int iSize){
386 memset(p, 0, sizeof(*p));
387 if( iSize>=128 && iSize<=512 ){
388 p->nRate = (1600 - ((iSize + 31)&~31)*2)/8;
389 }else{
390 p->nRate = 144;
391 }
392 #if SHA3_BYTEORDER==1234
393 /* Known to be little-endian at compile-time. No-op */
394 #elif SHA3_BYTEORDER==4321
395 p->ixMask = 7; /* Big-endian */
396
--- src/sha3.c
+++ src/sha3.c
@@ -378,18 +378,18 @@
378 }
379
380 /*
381 ** Initialize a new hash. iSize determines the size of the hash
382 ** in bits and should be one of 224, 256, 384, or 512. Or iSize
383 ** can be zero to use the default hash size of 256 bits.
384 */
385 static void SHA3Init(SHA3Context *p, int iSize){
386 memset(p, 0, sizeof(*p));
387 if( iSize>=128 && iSize<=512 ){
388 p->nRate = (1600 - ((iSize + 31)&~31)*2)/8;
389 }else{
390 p->nRate = (1600 - 2*256)/8;
391 }
392 #if SHA3_BYTEORDER==1234
393 /* Known to be little-endian at compile-time. No-op */
394 #elif SHA3_BYTEORDER==4321
395 p->ixMask = 7; /* Big-endian */
396

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button