Skip to content

Commit

Permalink
Add ed25519 (GH #764, PR #767)
Browse files Browse the repository at this point in the history
Add ed25519
  • Loading branch information
noloader committed Dec 24, 2018
1 parent 2ba3c1f commit d62674b
Show file tree
Hide file tree
Showing 29 changed files with 5,146 additions and 419 deletions.
35 changes: 22 additions & 13 deletions Filelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ dlltest.vcxproj.filters
dmac.h
drbg.h
donna.h
donna_32.h
donna_64.h
donna_sse.h
donna_32.cpp
donna_64.cpp
donna_sse.cpp
Expand Down Expand Up @@ -412,6 +415,10 @@ TestData/dlie2048.dat
TestData/dsa1024.dat
TestData/dsa1024b.dat
TestData/dsa512.dat
TestData/ed25519.dat
TestData/ed25519_ver.dat
TestData/ed25519v0.dat
TestData/ed25519v1.dat
TestData/elgc1024.dat
TestData/esig1023.dat
TestData/esig1536.dat
Expand Down Expand Up @@ -447,10 +454,10 @@ TestData/rc6val.dat
TestData/rijndael.dat
TestData/rsa1024.dat
TestData/rsa2048.dat
TestData/rsa2048a.dat
TestData/rsa400pb.dat
TestData/rsa400pv.dat
TestData/rsa512a.dat
TestData/rsa2048a.dat
TestData/rw1024.dat
TestData/rw2048.dat
TestData/saferval.dat
Expand All @@ -462,41 +469,43 @@ TestData/squareva.dat
TestData/twofishv.dat
TestData/usage.dat
TestData/x25519.dat
TestData/x25519v0.dat
TestData/x25519v1.dat
TestData/xtrdh171.dat
TestData/xtrdh342.dat
TestVectors/Readme.txt
TestVectors/aes.txt
TestVectors/all.txt
TestVectors/aria.txt
TestVectors/blake2.txt
TestVectors/blake2b.txt
TestVectors/blake2s.txt
TestVectors/aria.txt
TestVectors/camellia.txt
TestVectors/cham.txt
TestVectors/ccm.txt
TestVectors/chacha.txt
TestVectors/chacha_tls.txt
TestVectors/cham.txt
TestVectors/cmac.txt
TestVectors/dlies.txt
TestVectors/dsa.txt
TestVectors/dsa_rfc6979.txt
TestVectors/dsa_1363.txt
TestVectors/dsa_rfc6979.txt
TestVectors/eax.txt
TestVectors/esign.txt
TestVectors/gcm.txt
TestVectors/hc128.txt
TestVectors/hc256.txt
TestVectors/hkdf.txt
TestVectors/hight.txt
TestVectors/hkdf.txt
TestVectors/hmac.txt
TestVectors/kalyna.txt
TestVectors/keccak.txt
TestVectors/lea.txt
TestVectors/mars.txt
TestVectors/nr.txt
TestVectors/ocb.txt
TestVectors/panama.txt
TestVectors/rabbit.txt
TestVectors/Readme.txt
TestVectors/rsa_oaep.txt
TestVectors/rsa_pkcs1_1_5.txt
TestVectors/rsa_pss.txt
Expand All @@ -505,20 +514,20 @@ TestVectors/salsa.txt
TestVectors/seal.txt
TestVectors/seed.txt
TestVectors/sha.txt
TestVectors/sha2.txt
TestVectors/sha3.txt
TestVectors/sha1_fips_180.txt
TestVectors/sha1_160_fips_180.txt
TestVectors/sha2_fips_180.txt
TestVectors/sha1_fips_180.txt
TestVectors/sha2.txt
TestVectors/sha2_224_fips_180.txt
TestVectors/sha2_256_fips_180.txt
TestVectors/sha2_384_fips_180.txt
TestVectors/sha2_512_fips_180.txt
TestVectors/sha3_fips_202.txt
TestVectors/sha2_fips_180.txt
TestVectors/sha3.txt
TestVectors/sha3_224_fips_202.txt
TestVectors/sha3_256_fips_202.txt
TestVectors/sha3_384_fips_202.txt
TestVectors/sha3_512_fips_202.txt
TestVectors/sha3_fips_202.txt
TestVectors/shacal2.txt
TestVectors/simeck.txt
TestVectors/simon.txt
Expand All @@ -541,9 +550,9 @@ TestPrograms/test_arm_asimd.cxx
TestPrograms/test_arm_crc.cxx
TestPrograms/test_arm_neon.cxx
TestPrograms/test_arm_pmull.cxx
TestPrograms/test_arm_sha.cxx
TestPrograms/test_arm_sha3.cxx
TestPrograms/test_arm_sha512.cxx
TestPrograms/test_arm_sha.cxx
TestPrograms/test_arm_sm3.cxx
TestPrograms/test_arm_sm4.cxx
TestPrograms/test_cxx.cxx
Expand All @@ -558,9 +567,9 @@ TestPrograms/test_ppc_sha.cxx
TestPrograms/test_ppc_vmull.cxx
TestPrograms/test_pthreads.cxx
TestPrograms/test_x86_aes.cxx
TestPrograms/test_x86_avx.cxx
TestPrograms/test_x86_avx2.cxx
TestPrograms/test_x86_avx512.cxx
TestPrograms/test_x86_avx.cxx
TestPrograms/test_x86_clmul.cxx
TestPrograms/test_x86_cpuid.cxx
TestPrograms/test_x86_sha.cxx
Expand Down
1 change: 1 addition & 0 deletions TestData/ed25519.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
302E020100300506032B65700422042098C59D3F097FB23D44BA90791281B453258D691A55AF5CE4F1EE712FDF91AE6D
1 change: 1 addition & 0 deletions TestData/ed25519v0.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
302E020100300506032B65700422042030BF776A497D7F1E0E26AC4FB03F5BE7E187DDFEFB914CD292A6FEDB7F70CE6B
1 change: 1 addition & 0 deletions TestData/ed25519v1.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3053020101300506032B6570042204206861FD53C7643DABDCDF4C3969CE44A156BAC261242A5AAEC140EDE510071C6CA12303210029CF90E6C1CF1ADC7105720303B2EE303412D2B682C6FEEF3D8736A286B2E27F
2 changes: 1 addition & 1 deletion TestData/x25519.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3045032100D06927B313A78535F70AE1EC299D0FE86CDF0A655FC3EC7685BDA8E8D2F67174042097DD7D94CF3A33BB8374FD50C2663DD5F35F6CDFB8D7F01A8B22508DEA59195B
302E020100300506032B656E0422042030D407BB0CC97D0EC493BDB00A4A8EFA06A50D2388F5BA62947030E7D9873F49
1 change: 1 addition & 0 deletions TestData/x25519v0.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
302E020100300506032B656E042204202818E54DE6B88EEF3E99E25042CB98E69373B222E4C1E8B3FB10AC9B26C1007B
1 change: 1 addition & 0 deletions TestData/x25519v1.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3053020101300506032B656E04220420A00FADD6D29BE764B851F64F7620E80B700DF65914BED31E486362281BB5D061A123032100E9AD4CC54DAA36F312D98B253854F0076E2BC26FCE5802B3AC79A5B59B3D2C4F
6 changes: 5 additions & 1 deletion asn.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ class CRYPTOPP_DLL OID
/// </pre>
void BERDecodeAndCheck(BufferedTransformation &bt) const;

bool Empty() const {
return m_values.empty();
}

const std::vector<word32>& GetValues() const {
return m_values;
}
Expand Down Expand Up @@ -413,7 +417,7 @@ class CRYPTOPP_DLL X509PublicKey : public ASN1CryptoMaterial<PublicKey>
virtual void DEREncodePublicKey(BufferedTransformation &bt) const =0;
};

/// \brief Encodes and decodesprivateKeyInfo
/// \brief Encodes and Decodes privateKeyInfo
class CRYPTOPP_DLL PKCS8PrivateKey : public ASN1CryptoMaterial<PrivateKey>
{
public:
Expand Down
19 changes: 14 additions & 5 deletions bench3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
#include "ec2n.h"
#include "asn.h"
#include "dh.h"
#include "xed25519.h"
#include "mqv.h"
#include "hmqv.h"
#include "fhmqv.h"
#include "xed25519.h"
#include "xtrcrypt.h"
#include "esign.h"
#include "pssr.h"
Expand Down Expand Up @@ -380,6 +380,18 @@ void Benchmark3(double t, double hertz)
}

std::cout << "\n<TBODY style=\"background: yellow;\">";
{
ed25519::Signer sign(Test::GlobalRNG());
ed25519::Verifier verify(sign);
x25519 agree(Test::GlobalRNG());

BenchMarkSigning("ed25519", sign, t);
BenchMarkVerification("ed25519", sign, verify, t);
BenchMarkKeyGen("x25519", agree, t);
BenchMarkAgreement("x25519", agree, t);
}

std::cout << "\n<TBODY style=\"background: white;\">";
{
ECIES<ECP>::Decryptor cpriv(Test::GlobalRNG(), ASN1::secp256k1());
ECIES<ECP>::Encryptor cpub(cpriv);
Expand All @@ -391,7 +403,6 @@ void Benchmark3(double t, double hertz)
ECGDSA<ECP, SHA1>::Verifier spub3(spriv3);
ECDH<ECP>::Domain ecdhc(ASN1::secp256k1());
ECMQV<ECP>::Domain ecmqvc(ASN1::secp256k1());
x25519 x25519ka(Test::GlobalRNG());

BenchMarkEncryption("ECIES over GF(p) 256", cpub, t);
BenchMarkDecryption("ECIES over GF(p) 256", cpriv, cpub, t);
Expand All @@ -401,15 +412,13 @@ void Benchmark3(double t, double hertz)
BenchMarkVerification("ECDSA-RFC6979 over GF(p) 256", spriv2, spub2, t);
BenchMarkSigning("ECGDSA over GF(p) 256", spriv3, t);
BenchMarkVerification("ECGDSA over GF(p) 256", spriv3, spub3, t);
BenchMarkKeyGen("x25519", x25519ka, t);
BenchMarkAgreement("x25519", x25519ka, t);
BenchMarkKeyGen("ECDHC over GF(p) 256", ecdhc, t);
BenchMarkAgreement("ECDHC over GF(p) 256", ecdhc, t);
BenchMarkKeyGen("ECMQVC over GF(p) 256", ecmqvc, t);
BenchMarkAgreement("ECMQVC over GF(p) 256", ecmqvc, t);
}

std::cout << "\n<TBODY style=\"background: white;\">";
std::cout << "\n<TBODY style=\"background: yellow;\">";
{
ECIES<EC2N>::Decryptor cpriv(Test::GlobalRNG(), ASN1::sect233r1());
ECIES<EC2N>::Encryptor cpub(cpriv);
Expand Down
1 change: 1 addition & 0 deletions cryptest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@
<None Include="TestData\dsa1024.dat" />
<None Include="TestData\dsa1024b.dat" />
<None Include="TestData\dsa512.dat" />
<None Include="TestData\ed25519.dat" />
<None Include="TestData\elgc1024.dat" />
<None Include="TestData\esig1023.dat" />
<None Include="TestData\esig1536.dat" />
Expand Down
5 changes: 4 additions & 1 deletion cryptest.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@
<None Include="TestData\dsa512.dat">
<Filter>TestData</Filter>
</None>
<None Include="TestData\ed25519.dat">
<Filter>TestData</Filter>
</None>
<None Include="TestData\elgc1024.dat">
<Filter>TestData</Filter>
</None>
Expand Down Expand Up @@ -518,4 +521,4 @@
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>
3 changes: 3 additions & 0 deletions cryptlib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@
<ClInclude Include="dmac.h" />
<ClInclude Include="drbg.h" />
<ClInclude Include="donna.h" />
<ClInclude Include="donna_32.h" />
<ClInclude Include="donna_64.h" />
<ClInclude Include="donna_sse.h" />
<ClInclude Include="dsa.h" />
<ClInclude Include="eax.h" />
<ClInclude Include="ec2n.h" />
Expand Down
9 changes: 9 additions & 0 deletions cryptlib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,15 @@
<ClInclude Include="donna.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="donna_32.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="donna_64.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="donna_sse.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="eax.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
Loading

0 comments on commit d62674b

Please sign in to comment.