1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

hashes/sha224: Remove static variables from sha224

This commit is contained in:
Koen Zandberg 2023-11-29 10:43:58 +01:00
parent bac3f48dc9
commit 434e5647d0
No known key found for this signature in database
GPG Key ID: BA1718B37D79F51C
2 changed files with 5 additions and 11 deletions

View File

@ -19,6 +19,7 @@
*/
#include <string.h>
#include <assert.h>
#include "hashes/sha224.h"
#include "hashes/sha2xx_common.h"
@ -40,18 +41,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;
}

View File

@ -110,11 +110,10 @@ static inline void sha224_final(sha224_context_t *ctx, void *digest)
*
* @param[in] data pointer to the buffer to generate hash from
* @param[in] len length of the buffer
* @param[out] digest optional pointer to an array for the result, length must
* @param[out] digest Pointer to an array for the result, length must
* 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
}