1 /** 2 * XMSS WOTS Addressed Public Key 3 * (C) 2016,2017 Matthias Gierlings 4 * 5 * Botan is released under the Simplified BSD License (see license.txt) 6 **/ 7 8 9 #ifndef BOTAN_XMSS_WOTS_ADDRESSED_PUBLICKEY_H_ 10 #define BOTAN_XMSS_WOTS_ADDRESSED_PUBLICKEY_H_ 11 12 #include <botan/internal/xmss_address.h> 13 #include <botan/xmss_wots.h> 14 15 namespace Botan { 16 17 /** 18 * Wrapper class to pair a XMSS_WOTS_PublicKey with an XMSS Address. Since 19 * the PK_Ops::Verification interface does not allow an extra address 20 * parameter to be passed to the sign(RandomNumberGenerator&), the address 21 * needs to be stored together with the key and passed to the 22 * XMSS_WOTS_Verification_Operation() on creation. 23 **/ 24 class XMSS_WOTS_Addressed_PublicKey : public virtual Public_Key 25 { 26 public: XMSS_WOTS_Addressed_PublicKey(const XMSS_WOTS_PublicKey & public_key)27 XMSS_WOTS_Addressed_PublicKey(const XMSS_WOTS_PublicKey& public_key) 28 : m_pub_key(public_key), m_adrs() {} 29 XMSS_WOTS_Addressed_PublicKey(const XMSS_WOTS_PublicKey & public_key,const XMSS_Address & adrs)30 XMSS_WOTS_Addressed_PublicKey(const XMSS_WOTS_PublicKey& public_key, 31 const XMSS_Address& adrs) 32 : m_pub_key(public_key), m_adrs(adrs) {} 33 XMSS_WOTS_Addressed_PublicKey(XMSS_WOTS_PublicKey && public_key)34 XMSS_WOTS_Addressed_PublicKey(XMSS_WOTS_PublicKey&& public_key) 35 : m_pub_key(std::move(public_key)), m_adrs() {} 36 XMSS_WOTS_Addressed_PublicKey(XMSS_WOTS_PublicKey && public_key,XMSS_Address && adrs)37 XMSS_WOTS_Addressed_PublicKey(XMSS_WOTS_PublicKey&& public_key, 38 XMSS_Address&& adrs) 39 : m_pub_key(std::move(public_key)), m_adrs(std::move(adrs)) {} 40 public_key()41 const XMSS_WOTS_PublicKey& public_key() const { return m_pub_key; } public_key()42 XMSS_WOTS_PublicKey& public_key() { return m_pub_key; } 43 address()44 const XMSS_Address& address() const { return m_adrs; } address()45 XMSS_Address& address() { return m_adrs; } 46 algo_name()47 std::string algo_name() const override 48 { 49 return m_pub_key.algo_name(); 50 } 51 algorithm_identifier()52 AlgorithmIdentifier algorithm_identifier() const override 53 { 54 return m_pub_key.algorithm_identifier(); 55 } 56 check_key(RandomNumberGenerator & rng,bool strong)57 bool check_key(RandomNumberGenerator& rng, bool strong) const override 58 { 59 return m_pub_key.check_key(rng, strong); 60 } 61 62 std::unique_ptr<PK_Ops::Verification> create_verification_op(const std::string & params,const std::string & provider)63 create_verification_op(const std::string& params, 64 const std::string& provider) const override 65 { 66 return m_pub_key.create_verification_op(params, provider); 67 } 68 get_oid()69 OID get_oid() const override 70 { 71 return m_pub_key.get_oid(); 72 } 73 estimated_strength()74 size_t estimated_strength() const override 75 { 76 return m_pub_key.estimated_strength(); 77 } 78 key_length()79 size_t key_length() const override 80 { 81 return m_pub_key.estimated_strength(); 82 } 83 public_key_bits()84 std::vector<uint8_t> public_key_bits() const override 85 { 86 return m_pub_key.public_key_bits(); 87 } 88 89 protected: 90 XMSS_WOTS_PublicKey m_pub_key; 91 XMSS_Address m_adrs; 92 }; 93 94 } 95 96 #endif 97