summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2018-07-20 07:01:28 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-09-08 16:14:56 +0200
commitf5ee9a0e0bdd2e8831c7d5dfeb2bdf890d76a18c (patch)
tree994c69c57a21c91ccc70abc6f6777b989dbc2705 /cpukit
parentImplement SHA2-224 submode of SHA2-256 (diff)
downloadrtems-f5ee9a0e0bdd2e8831c7d5dfeb2bdf890d76a18c.tar.bz2
libmd: Always erase context in _Final method,
and when doing it, consistently use explicit_bzero(). Update manual pages to match the behavior. Reviewed by: pfg, allanjude, jmg MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D16316
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/libmd/sha256c.c2
-rw-r--r--cpukit/libmd/sha512c.c8
2 files changed, 5 insertions, 5 deletions
diff --git a/cpukit/libmd/sha256c.c b/cpukit/libmd/sha256c.c
index 7fd568a2ab..563f9e2099 100644
--- a/cpukit/libmd/sha256c.c
+++ b/cpukit/libmd/sha256c.c
@@ -295,7 +295,7 @@ SHA256_Final(unsigned char digest[static SHA256_DIGEST_LENGTH], SHA256_CTX *ctx)
be32enc_vect(digest, ctx->state, SHA256_DIGEST_LENGTH);
/* Clear the context state */
- memset(ctx, 0, sizeof(*ctx));
+ explicit_bzero(ctx, sizeof(*ctx));
}
/*** SHA-224: *********************************************************/
diff --git a/cpukit/libmd/sha512c.c b/cpukit/libmd/sha512c.c
index daeef9d671..0b03d09fa9 100644
--- a/cpukit/libmd/sha512c.c
+++ b/cpukit/libmd/sha512c.c
@@ -327,7 +327,7 @@ SHA512_Final(unsigned char digest[static SHA512_DIGEST_LENGTH], SHA512_CTX *ctx)
be64enc_vect(digest, ctx->state, SHA512_DIGEST_LENGTH);
/* Clear the context state */
- memset(ctx, 0, sizeof(*ctx));
+ explicit_bzero(ctx, sizeof(*ctx));
}
/*** SHA-512t: *********************************************************/
@@ -370,7 +370,7 @@ SHA512_224_Final(unsigned char digest[static SHA512_224_DIGEST_LENGTH], SHA512_C
be64enc_vect(digest, ctx->state, SHA512_224_DIGEST_LENGTH);
/* Clear the context state */
- memset(ctx, 0, sizeof(*ctx));
+ explicit_bzero(ctx, sizeof(*ctx));
}
void
@@ -409,7 +409,7 @@ SHA512_256_Final(unsigned char digest[static SHA512_256_DIGEST_LENGTH], SHA512_C
be64enc_vect(digest, ctx->state, SHA512_256_DIGEST_LENGTH);
/* Clear the context state */
- memset(ctx, 0, sizeof(*ctx));
+ explicit_bzero(ctx, sizeof(*ctx));
}
/*** SHA-384: *********************************************************/
@@ -459,5 +459,5 @@ SHA384_Final(unsigned char digest[static SHA384_DIGEST_LENGTH], SHA384_CTX *ctx)
be64enc_vect(digest, ctx->state, SHA384_DIGEST_LENGTH);
/* Clear the context state */
- memset(ctx, 0, sizeof(*ctx));
+ explicit_bzero(ctx, sizeof(*ctx));
}