[nginx] Usage of ngx_explicit_memzero() in internal md5 and sha1.

Maxim Dounin mdounin at mdounin.ru
Sat Aug 31 00:54:19 UTC 2024


details:   http://freenginx.org/hg/nginx/rev/0086f8da5d8d
branches:  
changeset: 9325:0086f8da5d8d
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Sat Aug 31 00:30:44 2024 +0300
description:
Usage of ngx_explicit_memzero() in internal md5 and sha1.

The goal of the context cleanup in ngx_md5_final() and ngx_sha1_final()
is to clear potentially sensitive data, so ngx_explicit_memzero() is
appropriate.

diffstat:

 src/core/ngx_md5.c  |  2 +-
 src/core/ngx_sha1.c |  2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diffs (24 lines):

diff --git a/src/core/ngx_md5.c b/src/core/ngx_md5.c
--- a/src/core/ngx_md5.c
+++ b/src/core/ngx_md5.c
@@ -107,7 +107,7 @@ ngx_md5_final(u_char result[16], ngx_md5
     result[14] = (u_char) (ctx->d >> 16);
     result[15] = (u_char) (ctx->d >> 24);
 
-    ngx_memzero(ctx, sizeof(*ctx));
+    ngx_explicit_memzero(ctx, sizeof(*ctx));
 }
 
 
diff --git a/src/core/ngx_sha1.c b/src/core/ngx_sha1.c
--- a/src/core/ngx_sha1.c
+++ b/src/core/ngx_sha1.c
@@ -113,7 +113,7 @@ ngx_sha1_final(u_char result[20], ngx_sh
     result[18] = (u_char) (ctx->e >> 8);
     result[19] = (u_char) ctx->e;
 
-    ngx_memzero(ctx, sizeof(*ctx));
+    ngx_explicit_memzero(ctx, sizeof(*ctx));
 }
 
 


More information about the nginx-devel mailing list