diff options
author | Jack Lloyd <[email protected]> | 2018-03-10 10:24:25 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-03-10 10:27:12 -0500 |
commit | 9141f982c7679a27a265a84ba34d9695017883c9 (patch) | |
tree | 2853c6c86ab7ac70dde74692a82ec01c15bbbb20 /src/lib/prov | |
parent | ea0f46dfcab59938fc863ca8d01552392c3c5a34 (diff) |
Add PointGFp::encode as replacement for EC2OSP
Literally every single call to EC2OSP is converting the returned
secure_vector to a std::vector. Which makes sense since private
points are not really a thing in any protocol I know of.
Diffstat (limited to 'src/lib/prov')
-rw-r--r-- | src/lib/prov/bearssl/bearssl_ec.cpp | 4 | ||||
-rw-r--r-- | src/lib/prov/openssl/openssl_ec.cpp | 4 | ||||
-rw-r--r-- | src/lib/prov/pkcs11/p11_ecc_key.cpp | 2 | ||||
-rw-r--r-- | src/lib/prov/pkcs11/p11_ecdh.h | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/prov/bearssl/bearssl_ec.cpp b/src/lib/prov/bearssl/bearssl_ec.cpp index 29ff1b5ad..23f566043 100644 --- a/src/lib/prov/bearssl/bearssl_ec.cpp +++ b/src/lib/prov/bearssl/bearssl_ec.cpp @@ -92,7 +92,7 @@ class BearSSL_ECDSA_Verification_Operation final : public PK_Ops::Verification if (m_hf == nullptr) throw Lookup_Error("BearSSL ECDSA does not support hash " + req.arg(0)); - m_q_buf = EC2OSP(ecdsa.public_point(), PointGFp::UNCOMPRESSED); + m_q_buf = ecdsa.public_point().encode(PointGFp::UNCOMPRESSED); m_key.qlen = m_q_buf.size(); m_key.q = m_q_buf.data(); @@ -123,7 +123,7 @@ class BearSSL_ECDSA_Verification_Operation final : public PK_Ops::Verification private: br_ec_public_key m_key; std::unique_ptr<HashFunction> m_hf; - secure_vector<uint8_t> m_q_buf; + std::vector<uint8_t> m_q_buf; const br_hash_class *m_hash; size_t m_order_bits; }; diff --git a/src/lib/prov/openssl/openssl_ec.cpp b/src/lib/prov/openssl/openssl_ec.cpp index 90b5e2023..c61f83d02 100644 --- a/src/lib/prov/openssl/openssl_ec.cpp +++ b/src/lib/prov/openssl/openssl_ec.cpp @@ -56,7 +56,7 @@ secure_vector<uint8_t> PKCS8_for_openssl(const EC_PrivateKey& ec) .raw_bytes(ec.domain().DER_encode(EC_DOMPAR_ENC_OID)) .end_cons() .start_cons(ASN1_Tag(1), PRIVATE) - .encode(EC2OSP(pub_key, PointGFp::UNCOMPRESSED), BIT_STRING) + .encode(pub_key.encode(PointGFp::UNCOMPRESSED), BIT_STRING) .end_cons() .end_cons() .get_contents(); @@ -147,7 +147,7 @@ class OpenSSL_ECDSA_Verification_Operation final : public PK_Ops::Verification_w if(!::EC_KEY_set_group(m_ossl_ec.get(), grp.get())) throw OpenSSL_Error("EC_KEY_set_group"); - const secure_vector<uint8_t> enc = EC2OSP(ecdsa.public_point(), PointGFp::UNCOMPRESSED); + const std::vector<uint8_t> enc = ecdsa.public_point().encode(PointGFp::UNCOMPRESSED); const uint8_t* enc_ptr = enc.data(); EC_KEY* key_ptr = m_ossl_ec.get(); if(!::o2i_ECPublicKey(&key_ptr, &enc_ptr, enc.size())) diff --git a/src/lib/prov/pkcs11/p11_ecc_key.cpp b/src/lib/prov/pkcs11/p11_ecc_key.cpp index d5a9a2b76..2bcf41a2c 100644 --- a/src/lib/prov/pkcs11/p11_ecc_key.cpp +++ b/src/lib/prov/pkcs11/p11_ecc_key.cpp @@ -111,7 +111,7 @@ size_t PKCS11_EC_PrivateKey::key_length() const std::vector<uint8_t> PKCS11_EC_PrivateKey::public_key_bits() const { - return unlock(EC2OSP(public_point(), PointGFp::COMPRESSED)); + return public_point().encode(PointGFp::COMPRESSED); } size_t PKCS11_EC_PrivateKey::estimated_strength() const diff --git a/src/lib/prov/pkcs11/p11_ecdh.h b/src/lib/prov/pkcs11/p11_ecdh.h index 203e5ea5f..bbef9a3e5 100644 --- a/src/lib/prov/pkcs11/p11_ecdh.h +++ b/src/lib/prov/pkcs11/p11_ecdh.h @@ -95,7 +95,7 @@ class BOTAN_PUBLIC_API(2,0) PKCS11_ECDH_PrivateKey final : public virtual PKCS11 inline std::vector<uint8_t> public_value() const override { - return unlock(EC2OSP(public_point(), PointGFp::UNCOMPRESSED)); + return public_point().encode(PointGFp::UNCOMPRESSED); } /// @return the exported ECDH private key |