diff options
author | Jack Lloyd <[email protected]> | 2017-08-04 15:22:33 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-08-04 15:22:33 -0400 |
commit | 87fcd69b587ccd60c5f248b40003cf9a0a558a53 (patch) | |
tree | c558cab7be5e591a36d74c3f8948c018a1c89bb7 /src/lib/pubkey/sm2/sm2.cpp | |
parent | 58b1f7cc90b3e5c8a4bbff7adf2c001db0ef4d21 (diff) |
Add SM2 encryption scheme
This is a contribution from Ribose Inc (@riboseinc)
Diffstat (limited to 'src/lib/pubkey/sm2/sm2.cpp')
-rw-r--r-- | src/lib/pubkey/sm2/sm2.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/pubkey/sm2/sm2.cpp b/src/lib/pubkey/sm2/sm2.cpp index 5c5b50792..2882cb0ad 100644 --- a/src/lib/pubkey/sm2/sm2.cpp +++ b/src/lib/pubkey/sm2/sm2.cpp @@ -40,12 +40,10 @@ SM2_Signature_PrivateKey::SM2_Signature_PrivateKey(RandomNumberGenerator& rng, m_da_inv = inverse_mod(m_private_key + 1, domain.get_order()); } -namespace { - -std::vector<uint8_t> compute_za(HashFunction& hash, - const std::string& user_id, - const EC_Group& domain, - const PointGFp& pubkey) +std::vector<uint8_t> sm2_compute_za(HashFunction& hash, + const std::string& user_id, + const EC_Group& domain, + const PointGFp& pubkey) { if(user_id.size() >= 8192) throw Invalid_Argument("SM2 user id too long to represent"); @@ -71,6 +69,8 @@ std::vector<uint8_t> compute_za(HashFunction& hash, return za; } +namespace { + /** * SM2 signature operation */ @@ -88,7 +88,7 @@ class SM2_Signature_Operation : public PK_Ops::Signature m_hash(HashFunction::create_or_throw("SM3")) { // ZA=H256(ENTLA || IDA || a || b || xG || yG || xA || yA) - m_za = compute_za(*m_hash, ident, sm2.domain(), sm2.public_point()); + m_za = sm2_compute_za(*m_hash, ident, sm2.domain(), sm2.public_point()); m_hash->update(m_za); } @@ -142,7 +142,7 @@ class SM2_Verification_Operation : public PK_Ops::Verification m_hash(HashFunction::create_or_throw("SM3")) { // ZA=H256(ENTLA || IDA || a || b || xG || yG || xA || yA) - m_za = compute_za(*m_hash, ident, sm2.domain(), sm2.public_point()); + m_za = sm2_compute_za(*m_hash, ident, sm2.domain(), sm2.public_point()); m_hash->update(m_za); } |