mirror of
https://github.com/biergaizi/codecrypt
synced 2024-06-27 01:08:15 +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:
parent
7021f6c734
commit
29f7826b1e
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define ROT(a,b,n) (((a) << (b)) | ((a) >> (n - b)))
|
#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) {
|
void process_final_incomplete_block (const byte*data, int n) {
|
||||||
|
|
||||||
int i;
|
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)
|
for (i = 0; i + 4 <= n; i += 4)
|
||||||
#if __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
|
#if __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
|
||||||
|
Loading…
Reference in New Issue
Block a user