From cd5ab329f2a2bfc20da17613886b50e7a2c7e41a Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Mon, 23 Jul 2007 16:10:06 +0000 Subject: [PATCH] Optimized OPENSSL_cleanse [from HEAD]. --- crypto/mem_clr.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crypto/mem_clr.c b/crypto/mem_clr.c index 75cbfb374e..add1f78020 100644 --- a/crypto/mem_clr.c +++ b/crypto/mem_clr.c @@ -64,12 +64,14 @@ unsigned char cleanse_ctr = 0; void OPENSSL_cleanse(void *ptr, size_t len) { unsigned char *p = ptr; - size_t loop = len; + size_t loop = len, ctr = cleanse_ctr; while(loop--) { - *(p++) = cleanse_ctr; - cleanse_ctr += (17 + (unsigned char)((unsigned long)p & 0xF)); + *(p++) = (unsigned char)ctr; + ctr += (17 + ((size_t)p & 0xF)); } - if(memchr(ptr, cleanse_ctr, len)) - cleanse_ctr += 63; + p=memchr(ptr, (unsigned char)ctr, len); + if(p) + ctr += (63 + (size_t)p); + cleanse_ctr = (unsigned char)ctr; } -- 2.25.1