From: Andy Polyakov Date: Wed, 20 Jun 2007 17:36:39 +0000 (+0000) Subject: Optimize OPENSSL_cleanse. X-Git-Tag: OpenSSL_0_9_8k^2~789 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c943ca5404a9297cbe57aecb538b17fb06d98969;p=oweals%2Fopenssl.git Optimize OPENSSL_cleanse. --- diff --git a/crypto/mem_clr.c b/crypto/mem_clr.c index 75cbfb374e..00dfcff0cf 100644 --- a/crypto/mem_clr.c +++ b/crypto/mem_clr.c @@ -64,12 +64,13 @@ 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; + if(p=memchr(ptr, (unsigned char)ctr, len)) + ctr += (63 + (size_t)p); + cleanse_ctr = (unsigned char)ctr; }