Fossil SCM
The default SHA3 hash size is 256, not 224. Fix the comments and the (unused) default initialization in the SHA3Init() routine.
Commit
4a31a093a3058acd8003793d4b0b5eab16892fe1
Parent
691a64923448492…
1 file changed
+2
-2
+2
-2
| --- src/sha3.c | ||
| +++ src/sha3.c | ||
| @@ -378,18 +378,18 @@ | ||
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /* |
| 381 | 381 | ** Initialize a new hash. iSize determines the size of the hash |
| 382 | 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. | |
| 383 | +** can be zero to use the default hash size of 256 bits. | |
| 384 | 384 | */ |
| 385 | 385 | static void SHA3Init(SHA3Context *p, int iSize){ |
| 386 | 386 | memset(p, 0, sizeof(*p)); |
| 387 | 387 | if( iSize>=128 && iSize<=512 ){ |
| 388 | 388 | p->nRate = (1600 - ((iSize + 31)&~31)*2)/8; |
| 389 | 389 | }else{ |
| 390 | - p->nRate = 144; | |
| 390 | + p->nRate = (1600 - 2*256)/8; | |
| 391 | 391 | } |
| 392 | 392 | #if SHA3_BYTEORDER==1234 |
| 393 | 393 | /* Known to be little-endian at compile-time. No-op */ |
| 394 | 394 | #elif SHA3_BYTEORDER==4321 |
| 395 | 395 | p->ixMask = 7; /* Big-endian */ |
| 396 | 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 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 |