process unaligned data through a trampoline buffer when architecture needs it
should fix #108
This commit is contained in:
parent
12a26c14c4
commit
ba10930add
@ -25,6 +25,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "cryptonite_bitfn.h"
|
#include "cryptonite_bitfn.h"
|
||||||
|
#include "cryptonite_align.h"
|
||||||
#include "cryptonite_sha3.h"
|
#include "cryptonite_sha3.h"
|
||||||
|
|
||||||
#define KECCAK_NB_ROUNDS 24
|
#define KECCAK_NB_ROUNDS 24
|
||||||
@ -124,9 +125,19 @@ void cryptonite_sha3_update(struct sha3_ctx *ctx, const uint8_t *data, uint32_t
|
|||||||
ctx->bufindex = 0;
|
ctx->bufindex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* process as much ctx->bufsz-block */
|
if (need_alignment(data, 8)) {
|
||||||
for (; len >= ctx->bufsz; len -= ctx->bufsz, data += ctx->bufsz)
|
uint64_t tramp[200 - 2 * (224 / 8)];
|
||||||
sha3_do_chunk(ctx->state, (uint64_t *) data, ctx->bufsz / 8);
|
ASSERT_ALIGNMENT(tramp, 8);
|
||||||
|
for (; len >= ctx->bufsz; len -= ctx->bufsz, data += ctx->bufsz) {
|
||||||
|
memcpy(tramp, data, ctx->bufsz / 8);
|
||||||
|
sha3_do_chunk(ctx->state, (uint64_t *) data, ctx->bufsz / 8);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* process as much ctx->bufsz-block */
|
||||||
|
for (; len >= ctx->bufsz; len -= ctx->bufsz, data += ctx->bufsz)
|
||||||
|
sha3_do_chunk(ctx->state, (uint64_t *) data, ctx->bufsz / 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* append data into buf */
|
/* append data into buf */
|
||||||
if (len) {
|
if (len) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user