diff options
author | Jack Lloyd <[email protected]> | 2017-09-07 10:29:47 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-09-07 10:29:47 -0400 |
commit | 1a39eca36d5b2f41b3178fbb1a359e42d47b7a74 (patch) | |
tree | 66f5d3224b6070572753779b413c46d3400104cc /src/tests | |
parent | e3f0b9ed6843f44162f482c10b1f214d6e634104 (diff) | |
parent | 729ee64431748d898a2a53baa8f8e17f2925e16e (diff) |
Merge GH #1188 Support arbitrary hashes in SM2
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/data/pubkey/sm2_sig.vec | 1 | ||||
-rw-r--r-- | src/tests/test_ffi.cpp | 8 | ||||
-rw-r--r-- | src/tests/test_sm2.cpp | 10 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/tests/data/pubkey/sm2_sig.vec b/src/tests/data/pubkey/sm2_sig.vec index d3356cceb..8a86dfc7d 100644 --- a/src/tests/data/pubkey/sm2_sig.vec +++ b/src/tests/data/pubkey/sm2_sig.vec @@ -7,6 +7,7 @@ yG = 0x0680512BCBB42C07D47349D2153B70C4E5D7FDFCBFA36EA1A85841B9E46E09A2 Order = 0x8542D69E4C044F18E8B92435BF6FF7DD297720630485628D5AE74EE7C32E79B7 Cofactor = 1 +Hash = SM3 Ident = [email protected] Msg = 6D65737361676520646967657374 x = 0x128B2FA8BD433C6C068C8D803DFF79792A519A55171B1B650C23661D15897263 diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp index 41fa3a044..4a8e7b317 100644 --- a/src/tests/test_ffi.cpp +++ b/src/tests/test_ffi.cpp @@ -1408,6 +1408,10 @@ class FFI_Unit_Tests : public Test TEST_FFI_OK(botan_privkey_export_pubkey, (&pub, priv)); ffi_test_pubkey_export(result, pub, priv, rng); + uint8_t za[32]; + size_t sizeof_za = sizeof(za); + TEST_FFI_OK(botan_pubkey_sm2_compute_za, (za, &sizeof_za, "Ident", "SM3", pub)); + // Check key load functions botan_mp_t private_scalar, public_x, public_y; botan_mp_init(&private_scalar); @@ -1495,6 +1499,10 @@ class FFI_Unit_Tests : public Test TEST_FFI_OK(botan_privkey_export_pubkey, (&pub, priv)); ffi_test_pubkey_export(result, pub, priv, rng); + uint8_t za[32]; + size_t sizeof_za = sizeof(za); + TEST_FFI_OK(botan_pubkey_sm2_compute_za, (za, &sizeof_za, "Ident", "SM3", pub)); + // Check key load functions botan_mp_t private_scalar, public_x, public_y; botan_mp_init(&private_scalar); diff --git a/src/tests/test_sm2.cpp b/src/tests/test_sm2.cpp index 88d872435..0497ccedd 100644 --- a/src/tests/test_sm2.cpp +++ b/src/tests/test_sm2.cpp @@ -27,11 +27,11 @@ class SM2_Signature_KAT_Tests : public PK_Signature_Generation_Test "SM2", "pubkey/sm2_sig.vec", "P,A,B,xG,yG,Order,Cofactor,Ident,Msg,x,Nonce,Signature", - "") {} + "Hash") {} virtual std::string default_padding(const VarMap& vars) const override { - return get_req_str(vars, "Ident"); + return get_req_str(vars, "Ident") + "," + get_opt_str(vars, "Hash", "SM3"); } Botan::RandomNumberGenerator* test_rng(const std::vector<uint8_t>& nonce) const override @@ -71,11 +71,11 @@ class SM2_Encryption_KAT_Tests : public PK_Encryption_Decryption_Test "SM2", "pubkey/sm2_enc.vec", "P,A,B,xG,yG,Order,Cofactor,Msg,x,Nonce,Ciphertext", - "") {} + "Hash") {} - virtual std::string default_padding(const VarMap&) const override + virtual std::string default_padding(const VarMap& vars) const override { - return ""; + return get_opt_str(vars, "Hash", "SM3"); } Botan::RandomNumberGenerator* test_rng(const std::vector<uint8_t>& nonce) const override |