Introduce hash context to support pluggable SHA256 compression
This is purely a mechanical change with no behavior change. It introduces a secp256k1_hash_ctx struct inside secp256k1_context and propagates it to all SHA256-related operations. This sets up the ability to provide a hardware-optimized SHA256 compression function at runtime in a follow-up commit.
This commit is contained in:
@@ -22,12 +22,13 @@ SECP256K1_INLINE static void testrand_seed(const unsigned char *seed16) {
|
||||
unsigned char out32[32];
|
||||
secp256k1_sha256 hash;
|
||||
int i;
|
||||
const secp256k1_hash_ctx *hash_ctx = secp256k1_get_hash_context(secp256k1_context_static);
|
||||
|
||||
/* Use SHA256(PREFIX || seed16) as initial state. */
|
||||
secp256k1_sha256_initialize(&hash);
|
||||
secp256k1_sha256_write(&hash, PREFIX, sizeof(PREFIX));
|
||||
secp256k1_sha256_write(&hash, seed16, 16);
|
||||
secp256k1_sha256_finalize(&hash, out32);
|
||||
secp256k1_sha256_write(hash_ctx, &hash, PREFIX, sizeof(PREFIX));
|
||||
secp256k1_sha256_write(hash_ctx, &hash, seed16, 16);
|
||||
secp256k1_sha256_finalize(hash_ctx, &hash, out32);
|
||||
for (i = 0; i < 4; ++i) {
|
||||
uint64_t s = 0;
|
||||
int j;
|
||||
|
||||
Reference in New Issue
Block a user