1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-06-20 05:48:19 +00:00

cubehash_impl.h: finalize without an incomplete block.

Currently, process_final_incomplete_block() will perform the round
R calculation with the remaining data, then finalize CubeHash. It
is not possible to finalize CubeHash if there's no incomplete block.

Here, we define the call of process_final_incomplete_block(NULL, 0)
as a way to directly finalize CubeHash when input is a multiple of
block size and there is no remaining data for round R.

Also, in this case, any call of process_final_incomplete_block(),
but only with a single NULL pointer, or only with n == 0, is an
indication of bug. We assert both to be zero/nonzero.

Signed-off-by: Tom Li <tomli@tomli.me>
This commit is contained in:
Tom Li 2019-01-03 21:18:21 +08:00
parent 7021f6c734
commit 29f7826b1e
No known key found for this signature in database
GPG Key ID: FAD3EB05E88E8D6D

@ -23,6 +23,7 @@
#include "types.h"
#include <cassert>
#include <stdint.h>
#define ROT(a,b,n) (((a) << (b)) | ((a) >> (n - b)))
@ -99,6 +100,13 @@ public:
void process_final_incomplete_block (const byte*data, int n) {
int i;
if (data == NULL && n == 0) {
//empty block, finalize
X[31] ^= 1;
rounds (F);
return;
}
assert(data != NULL && n != 0); // if only one is NULL/0, it's a bug
for (i = 0; i + 4 <= n; i += 4)
#if __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__