Fix AlgorithmName() for 128-bit block SIMON and SPECK

pull/548/head
Jeffrey Walton 2017-11-21 06:48:37 -05:00
parent c14e054ed8
commit 8cc76597c6
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 10 additions and 4 deletions

View File

@ -45,6 +45,7 @@ template <class W>
struct SIMON_Base
{
virtual ~SIMON_Base() {}
SIMON_Base() : m_kwords(0) {}
typedef SecBlock<W, AllocatorWithCleanup<W, true> > AlignedSecBlock;
mutable AlignedSecBlock m_wspace; // workspace
@ -68,7 +69,8 @@ public:
{
public:
std::string AlgorithmName() const {
return StaticAlgorithmName() + "(" + IntToString(m_kwords*sizeof(word32)*8) + ")";
return StaticAlgorithmName() + (m_kwords == 0 ? "" :
"(" + IntToString(m_kwords*sizeof(word32)*8) + ")");
}
protected:
@ -115,7 +117,8 @@ public:
{
public:
std::string AlgorithmName() const {
return StaticAlgorithmName() + "(" + IntToString(m_kwords*sizeof(word64)*8) + ")";
return StaticAlgorithmName() + (m_kwords == 0 ? "" :
"(" + IntToString(m_kwords*sizeof(word64)*8) + ")");
}
protected:

View File

@ -45,6 +45,7 @@ template <class W>
struct SPECK_Base
{
virtual ~SPECK_Base() {}
SPECK_Base() : m_kwords(0) {}
typedef SecBlock<W, AllocatorWithCleanup<W, true> > AlignedSecBlock;
mutable AlignedSecBlock m_wspace; // workspace
@ -68,7 +69,8 @@ public:
{
public:
std::string AlgorithmName() const {
return StaticAlgorithmName() + "(" + IntToString(m_kwords*sizeof(word32)*8) + ")";
return StaticAlgorithmName() + (m_kwords == 0 ? "" :
"(" + IntToString(m_kwords*sizeof(word32)*8) + ")");
}
protected:
@ -115,7 +117,8 @@ public:
{
public:
std::string AlgorithmName() const {
return StaticAlgorithmName() + "(" + IntToString(m_kwords*sizeof(word64)*8) + ")";
return StaticAlgorithmName() + (m_kwords == 0 ? "" :
"(" + IntToString(m_kwords*sizeof(word64)*8) + ")");
}
protected: