summaryrefslogtreecommitdiffstats
path: root/cpukit/libmd/sha256c.c
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2016-05-26 19:29:29 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-09-08 16:14:56 +0200
commit3a22e5d30f49090d95ebff0e157b19522a38be35 (patch)
tree8d76d7e97bfdb251821e89688794391ede575b16 /cpukit/libmd/sha256c.c
parentReplace sys/crypto/sha2/sha2.c with lib/libmd/sha512c.c (diff)
downloadrtems-3a22e5d30f49090d95ebff0e157b19522a38be35.tar.bz2
crypto routines: Hint minimum buffer sizes to the compiler
Use the C99 'static' keyword to hint to the compiler IVs and output digest sizes. The keyword informs the compiler of the minimum valid size for a given array. Obviously not every pointer can be validated (i.e., the compiler can produce false negative but not false positive reports). No functional change. No ABI change. Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'cpukit/libmd/sha256c.c')
-rw-r--r--cpukit/libmd/sha256c.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/cpukit/libmd/sha256c.c b/cpukit/libmd/sha256c.c
index 4c0371dda7..f5a453e43b 100644
--- a/cpukit/libmd/sha256c.c
+++ b/cpukit/libmd/sha256c.c
@@ -283,7 +283,7 @@ SHA256_Update(SHA256_CTX * ctx, const void *in, size_t len)
* and clears the context state.
*/
void
-SHA256_Final(unsigned char digest[32], SHA256_CTX * ctx)
+SHA256_Final(unsigned char digest[static SHA256_DIGEST_LENGTH], SHA256_CTX *ctx)
{
/* Add padding */
@@ -291,7 +291,8 @@ SHA256_Final(unsigned char digest[32], SHA256_CTX * ctx)
/* Write the hash */
be32enc_vect(digest, ctx->state, 32);
+ be32enc_vect(digest, ctx->state, SHA256_DIGEST_LENGTH);
/* Clear the context state */
- memset((void *)ctx, 0, sizeof(*ctx));
+ memset(ctx, 0, sizeof(*ctx));
}