Skip to content

Commit 92436b9

Browse files
committed
Re-enable Salsa20 ASM (GH weidai11#543)
We are fairly certain this is a false positive due to glibc's __memcmp_sse4_1.
1 parent f86c612 commit 92436b9

File tree

3 files changed

+8
-21
lines changed

3 files changed

+8
-21
lines changed

datatest.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,8 @@ void PutDecodedDatumInto(const TestData &data, const char *name, BufferedTransfo
116116
s1 = s1.substr(s1.find(' ')+1);
117117
}
118118

119-
// Convert endian order. Use it with 64-bit words like this:
120-
// Key: word64 BC2560EFC6BBA2B1 E3361F162238EB40 FB8631EE0ABBD175 7B9479D4C5479ED1
121-
// BC2560EFC6BBA2B1 will be processed into B1A2BBC6EF6025BC.
122-
// or:
123-
// Key: word32 BC2560EF E3361F16 FB8631EE 7B9479D4
124-
// BC2560EF will be processed into EF6025BC.
119+
// Convert word32 or word64 to little endian order. Some algorithm test vectors are
120+
// presented in the format. We probably should have named them word32le and word64le.
125121
if (s1.length() >= 6 && (s1.substr(0,6) == "word32" || s1.substr(0,6) == "word64"))
126122
{
127123
std::istringstream iss(s1.substr(6));
@@ -489,16 +485,7 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters)
489485
static_cast<BlockPaddingSchemeDef::BlockPaddingScheme>(paddingScheme));
490486
RandomizedTransfer(StringStore(plaintext).Ref(), encFilter, true);
491487
encFilter.MessageEnd();
492-
/*{
493-
std::string z;
494-
encryptor->Seek(seek);
495-
StringSource ss(plaintext, false, new StreamTransformationFilter(*encryptor, new StringSink(z),
496-
static_cast<BlockPaddingSchemeDef::BlockPaddingScheme>(paddingScheme)));
497-
while (ss.Pump(64)) {}
498-
ss.PumpAll();
499-
for (int i=0; i<z.length(); i++)
500-
CRYPTOPP_ASSERT(encrypted[i] == z[i]);
501-
}*/
488+
502489
if (test != "EncryptXorDigest")
503490
ciphertext = GetDecodedDatum(v, "Ciphertext");
504491
else

salsa.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void Salsa20_Policy::SeekToIteration(lword iterationCount)
7474
m_state[5] = (word32)SafeRightShift<32>(iterationCount);
7575
}
7676

77-
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) && !defined(CRYPTOPP_DISABLE_SALSA_ASM)
77+
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
7878
unsigned int Salsa20_Policy::GetAlignment() const
7979
{
8080
#if CRYPTOPP_SSE2_ASM_AVAILABLE

salsa.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// TODO: work around GCC 4.8+ issue with SSE2 ASM until the exact details are known
1313
// and fix is released. Duplicate with "valgrind ./cryptest.exe tv salsa"
1414
// "Inline assembly operands don't work with .intel_syntax", http://llvm.org/bugs/show_bug.cgi?id=24232
15-
#if CRYPTOPP_BOOL_X32 || defined(CRYPTOPP_DISABLE_INTEL_ASM) || (CRYPTOPP_GCC_VERSION >= 40800)
15+
#if CRYPTOPP_BOOL_X32 || defined(CRYPTOPP_DISABLE_INTEL_ASM)
1616
# define CRYPTOPP_DISABLE_SALSA_ASM
1717
#endif
1818

@@ -22,7 +22,7 @@ NAMESPACE_BEGIN(CryptoPP)
2222
//! \brief Salsa20 stream cipher information
2323
struct Salsa20_Info : public VariableKeyLength<32, 16, 32, 16, SimpleKeyingInterface::UNIQUE_IV, 8>
2424
{
25-
CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Salsa20";}
25+
static std::string StaticAlgorithmName() {return "Salsa20";}
2626
};
2727

2828
//! \class Salsa20_Policy
@@ -35,7 +35,7 @@ class CRYPTOPP_NO_VTABLE Salsa20_Policy : public AdditiveCipherConcretePolicy<wo
3535
void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
3636
bool CipherIsRandomAccess() const {return true;}
3737
void SeekToIteration(lword iterationCount);
38-
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) && !defined(CRYPTOPP_DISABLE_SALSA_ASM)
38+
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
3939
unsigned int GetAlignment() const;
4040
unsigned int GetOptimalBlockSize() const;
4141
#endif
@@ -58,7 +58,7 @@ struct Salsa20 : public Salsa20_Info, public SymmetricCipherDocumentation
5858
//! \brief XSalsa20 stream cipher information
5959
struct XSalsa20_Info : public FixedKeyLength<32, SimpleKeyingInterface::UNIQUE_IV, 24>
6060
{
61-
CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "XSalsa20";}
61+
static std::string StaticAlgorithmName() {return "XSalsa20";}
6262
};
6363

6464
//! \class XSalsa20_Policy

0 commit comments

Comments
 (0)