1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-22 23:48:58 +00:00

Implement state clone for rest of SHA-2 incremental API

This commit is contained in:
Douglas Stebila 2019-07-30 13:25:23 -04:00
parent 4d7e5886c9
commit b70216eb8d
2 changed files with 15 additions and 0 deletions

View File

@ -529,10 +529,22 @@ void sha512_inc_init(sha512ctx *state) {
} }
} }
void sha224_inc_clone_state(sha224ctx *stateout, const sha224ctx *statein) {
memcpy(stateout, statein, sizeof(sha224ctx));
}
void sha256_inc_clone_state(sha256ctx *stateout, const sha256ctx *statein) { void sha256_inc_clone_state(sha256ctx *stateout, const sha256ctx *statein) {
memcpy(stateout, statein, sizeof(sha256ctx)); memcpy(stateout, statein, sizeof(sha256ctx));
} }
void sha384_inc_clone_state(sha384ctx *stateout, const sha384ctx *statein) {
memcpy(stateout, statein, sizeof(sha384ctx));
}
void sha512_inc_clone_state(sha512ctx *stateout, const sha512ctx *statein) {
memcpy(stateout, statein, sizeof(sha512ctx));
}
void sha256_inc_blocks(sha256ctx *state, const uint8_t *in, size_t inblocks) { void sha256_inc_blocks(sha256ctx *state, const uint8_t *in, size_t inblocks) {
uint64_t bytes = load_bigendian_64(state->ctx + 32); uint64_t bytes = load_bigendian_64(state->ctx + 32);

View File

@ -25,6 +25,7 @@ typedef struct {
} sha512ctx; } sha512ctx;
void sha224_inc_init(sha224ctx *state); void sha224_inc_init(sha224ctx *state);
void sha224_inc_clone_state(sha224ctx *stateout, const sha224ctx *statein);
void sha224_inc_blocks(sha224ctx *state, const uint8_t *in, size_t inblocks); void sha224_inc_blocks(sha224ctx *state, const uint8_t *in, size_t inblocks);
void sha224_inc_finalize(uint8_t *out, sha224ctx *state, const uint8_t *in, size_t inlen); void sha224_inc_finalize(uint8_t *out, sha224ctx *state, const uint8_t *in, size_t inlen);
void sha224(uint8_t *out, const uint8_t *in, size_t inlen); void sha224(uint8_t *out, const uint8_t *in, size_t inlen);
@ -36,11 +37,13 @@ void sha256_inc_finalize(uint8_t *out, sha256ctx *state, const uint8_t *in, size
void sha256(uint8_t *out, const uint8_t *in, size_t inlen); void sha256(uint8_t *out, const uint8_t *in, size_t inlen);
void sha384_inc_init(sha384ctx *state); void sha384_inc_init(sha384ctx *state);
void sha384_inc_clone_state(sha384ctx *stateout, const sha384ctx *statein);
void sha384_inc_blocks(sha384ctx *state, const uint8_t *in, size_t inblocks); void sha384_inc_blocks(sha384ctx *state, const uint8_t *in, size_t inblocks);
void sha384_inc_finalize(uint8_t *out, sha384ctx *state, const uint8_t *in, size_t inlen); void sha384_inc_finalize(uint8_t *out, sha384ctx *state, const uint8_t *in, size_t inlen);
void sha384(uint8_t *out, const uint8_t *in, size_t inlen); void sha384(uint8_t *out, const uint8_t *in, size_t inlen);
void sha512_inc_init(sha512ctx *state); void sha512_inc_init(sha512ctx *state);
void sha512_inc_clone_state(sha512ctx *stateout, const sha512ctx *statein);
void sha512_inc_blocks(sha512ctx *state, const uint8_t *in, size_t inblocks); void sha512_inc_blocks(sha512ctx *state, const uint8_t *in, size_t inblocks);
void sha512_inc_finalize(uint8_t *out, sha512ctx *state, const uint8_t *in, size_t inlen); void sha512_inc_finalize(uint8_t *out, sha512ctx *state, const uint8_t *in, size_t inlen);
void sha512(uint8_t *out, const uint8_t *in, size_t inlen); void sha512(uint8_t *out, const uint8_t *in, size_t inlen);