summaryrefslogtreecommitdiff
path: root/validat9.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2022-08-06 11:38:39 -0400
committerJeffrey Walton <noloader@gmail.com>2022-08-06 11:38:39 -0400
commit437346340b1a1e5bbd9b6d7c6023f07021172728 (patch)
tree99faabd6a84c7f99c1a6e34a1a81770902ac4b1d /validat9.cpp
parentd01ab643e9e0d2521fe954d988cecb1d442437aa (diff)
downloadcryptopp-git-437346340b1a1e5bbd9b6d7c6023f07021172728.tar.gz
Work around ECGDSA crash with GCC 12 (GH #1134)
Diffstat (limited to 'validat9.cpp')
-rw-r--r--validat9.cpp224
1 files changed, 120 insertions, 104 deletions
diff --git a/validat9.cpp b/validat9.cpp
index 735afe51..818148be 100644
--- a/validat9.cpp
+++ b/validat9.cpp
@@ -326,34 +326,32 @@ bool ValidateECDSA_RFC6979()
}
// from http://www.teletrust.de/fileadmin/files/oid/ecgdsa_final.pdf
-bool ValidateECGDSA(bool thorough)
+// ValidateECGDSA split into standard and thorough due to GH #1134
+bool ValidateECGDSAStandard()
{
- std::cout << "\nECGDSA validation suite running...\n\n";
-
bool fail, pass=true;
- // 2.4.1 Examples of ECGDSA over GF(p) with the hash function RIPEMD-160 (p. 10)
- if (thorough)
+ // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-1 (p. 19)
{
const OID oid = ASN1::brainpoolP192r1();
DL_GroupParameters_EC<ECP> params(oid);
Integer x("0x 80F2425E 89B4F585 F27F3536 ED834D68 E3E492DE 08FE84B9");
- ECGDSA<ECP, RIPEMD160>::Signer signer(params, x);
- ECGDSA<ECP, RIPEMD160>::Verifier verifier(signer);
+ ECGDSA<ECP, SHA1>::Signer signer(params, x);
+ ECGDSA<ECP, SHA1>::Verifier verifier(signer);
- Integer e("0x 00000000 577EF842 B32FDE45 79727FFF 02F7A280 74ADC4EF");
+ Integer e("0x 00000000 CF00CD42 CAA80DDF 8DDEBDFD 32F2DA15 11B53F29");
Integer k("0x 22C17C2A 367DD85A B8A365ED 06F19C43 F9ED1834 9A9BC044");
Integer r, s;
signer.RawSign(k, e, r, s);
Integer rExp("0x 2D017BE7 F117FF99 4ED6FC63 CA5B4C7A 0430E9FA 095DAFC4");
- Integer sExp("0x C02B5CC5 C51D5411 060BF024 5049F824 839F671D 78A1BBF1");
+ Integer sExp("0x 18FD604E 5F00F55B 3585C052 8C319A2B 05B8F2DD EE9CF1A6");
fail = (r != rExp) || (s != sExp);
pass = pass && !fail;
- const byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160";
+ const byte msg[] = "Example of ECGDSA with the hash function SHA-1";
const size_t len = strlen((char*)msg);
byte signature[48];
@@ -364,72 +362,70 @@ bool ValidateECGDSA(bool thorough)
pass = pass && !fail;
std::cout << (fail ? "FAILED " : "passed ");
- std::cout << "brainpoolP192r1 using RIPEMD-160\n";
+ std::cout << "brainpoolP192r1 using SHA-1\n";
fail = !SignatureValidate(signer, verifier);
pass = pass && !fail;
}
- // 2.4.1 Examples of ECGDSA over GF(p) with the hash function RIPEMD-160 (p. 13)
- if (thorough)
+ // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-224 (p. 23)
{
- const OID oid = ASN1::brainpoolP256r1();
+ const OID oid = ASN1::brainpoolP320r1();
DL_GroupParameters_EC<ECP> params(oid);
- Integer x("0x 47B3A278 62DEF037 49ACF0D6 00E69F9B 851D01ED AEFA531F 4D168E78 7307F4D8");
- ECGDSA<ECP, RIPEMD160>::Signer signer(params, x);
- ECGDSA<ECP, RIPEMD160>::Verifier verifier(signer);
+ Integer x("0x 48683594 5A3A284F FC52629A D48D8F37 F4B2E993 9C52BC72 362A9961 40192AEF 7D2AAFF0 C73A51C5");
+ ECGDSA<ECP, SHA224>::Signer signer(params, x);
+ ECGDSA<ECP, SHA224>::Verifier verifier(signer);
- Integer e("0x 00000000 00000000 00000000 577EF842 B32FDE45 79727FFF 02F7A280 74ADC4EF");
- Integer k("0x 908E3099 776261A4 558FF7A9 FA6DFFE0 CA6BB3F9 CB35C2E4 E1DC73FD 5E8C08A3");
+ Integer e("0x 00000000 00000000 00000000 92AE8A0E 8D08EADE E9426378 714FF3E0 1957587D 2876FA70 D40E3144");
+ Integer k("0x C70BC00A 77AD7872 5D36CEEC 27D6F956 FB546EEF 6DC90E35 31452BD8 7ECE8A4A 7AD730AD C299D81B");
Integer r, s;
signer.RawSign(k, e, r, s);
- Integer rExp("0x 62CCD1D2 91E62F6A 4FFBD966 C66C85AA BA990BB6 AB0C087D BD54A456 CCC84E4C");
- Integer sExp("0x 9119719B 08EEA0D6 BC56E4D1 D37369BC F3768445 EF65CAE4 A37BF6D4 3BD01646");
+ Integer rExp("0x 3C925969 FAB22F7A E7B8CC5D 50CB0867 DFDB2CF4 FADA3D49 0DF75D72 F7563186 419494C9 8F9C82A6");
+ Integer sExp("0x 6EA191CA 0D468AC3 E9568768 9338357C 7D0BACB3 F1D87E0D EC05F635 B7ADB842 75AA0086 60F812CF");
fail = (r != rExp) || (s != sExp);
pass = pass && !fail;
- const byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160";
+ const byte msg[] = "Example of ECGDSA with the hash function SHA-224";
const size_t len = strlen((char*)msg);
- byte signature[64];
- r.Encode(signature+0, 32);
- s.Encode(signature+32, 32);
+ byte signature[80];
+ r.Encode(signature+0, 40);
+ s.Encode(signature+40, 40);
fail = !verifier.VerifyMessage(msg, len, signature, sizeof(signature));
pass = pass && !fail;
std::cout << (fail ? "FAILED " : "passed ");
- std::cout << "brainpoolP256r1 using RIPEMD-160\n";
+ std::cout << "brainpoolP320r1 using SHA-224\n";
fail = !SignatureValidate(signer, verifier);
pass = pass && !fail;
}
- // 2.4.1 Examples of ECGDSA over GF(p) with the hash function RIPEMD-160 (p. 16)
- if (thorough)
+ // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-256 (p. 27)
{
const OID oid = ASN1::brainpoolP320r1();
DL_GroupParameters_EC<ECP> params(oid);
Integer x("0x 48683594 5A3A284F FC52629A D48D8F37 F4B2E993 9C52BC72 362A9961 40192AEF 7D2AAFF0 C73A51C5");
- ECGDSA<ECP, RIPEMD160>::Signer signer(params, x);
- ECGDSA<ECP, RIPEMD160>::Verifier verifier(signer);
+ ECGDSA<ECP, SHA256>::Signer signer(params, x);
+ ECGDSA<ECP, SHA256>::Verifier verifier(signer);
- Integer e("0x 00000000 00000000 00000000 00000000 00000000 577EF842 B32FDE45 79727FFF 02F7A280 74ADC4EF");
+ Integer e("0x 00000000 00000000 37ED8AA9 4AE667DB BB753330 E050EB8E 12195807 ECDC4FB1 0E0662B4 22C219D7");
Integer k("0x C70BC00A 77AD7872 5D36CEEC 27D6F956 FB546EEF 6DC90E35 31452BD8 7ECE8A4A 7AD730AD C299D81B");
Integer r, s;
signer.RawSign(k, e, r, s);
Integer rExp("0x 3C925969 FAB22F7A E7B8CC5D 50CB0867 DFDB2CF4 FADA3D49 0DF75D72 F7563186 419494C9 8F9C82A6");
- Integer sExp("0x 06AB5250 B31A8E93 56194894 61733200 E4FD5C12 75C0AB37 E7E41149 5BAAE145 41DF6DE6 66B8CA56");
+ Integer sExp("0x 24370797 A9D11717 BBBB2B76 2E08ECD0 7DD7E033 F544E47C BF3C6D16 FD90B51D CC2E4DD8 E6ECD8CD");
fail = (r != rExp) || (s != sExp);
pass = pass && !fail;
- const byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160";
+ const byte msg[] = "Example of ECGDSA with the hash function SHA-256";
const size_t len = strlen((char*)msg);
byte signature[80];
@@ -440,192 +436,201 @@ bool ValidateECGDSA(bool thorough)
pass = pass && !fail;
std::cout << (fail ? "FAILED " : "passed ");
- std::cout << "brainpoolP320r1 using RIPEMD-160\n";
+ std::cout << "brainpoolP320r1 using SHA-256\n";
fail = !SignatureValidate(signer, verifier);
pass = pass && !fail;
}
- // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-1 (p. 19)
+ // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-384 (p. 34)
{
- const OID oid = ASN1::brainpoolP192r1();
+ const OID oid = ASN1::brainpoolP512r1();
DL_GroupParameters_EC<ECP> params(oid);
- Integer x("0x 80F2425E 89B4F585 F27F3536 ED834D68 E3E492DE 08FE84B9");
- ECGDSA<ECP, SHA1>::Signer signer(params, x);
- ECGDSA<ECP, SHA1>::Verifier verifier(signer);
+ Integer x("0x 92006A98 8AF96D91 57AADCF8 62716962 7CE2ECC4 C58ECE5C 1A0A8642 11AB764C 04236FA0 160857A7 8E71CCAE 4D79D52E 5A69A457 8AF50658 1F598FA9 B4F7DA68");
+ ECGDSA<ECP, SHA384>::Signer signer(params, x);
+ ECGDSA<ECP, SHA384>::Verifier verifier(signer);
- Integer e("0x 00000000 CF00CD42 CAA80DDF 8DDEBDFD 32F2DA15 11B53F29");
- Integer k("0x 22C17C2A 367DD85A B8A365ED 06F19C43 F9ED1834 9A9BC044");
+ Integer e("0x 00000000 00000000 00000000 00000000 68FEAB7D 8BF8A779 4466E447 5959946B 2136C084 A86090CA 8070C980 68B1250D 88213190 6B7E0CB8 475F9054 E9290C2E");
+ Integer k("0x 6942B01D 5901BEC1 506BB874 9618E22E C0FCD7F3 5159D51E D53BA77A 78752128 A58232AD 8E0E021A FDE1477F F4C74FDF FE88AE2D 15D89B56 F6D73C03 77631D2B");
Integer r, s;
signer.RawSign(k, e, r, s);
- Integer rExp("0x 2D017BE7 F117FF99 4ED6FC63 CA5B4C7A 0430E9FA 095DAFC4");
- Integer sExp("0x 18FD604E 5F00F55B 3585C052 8C319A2B 05B8F2DD EE9CF1A6");
+ Integer rExp("0x 0104918B 2B32B1A5 49BD43C3 0092953B 4164CA01 A1A97B5B 0756EA06 3AC16B41 B88A1BAB 4538CD7D 8466180B 3E3F5C86 46AC4A45 F564E9B6 8FEE72ED 00C7AC48");
+ Integer sExp("0x 3D233E9F D9EB152E 889F4F7C F325B464 0894E5EA 44C51443 54305CD4 BF70D234 8257C2DB E06C5544 92CE9FDD 6861A565 77B53E5E E80E6062 31A4CF06 8FA1EC21");
fail = (r != rExp) || (s != sExp);
pass = pass && !fail;
- const byte msg[] = "Example of ECGDSA with the hash function SHA-1";
+ const byte msg[] = "Example of ECGDSA with the hash function SHA-384";
const size_t len = strlen((char*)msg);
- byte signature[48];
- r.Encode(signature+0, 24);
- s.Encode(signature+24, 24);
+ byte signature[128];
+ r.Encode(signature+0, 64);
+ s.Encode(signature+64, 64);
fail = !verifier.VerifyMessage(msg, len, signature, sizeof(signature));
pass = pass && !fail;
std::cout << (fail ? "FAILED " : "passed ");
- std::cout << "brainpoolP192r1 using SHA-1\n";
+ std::cout << "brainpoolP512r1 using SHA-384\n";
fail = !SignatureValidate(signer, verifier);
pass = pass && !fail;
}
- // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-224 (p. 23)
+ // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-512 (p. 38)
{
- const OID oid = ASN1::brainpoolP320r1();
+ const OID oid = ASN1::brainpoolP512r1();
DL_GroupParameters_EC<ECP> params(oid);
- Integer x("0x 48683594 5A3A284F FC52629A D48D8F37 F4B2E993 9C52BC72 362A9961 40192AEF 7D2AAFF0 C73A51C5");
- ECGDSA<ECP, SHA224>::Signer signer(params, x);
- ECGDSA<ECP, SHA224>::Verifier verifier(signer);
+ Integer x("0x 92006A98 8AF96D91 57AADCF8 62716962 7CE2ECC4 C58ECE5C 1A0A8642 11AB764C 04236FA0 160857A7 8E71CCAE 4D79D52E 5A69A457 8AF50658 1F598FA9 B4F7DA68");
+ ECGDSA<ECP, SHA512>::Signer signer(params, x);
+ ECGDSA<ECP, SHA512>::Verifier verifier(signer);
- Integer e("0x 00000000 00000000 00000000 92AE8A0E 8D08EADE E9426378 714FF3E0 1957587D 2876FA70 D40E3144");
- Integer k("0x C70BC00A 77AD7872 5D36CEEC 27D6F956 FB546EEF 6DC90E35 31452BD8 7ECE8A4A 7AD730AD C299D81B");
+ Integer e("0x 1A95EF81 D213BD3B 8191E7FE 7F5BFD43 F51E3EE5 A4FD3D08 4A7C9BB5 411F4649 746AEBC6 623D4DEA 7E02DC5A 85E24AF2 96B5A555 AD470413 71E4BF64 380F3E34");
+ Integer k("0x 6942B01D 5901BEC1 506BB874 9618E22E C0FCD7F3 5159D51E D53BA77A 78752128 A58232AD 8E0E021A FDE1477F F4C74FDF FE88AE2D 15D89B56 F6D73C03 77631D2B");
Integer r, s;
signer.RawSign(k, e, r, s);
- Integer rExp("0x 3C925969 FAB22F7A E7B8CC5D 50CB0867 DFDB2CF4 FADA3D49 0DF75D72 F7563186 419494C9 8F9C82A6");
- Integer sExp("0x 6EA191CA 0D468AC3 E9568768 9338357C 7D0BACB3 F1D87E0D EC05F635 B7ADB842 75AA0086 60F812CF");
+ Integer rExp("0x 0104918B 2B32B1A5 49BD43C3 0092953B 4164CA01 A1A97B5B 0756EA06 3AC16B41 B88A1BAB 4538CD7D 8466180B 3E3F5C86 46AC4A45 F564E9B6 8FEE72ED 00C7AC48");
+ Integer sExp("0x 17A011F8 DD7B5665 2B27AA6D 6E7BDF3C 7C23B5FA 32910FBA A107E627 0E1CA8A7 A263F661 8E6098A0 D6CD6BA1 C03544C5 425875EC B3418AF5 A3EE3F32 143E48D2");
fail = (r != rExp) || (s != sExp);
pass = pass && !fail;
- const byte msg[] = "Example of ECGDSA with the hash function SHA-224";
+ const byte msg[] = "Example of ECGDSA with the hash function SHA-512";
const size_t len = strlen((char*)msg);
- byte signature[80];
- r.Encode(signature+0, 40);
- s.Encode(signature+40, 40);
+ byte signature[128];
+ r.Encode(signature+0, 64);
+ s.Encode(signature+64, 64);
fail = !verifier.VerifyMessage(msg, len, signature, sizeof(signature));
pass = pass && !fail;
std::cout << (fail ? "FAILED " : "passed ");
- std::cout << "brainpoolP320r1 using SHA-224\n";
+ std::cout << "brainpoolP512r1 using SHA-512\n";
fail = !SignatureValidate(signer, verifier);
pass = pass && !fail;
}
- // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-256 (p. 27)
+ return pass;
+}
+
+// from http://www.teletrust.de/fileadmin/files/oid/ecgdsa_final.pdf
+// ValidateECGDSA split into standard and thorough due to GH #1134
+bool ValidateECGDSAThorough()
+{
+ bool fail, pass=true;
+
+ // 2.4.1 Examples of ECGDSA over GF(p) with the hash function RIPEMD-160 (p. 10)
{
- const OID oid = ASN1::brainpoolP320r1();
+ const OID oid = ASN1::brainpoolP192r1();
DL_GroupParameters_EC<ECP> params(oid);
- Integer x("0x 48683594 5A3A284F FC52629A D48D8F37 F4B2E993 9C52BC72 362A9961 40192AEF 7D2AAFF0 C73A51C5");
- ECGDSA<ECP, SHA256>::Signer signer(params, x);
- ECGDSA<ECP, SHA256>::Verifier verifier(signer);
+ Integer x("0x 80F2425E 89B4F585 F27F3536 ED834D68 E3E492DE 08FE84B9");
+ ECGDSA<ECP, RIPEMD160>::Signer signer(params, x);
+ ECGDSA<ECP, RIPEMD160>::Verifier verifier(signer);
- Integer e("0x 00000000 00000000 37ED8AA9 4AE667DB BB753330 E050EB8E 12195807 ECDC4FB1 0E0662B4 22C219D7");
- Integer k("0x C70BC00A 77AD7872 5D36CEEC 27D6F956 FB546EEF 6DC90E35 31452BD8 7ECE8A4A 7AD730AD C299D81B");
+ Integer e("0x 00000000 577EF842 B32FDE45 79727FFF 02F7A280 74ADC4EF");
+ Integer k("0x 22C17C2A 367DD85A B8A365ED 06F19C43 F9ED1834 9A9BC044");
Integer r, s;
signer.RawSign(k, e, r, s);
- Integer rExp("0x 3C925969 FAB22F7A E7B8CC5D 50CB0867 DFDB2CF4 FADA3D49 0DF75D72 F7563186 419494C9 8F9C82A6");
- Integer sExp("0x 24370797 A9D11717 BBBB2B76 2E08ECD0 7DD7E033 F544E47C BF3C6D16 FD90B51D CC2E4DD8 E6ECD8CD");
+ Integer rExp("0x 2D017BE7 F117FF99 4ED6FC63 CA5B4C7A 0430E9FA 095DAFC4");
+ Integer sExp("0x C02B5CC5 C51D5411 060BF024 5049F824 839F671D 78A1BBF1");
fail = (r != rExp) || (s != sExp);
pass = pass && !fail;
- const byte msg[] = "Example of ECGDSA with the hash function SHA-256";
+ const byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160";
const size_t len = strlen((char*)msg);
- byte signature[80];
- r.Encode(signature+0, 40);
- s.Encode(signature+40, 40);
+ byte signature[48];
+ r.Encode(signature+0, 24);
+ s.Encode(signature+24, 24);
fail = !verifier.VerifyMessage(msg, len, signature, sizeof(signature));
pass = pass && !fail;
std::cout << (fail ? "FAILED " : "passed ");
- std::cout << "brainpoolP320r1 using SHA-256\n";
+ std::cout << "brainpoolP192r1 using RIPEMD-160\n";
fail = !SignatureValidate(signer, verifier);
pass = pass && !fail;
}
- // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-384 (p. 34)
+ // 2.4.1 Examples of ECGDSA over GF(p) with the hash function RIPEMD-160 (p. 13)
{
- const OID oid = ASN1::brainpoolP512r1();
+ const OID oid = ASN1::brainpoolP256r1();
DL_GroupParameters_EC<ECP> params(oid);
- Integer x("0x 92006A98 8AF96D91 57AADCF8 62716962 7CE2ECC4 C58ECE5C 1A0A8642 11AB764C 04236FA0 160857A7 8E71CCAE 4D79D52E 5A69A457 8AF50658 1F598FA9 B4F7DA68");
- ECGDSA<ECP, SHA384>::Signer signer(params, x);
- ECGDSA<ECP, SHA384>::Verifier verifier(signer);
+ Integer x("0x 47B3A278 62DEF037 49ACF0D6 00E69F9B 851D01ED AEFA531F 4D168E78 7307F4D8");
+ ECGDSA<ECP, RIPEMD160>::Signer signer(params, x);
+ ECGDSA<ECP, RIPEMD160>::Verifier verifier(signer);
- Integer e("0x 00000000 00000000 00000000 00000000 68FEAB7D 8BF8A779 4466E447 5959946B 2136C084 A86090CA 8070C980 68B1250D 88213190 6B7E0CB8 475F9054 E9290C2E");
- Integer k("0x 6942B01D 5901BEC1 506BB874 9618E22E C0FCD7F3 5159D51E D53BA77A 78752128 A58232AD 8E0E021A FDE1477F F4C74FDF FE88AE2D 15D89B56 F6D73C03 77631D2B");
+ Integer e("0x 00000000 00000000 00000000 577EF842 B32FDE45 79727FFF 02F7A280 74ADC4EF");
+ Integer k("0x 908E3099 776261A4 558FF7A9 FA6DFFE0 CA6BB3F9 CB35C2E4 E1DC73FD 5E8C08A3");
Integer r, s;
signer.RawSign(k, e, r, s);
- Integer rExp("0x 0104918B 2B32B1A5 49BD43C3 0092953B 4164CA01 A1A97B5B 0756EA06 3AC16B41 B88A1BAB 4538CD7D 8466180B 3E3F5C86 46AC4A45 F564E9B6 8FEE72ED 00C7AC48");
- Integer sExp("0x 3D233E9F D9EB152E 889F4F7C F325B464 0894E5EA 44C51443 54305CD4 BF70D234 8257C2DB E06C5544 92CE9FDD 6861A565 77B53E5E E80E6062 31A4CF06 8FA1EC21");
+ Integer rExp("0x 62CCD1D2 91E62F6A 4FFBD966 C66C85AA BA990BB6 AB0C087D BD54A456 CCC84E4C");
+ Integer sExp("0x 9119719B 08EEA0D6 BC56E4D1 D37369BC F3768445 EF65CAE4 A37BF6D4 3BD01646");
fail = (r != rExp) || (s != sExp);
pass = pass && !fail;
- const byte msg[] = "Example of ECGDSA with the hash function SHA-384";
+ const byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160";
const size_t len = strlen((char*)msg);
- byte signature[128];
- r.Encode(signature+0, 64);
- s.Encode(signature+64, 64);
+ byte signature[64];
+ r.Encode(signature+0, 32);
+ s.Encode(signature+32, 32);
fail = !verifier.VerifyMessage(msg, len, signature, sizeof(signature));
pass = pass && !fail;
std::cout << (fail ? "FAILED " : "passed ");
- std::cout << "brainpoolP512r1 using SHA-384\n";
+ std::cout << "brainpoolP256r1 using RIPEMD-160\n";
fail = !SignatureValidate(signer, verifier);
pass = pass && !fail;
}
- // 2.4.1 Examples of ECGDSA over GF(p) with the hash function SHA-512 (p. 38)
+ // 2.4.1 Examples of ECGDSA over GF(p) with the hash function RIPEMD-160 (p. 16)
{
- const OID oid = ASN1::brainpoolP512r1();
+ const OID oid = ASN1::brainpoolP320r1();
DL_GroupParameters_EC<ECP> params(oid);
- Integer x("0x 92006A98 8AF96D91 57AADCF8 62716962 7CE2ECC4 C58ECE5C 1A0A8642 11AB764C 04236FA0 160857A7 8E71CCAE 4D79D52E 5A69A457 8AF50658 1F598FA9 B4F7DA68");
- ECGDSA<ECP, SHA512>::Signer signer(params, x);
- ECGDSA<ECP, SHA512>::Verifier verifier(signer);
+ Integer x("0x 48683594 5A3A284F FC52629A D48D8F37 F4B2E993 9C52BC72 362A9961 40192AEF 7D2AAFF0 C73A51C5");
+ ECGDSA<ECP, RIPEMD160>::Signer signer(params, x);
+ ECGDSA<ECP, RIPEMD160>::Verifier verifier(signer);
- Integer e("0x 1A95EF81 D213BD3B 8191E7FE 7F5BFD43 F51E3EE5 A4FD3D08 4A7C9BB5 411F4649 746AEBC6 623D4DEA 7E02DC5A 85E24AF2 96B5A555 AD470413 71E4BF64 380F3E34");
- Integer k("0x 6942B01D 5901BEC1 506BB874 9618E22E C0FCD7F3 5159D51E D53BA77A 78752128 A58232AD 8E0E021A FDE1477F F4C74FDF FE88AE2D 15D89B56 F6D73C03 77631D2B");
+ Integer e("0x 00000000 00000000 00000000 00000000 00000000 577EF842 B32FDE45 79727FFF 02F7A280 74ADC4EF");
+ Integer k("0x C70BC00A 77AD7872 5D36CEEC 27D6F956 FB546EEF 6DC90E35 31452BD8 7ECE8A4A 7AD730AD C299D81B");
Integer r, s;
signer.RawSign(k, e, r, s);
- Integer rExp("0x 0104918B 2B32B1A5 49BD43C3 0092953B 4164CA01 A1A97B5B 0756EA06 3AC16B41 B88A1BAB 4538CD7D 8466180B 3E3F5C86 46AC4A45 F564E9B6 8FEE72ED 00C7AC48");
- Integer sExp("0x 17A011F8 DD7B5665 2B27AA6D 6E7BDF3C 7C23B5FA 32910FBA A107E627 0E1CA8A7 A263F661 8E6098A0 D6CD6BA1 C03544C5 425875EC B3418AF5 A3EE3F32 143E48D2");
+ Integer rExp("0x 3C925969 FAB22F7A E7B8CC5D 50CB0867 DFDB2CF4 FADA3D49 0DF75D72 F7563186 419494C9 8F9C82A6");
+ Integer sExp("0x 06AB5250 B31A8E93 56194894 61733200 E4FD5C12 75C0AB37 E7E41149 5BAAE145 41DF6DE6 66B8CA56");
fail = (r != rExp) || (s != sExp);
pass = pass && !fail;
- const byte msg[] = "Example of ECGDSA with the hash function SHA-512";
+ const byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160";
const size_t len = strlen((char*)msg);
- byte signature[128];
- r.Encode(signature+0, 64);
- s.Encode(signature+64, 64);
+ byte signature[80];
+ r.Encode(signature+0, 40);
+ s.Encode(signature+40, 40);
fail = !verifier.VerifyMessage(msg, len, signature, sizeof(signature));
pass = pass && !fail;
std::cout << (fail ? "FAILED " : "passed ");
- std::cout << "brainpoolP512r1 using SHA-512\n";
+ std::cout << "brainpoolP320r1 using RIPEMD-160\n";
fail = !SignatureValidate(signer, verifier);
pass = pass && !fail;
@@ -634,6 +639,17 @@ bool ValidateECGDSA(bool thorough)
return pass;
}
+// ValidateECGDSA split into standard and thorough due to GH #1134
+bool ValidateECGDSA(bool thorough)
+{
+ std::cout << "\nECGDSA validation suite running...\n\n";
+
+ if(thorough)
+ return ValidateECGDSAStandard() && ValidateECGDSAThorough();
+ else
+ return ValidateECGDSAStandard();
+}
+
bool ValidateESIGN()
{
std::cout << "\nESIGN validation suite running...\n\n";