Skip to content

Commit

Permalink
Optimize OPENSSL_cleanse.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Polyakov committed Jun 20, 2007
1 parent 1c7f870 commit c943ca5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crypto/mem_clr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit c943ca5

Please sign in to comment.