Skip to content

Commit

Permalink
Improve constant propagation of fix for Issue 146
Browse files Browse the repository at this point in the history
  • Loading branch information
noloader committed Apr 7, 2016
1 parent ab39385 commit 50e5c14
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions rijndael.cpp
Expand Up @@ -388,10 +388,12 @@ void Rijndael::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock
t3 = rk[7];
rk += 8;

// timing attack countermeasure. see comments at top for more details
// timing attack countermeasure. see comments at top for more details.
// also see http://github.com/weidai11/cryptopp/issues/146
const int cacheLineSize = GetCacheLineSize();
unsigned int i;
volatile word32 u = 0;
volatile word32 _u = 0;
word32 u = _u;
#if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) || defined(CRYPTOPP_ALLOW_RIJNDAEL_UNALIGNED_DATA_ACCESS)
for (i=0; i<2048; i+=cacheLineSize)
#else
Expand Down Expand Up @@ -464,10 +466,12 @@ void Rijndael::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock
t3 = rk[7];
rk += 8;

// timing attack countermeasure. see comments at top for more details
// timing attack countermeasure. see comments at top for more details.
// also see http://github.com/weidai11/cryptopp/issues/146
const int cacheLineSize = GetCacheLineSize();
unsigned int i;
volatile word32 u = 0;
volatile word32 _u = 0;
word32 u = _u;
#if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) || defined(CRYPTOPP_ALLOW_RIJNDAEL_UNALIGNED_DATA_ACCESS)
for (i=0; i<2048; i+=cacheLineSize)
#else
Expand Down

1 comment on commit 50e5c14

@noloader
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also see Issue 146 and the tail of the comments at Pull Request 154.

Please sign in to comment.