Skip to content

Commit

Permalink
hashes/sha224: Remove static variables from sha224
Browse files Browse the repository at this point in the history
  • Loading branch information
bergzand committed Nov 29, 2023
1 parent c98f3a7 commit 4ef7b88
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions sys/hashes/sha224.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,12 @@ void sha224_init(sha224_context_t *ctx)
ctx->state[7] = 0xBEFA4FA4;
}

void *sha224(const void *data, size_t len, void *digest)
void sha224(const void *data, size_t len, void *digest)
{
sha224_context_t c;
static unsigned char m[SHA224_DIGEST_LENGTH];

if (digest == NULL) {
digest = m;
}
assert(digest);

sha224_init(&c);
sha224_update(&c, data, len);
sha224_final(&c, digest);

return digest;
}
2 changes: 1 addition & 1 deletion sys/include/hashes/sha224.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static inline void sha224_final(sha224_context_t *ctx, void *digest)
* be SHA224_DIGEST_LENGTH
* if digest == NULL, one static buffer is used
*/
void *sha224(const void *data, size_t len, void *digest);
void sha224(const void *data, size_t len, void *digest);

#ifdef __cplusplus
}
Expand Down

0 comments on commit 4ef7b88

Please sign in to comment.