Skip to content

Commit

Permalink
Fix SIMON128 when running on POWER8 and above (GH #1237)
Browse files Browse the repository at this point in the history
This was an Asan failure uncovered by cryptest.sh
  • Loading branch information
noloader committed Oct 1, 2023
1 parent 34151a5 commit 45f8a77
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions simon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ void SIMON64::Base::UncheckedSetKey(const byte *userKey, unsigned int keyLength,
switch (m_kwords)
{
case 3:
m_rkeys.New((m_rounds = 42));
m_rkeys.New((m_rounds = 42)+1);
kblk(m_wspace[2])(m_wspace[1])(m_wspace[0]);
SIMON64_ExpandKey_3W(m_rkeys, m_wspace);
break;
case 4:
m_rkeys.New((m_rounds = 44));
m_rkeys.New((m_rounds = 44)+1);
kblk(m_wspace[3])(m_wspace[2])(m_wspace[1])(m_wspace[0]);
SIMON64_ExpandKey_4W(m_rkeys, m_wspace);
break;
Expand Down Expand Up @@ -364,17 +364,17 @@ void SIMON128::Base::UncheckedSetKey(const byte *userKey, unsigned int keyLength
switch (m_kwords)
{
case 2:
m_rkeys.New((m_rounds = 68));
m_rkeys.New((m_rounds = 68)+1);
kblk(m_wspace[1])(m_wspace[0]);
SIMON128_ExpandKey_2W(m_rkeys, m_wspace);
break;
case 3:
m_rkeys.New((m_rounds = 69));
m_rkeys.New((m_rounds = 69)+1);
kblk(m_wspace[2])(m_wspace[1])(m_wspace[0]);
SIMON128_ExpandKey_3W(m_rkeys, m_wspace);
break;
case 4:
m_rkeys.New((m_rounds = 72));
m_rkeys.New((m_rounds = 72)+1);
kblk(m_wspace[3])(m_wspace[2])(m_wspace[1])(m_wspace[0]);
SIMON128_ExpandKey_4W(m_rkeys, m_wspace);
break;
Expand Down

0 comments on commit 45f8a77

Please sign in to comment.