Add additional self tests

And whitespace check-in
pull/769/head
Jeffrey Walton 2018-12-25 10:08:49 -05:00
parent 7226abd433
commit a749296504
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
3 changed files with 66 additions and 36 deletions

View File

@ -922,6 +922,10 @@ bool Validate(int alg, bool thorough, const char *seedInput)
case 9994: result = TestHuffmanCodes(); break;
// http://github.com/weidai11/cryptopp/issues/346
case 9993: result = TestASN1Parse(); break;
// http://github.com/weidai11/cryptopp/issues/242
case 9992: result = TestX25519(); break;
// http://github.com/weidai11/cryptopp/issues/346
case 9991: result = TestEd25519(); break;
# if defined(CRYPTOPP_ALTIVEC_AVAILABLE)
case 9992: result = TestAltivecOps(); break;
# endif

View File

@ -88,6 +88,7 @@ bool ValidateAll(bool thorough)
pass=TestSharing() && pass;
pass=TestEncryptors() && pass;
pass=TestX25519() && pass;
pass=TestEd25519() && pass;
#endif
pass=ValidateCRC32() && pass;

View File

@ -366,11 +366,24 @@ bool TestX25519()
bool pass = true;
try {
x25519 x1(FileSource(DataDir("TestData/x25519.dat").c_str(), true).Ref());
x25519 x2(FileSource(DataDir("TestData/x25519v0.dat").c_str(), true).Ref());
x25519 x3(FileSource(DataDir("TestData/x25519v1.dat").c_str(), true).Ref());
FileSource f1(DataDir("TestData/x25519.dat").c_str(), true, new HexDecoder);
FileSource f2(DataDir("TestData/x25519v0.dat").c_str(), true, new HexDecoder);
FileSource f3(DataDir("TestData/x25519v1.dat").c_str(), true, new HexDecoder);
x25519 x1(f1);
x25519 x2(f2);
x25519 x3(f3);
FileSource f4(DataDir("TestData/x25519.dat").c_str(), true, new HexDecoder);
FileSource f5(DataDir("TestData/x25519v0.dat").c_str(), true, new HexDecoder);
FileSource f6(DataDir("TestData/x25519v1.dat").c_str(), true, new HexDecoder);
x1.Load(f4);
x2.Load(f5);
x3.Load(f6);
}
catch (BERDecodeErr&) {
catch (const BERDecodeErr&) {
pass = false;
}
@ -424,11 +437,23 @@ bool TestEd25519()
bool pass = true;
try {
ed25519::Signer s1(FileSource(DataDir("TestData/ed25519.dat").c_str(), true).Ref());
ed25519::Signer s2(FileSource(DataDir("TestData/ed25519v0.dat").c_str(), true).Ref());
ed25519::Signer s3(FileSource(DataDir("TestData/ed25519v1.dat").c_str(), true).Ref());
FileSource f1(DataDir("TestData/ed25519.dat").c_str(), true, new HexDecoder);
FileSource f2(DataDir("TestData/ed25519v0.dat").c_str(), true, new HexDecoder);
FileSource f3(DataDir("TestData/ed25519v1.dat").c_str(), true, new HexDecoder);
ed25519::Signer s1(f1);
ed25519::Signer s2(f2);
ed25519::Signer s3(f3);
FileSource f4(DataDir("TestData/ed25519.dat").c_str(), true, new HexDecoder);
FileSource f5(DataDir("TestData/ed25519v0.dat").c_str(), true, new HexDecoder);
FileSource f6(DataDir("TestData/ed25519v1.dat").c_str(), true, new HexDecoder);
s1.AccessKey().Load(f4);
s2.AccessKey().Load(f5);
s3.AccessKey().Load(f6);
}
catch (BERDecodeErr&) {
catch (const BERDecodeErr&) {
pass = false;
}