Commit f9027544 authored by Geoff Simmons's avatar Geoff Simmons

make the SHA256_CTX local to the inline digest function

parent 32cf40bc
......@@ -86,9 +86,10 @@ errmsg(VRT_CTX, const char *fmt, ...)
}
static inline void
digest(SHA256_CTX *restrict const ctx, VCL_BLOB restrict const b,
uint8_t *restrict digest)
digest(VCL_BLOB restrict const b, uint8_t *restrict digest)
{
SHA256_CTX ctx[1];
SHA256_Init(ctx);
SHA256_Update(ctx, b->priv, b->len);
SHA256_Final(digest, ctx);
......@@ -114,10 +115,9 @@ vmod_hmac__init(VRT_CTX, struct vmod_blobsha256_hmac **hmacp,
if (key->len <= SHA256_BLOCKSZ)
memcpy(k, key->priv, key->len);
else {
SHA256_CTX hctx[1];
digest(hctx, key, k);
}
else
digest(key, k);
for (int i = 0; i < SHA256_BLOCKSZ; i++) {
innerk[i] = k[i] ^ 0x36;
outerk[i] = k[i] ^ 0x5c;
......@@ -185,7 +185,6 @@ vmod_blob__init(VRT_CTX, struct vmod_blobsha256_blob **blobp,
const char *vcl_name, VCL_BLOB b)
{
struct vmod_blobsha256_blob *blob;
SHA256_CTX hctx[1];
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(blobp);
......@@ -203,7 +202,7 @@ vmod_blob__init(VRT_CTX, struct vmod_blobsha256_blob **blobp,
blob->hash.len = SHA256_LEN;
blob->hash.free = NULL;
digest(hctx, b, blob->hash.priv);
digest(b, blob->hash.priv);
}
VCL_BLOB
......@@ -233,7 +232,6 @@ vmod_hash(VRT_CTX, VCL_BLOB msg)
{
struct vmod_priv *b;
char *snap;
SHA256_CTX hctx[1];
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
if (INIT_FINI(ctx)) {
......@@ -256,7 +254,7 @@ vmod_hash(VRT_CTX, VCL_BLOB msg)
}
b->len = SHA256_LEN;
b->free = NULL;
digest(hctx, msg, b->priv);
digest(msg, b->priv);
return b;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment