diff options
author | Jack Lloyd <[email protected]> | 2018-03-10 09:46:52 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-03-10 10:27:12 -0500 |
commit | ea0f46dfcab59938fc863ca8d01552392c3c5a34 (patch) | |
tree | 8b4ccb48cf3a660bd5b315f0fc81090a78b7153e /src/lib | |
parent | 30de6dc7179ca21e3cbca55b48b23bcac0f45f25 (diff) |
Default to encoding ECC public keys as uncompressed. GH #1480
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/pubkey/ecc_key/ecc_key.cpp | 13 | ||||
-rw-r--r-- | src/lib/pubkey/ecc_key/ecc_key.h | 14 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/lib/pubkey/ecc_key/ecc_key.cpp b/src/lib/pubkey/ecc_key/ecc_key.cpp index 4b591ff56..07122964e 100644 --- a/src/lib/pubkey/ecc_key/ecc_key.cpp +++ b/src/lib/pubkey/ecc_key/ecc_key.cpp @@ -68,7 +68,18 @@ AlgorithmIdentifier EC_PublicKey::algorithm_identifier() const std::vector<uint8_t> EC_PublicKey::public_key_bits() const { - return unlock(EC2OSP(public_point(), PointGFp::COMPRESSED)); + //return public_point().encode(point_format()); + return unlock(EC2OSP(public_point(), point_format())); + } + +void EC_PublicKey::set_point_encoding(PointGFp::Compression_Type enc) + { + if(enc != PointGFp::COMPRESSED && + enc != PointGFp::UNCOMPRESSED && + enc != PointGFp::HYBRID) + throw Invalid_Argument("Invalid point encoding for EC_PublicKey"); + + m_point_encoding = enc; } void EC_PublicKey::set_parameter_encoding(EC_Group_Encoding form) diff --git a/src/lib/pubkey/ecc_key/ecc_key.h b/src/lib/pubkey/ecc_key/ecc_key.h index 427be56ef..4e4e623b2 100644 --- a/src/lib/pubkey/ecc_key/ecc_key.h +++ b/src/lib/pubkey/ecc_key/ecc_key.h @@ -78,6 +78,12 @@ class BOTAN_PUBLIC_API(2,0) EC_PublicKey : public virtual Public_Key void set_parameter_encoding(EC_Group_Encoding enc); /** + * Set the point encoding method to be used when encoding this key. + * @param enc the encoding to use + */ + void set_point_encoding(PointGFp::Compression_Type enc); + + /** * Return the DER encoding of this keys domain in whatever format * is preset for this particular key */ @@ -91,6 +97,13 @@ class BOTAN_PUBLIC_API(2,0) EC_PublicKey : public virtual Public_Key EC_Group_Encoding domain_format() const { return m_domain_encoding; } + /** + * Get the point encoding method to be used when encoding this key. + * @result the encoding to use + */ + PointGFp::Compression_Type point_format() const + { return m_point_encoding; } + size_t key_length() const override; size_t estimated_strength() const override; @@ -101,6 +114,7 @@ class BOTAN_PUBLIC_API(2,0) EC_PublicKey : public virtual Public_Key EC_Group m_domain_params; PointGFp m_public_key; EC_Group_Encoding m_domain_encoding; + PointGFp::Compression_Type m_point_encoding = PointGFp::UNCOMPRESSED; }; /** |