mirror of
https://github.com/kazu-yamamoto/crypton.git
synced 2024-10-04 15:57:47 +03:00
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 <string.h>
|
||||
#include "cryptonite_bitfn.h"
|
||||
#include "cryptonite_align.h"
|
||||
#include "cryptonite_sha3.h"
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
if (need_alignment(data, 8)) {
|
||||
uint64_t tramp[200 - 2 * (224 / 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 */
|
||||
if (len) {
|
||||
|
Loading…
Reference in New Issue
Block a user