From: David Carlier Date: Tue, 18 Jun 2019 15:02:57 +0000 (+0000) Subject: Crypto: zeroing the context after usage. X-Git-Tag: 0.3.4~104 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=059174a9acc0be396af45757f2ee8f38b29532ba;p=njs.git Crypto: zeroing the context after usage. Regardless of the compiler optimisation. This closes #181 pull request. --- diff --git a/nxt/nxt_md5.c b/nxt/nxt_md5.c index 5382021f..1f488cf6 100644 --- a/nxt/nxt_md5.c +++ b/nxt/nxt_md5.c @@ -110,7 +110,7 @@ nxt_md5_final(u_char result[16], nxt_md5_t *ctx) result[14] = (u_char) (ctx->d >> 16); result[15] = (u_char) (ctx->d >> 24); - nxt_memzero(ctx, sizeof(*ctx)); + nxt_explicit_memzero(ctx, sizeof(*ctx)); } diff --git a/nxt/nxt_sha1.c b/nxt/nxt_sha1.c index 2b96cdc3..500b47ef 100644 --- a/nxt/nxt_sha1.c +++ b/nxt/nxt_sha1.c @@ -116,7 +116,7 @@ nxt_sha1_final(u_char result[20], nxt_sha1_t *ctx) result[18] = (u_char) (ctx->e >> 8); result[19] = (u_char) ctx->e; - nxt_memzero(ctx, sizeof(*ctx)); + nxt_explicit_memzero(ctx, sizeof(*ctx)); } diff --git a/nxt/nxt_sha2.c b/nxt/nxt_sha2.c index 9a52ae4d..58243952 100644 --- a/nxt/nxt_sha2.c +++ b/nxt/nxt_sha2.c @@ -131,7 +131,7 @@ nxt_sha2_final(u_char result[32], nxt_sha2_t *ctx) result[30] = (u_char) (ctx->h >> 8); result[31] = (u_char) ctx->h; - nxt_memzero(ctx, sizeof(*ctx)); + nxt_explicit_memzero(ctx, sizeof(*ctx)); } diff --git a/nxt/nxt_string.h b/nxt/nxt_string.h index 3859e0ac..5c3086e6 100644 --- a/nxt/nxt_string.h +++ b/nxt/nxt_string.h @@ -97,7 +97,7 @@ nxt_explicit_memzero(buf, length) \ (void) explicit_memset(buf, 0, length) #else nxt_inline void -nxt_explicit_memzero(u_char *buf, size_t length) +nxt_explicit_memzero(void *buf, size_t length) { volatile u_char *p = (volatile u_char *) buf;