mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2024-10-01 01:45:38 -04:00
Pass the blake2s_ctx to blake2s() as arg
Instead of allocating the blake2s_ctx in the blake2s() function we pass it as a pointer as an argument to be able to better control where the variable is in memory.
This commit is contained in:
parent
e0d68f3dae
commit
6d08a82c05
@ -334,16 +334,15 @@ void blake2s_final(blake2s_ctx *ctx, void *out)
|
||||
//------------------------------------------------------------------
|
||||
int blake2s(void *out, size_t outlen,
|
||||
const void *key, size_t keylen,
|
||||
const void *in, size_t inlen)
|
||||
const void *in, size_t inlen,
|
||||
blake2s_ctx *ctx)
|
||||
{
|
||||
blake2s_ctx ctx;
|
||||
|
||||
if (blake2s_init(&ctx, outlen, key, keylen))
|
||||
if (blake2s_init(ctx, outlen, key, keylen))
|
||||
return -1;
|
||||
|
||||
blake2s_update(&ctx, in, inlen);
|
||||
blake2s_update(ctx, in, inlen);
|
||||
|
||||
blake2s_final(&ctx, out);
|
||||
blake2s_final(ctx, out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ void blake2s_final(blake2s_ctx *ctx, void *out);
|
||||
// All-in-one convenience function.
|
||||
int blake2s(void *out, size_t outlen, // return buffer for digest
|
||||
const void *key, size_t keylen, // optional secret key
|
||||
const void *in, size_t inlen); // data to be hashed
|
||||
const void *in, size_t inlen, // data to be hashed
|
||||
blake2s_ctx *ctx);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user