test-gost-sig.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #include <cassert>
  2. #include <inttypes.h>
  3. #include <string.h>
  4. #include "Gost.h"
  5. #include "Signature.h"
  6. const uint8_t example2[72] =
  7. {
  8. 0xfb,0xe2,0xe5,0xf0,0xee,0xe3,0xc8,0x20,0xfb,0xea,0xfa,0xeb,0xef,0x20,0xff,0xfb,
  9. 0xf0,0xe1,0xe0,0xf0,0xf5,0x20,0xe0,0xed,0x20,0xe8,0xec,0xe0,0xeb,0xe5,0xf0,0xf2,
  10. 0xf1,0x20,0xff,0xf0,0xee,0xec,0x20,0xf1,0x20,0xfa,0xf2,0xfe,0xe5,0xe2,0x20,0x2c,
  11. 0xe8,0xf6,0xf3,0xed,0xe2,0x20,0xe8,0xe6,0xee,0xe1,0xe8,0xf0,0xf2,0xd1,0x20,0x2c,
  12. 0xe8,0xf0,0xf2,0xe5,0xe2,0x20,0xe5,0xd1
  13. };
  14. int main ()
  15. {
  16. uint8_t priv[64], pub[128], signature[128];
  17. i2p::crypto::CreateGOSTR3410RandomKeys (i2p::crypto::eGOSTR3410TC26A512, priv, pub);
  18. i2p::crypto::GOSTR3410_512_Signer signer (i2p::crypto::eGOSTR3410TC26A512, priv);
  19. signer.Sign (example2, 72, signature);
  20. i2p::crypto::GOSTR3410_512_Verifier verifier (i2p::crypto::eGOSTR3410TC26A512);
  21. verifier.SetPublicKey (pub);
  22. assert (verifier.Verify (example2, 72, signature));
  23. i2p::crypto::CreateGOSTR3410RandomKeys (i2p::crypto::eGOSTR3410CryptoProA, priv, pub);
  24. i2p::crypto::GOSTR3410_256_Signer signer1 (i2p::crypto::eGOSTR3410CryptoProA, priv);
  25. signer1.Sign (example2, 72, signature);
  26. i2p::crypto::GOSTR3410_256_Verifier verifier1 (i2p::crypto::eGOSTR3410CryptoProA);
  27. verifier1.SetPublicKey (pub);
  28. assert (verifier1.Verify (example2, 72, signature));
  29. }