diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/pubkey/xmss/xmss_index_registry.h | 7 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_tools.cpp | 32 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_tools.h | 3 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h | 14 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_privatekey.h | 28 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_publickey.h | 23 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp | 6 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_signature_operation.h | 12 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp | 10 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_verification_operation.h | 17 |
10 files changed, 32 insertions, 120 deletions
diff --git a/src/lib/pubkey/xmss/xmss_index_registry.h b/src/lib/pubkey/xmss/xmss_index_registry.h index 3e5aaa794..8759ca03b 100644 --- a/src/lib/pubkey/xmss/xmss_index_registry.h +++ b/src/lib/pubkey/xmss/xmss_index_registry.h @@ -12,19 +12,12 @@ #include <cstddef> #include <limits> #include <memory> -<<<<<<< HEAD -======= -#include <mutex> ->>>>>>> 959425d... Added Extended Hash-Based Signatures (XMSS) #include <string> #include <botan/hash.h> #include <botan/secmem.h> #include <botan/types.h> #include <botan/atomic.h> -<<<<<<< HEAD #include <botan/mutex.h> -======= ->>>>>>> 959425d... Added Extended Hash-Based Signatures (XMSS) namespace Botan { diff --git a/src/lib/pubkey/xmss/xmss_tools.cpp b/src/lib/pubkey/xmss/xmss_tools.cpp deleted file mode 100644 index 13e66759c..000000000 --- a/src/lib/pubkey/xmss/xmss_tools.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/** - * XMSS Tools - * Contains some helper functions. - * (C) 2016 Matthias Gierlings - * - * Botan is released under the Simplified BSD License (see license.txt) - **/ -#include <botan/xmss_tools.h> - -namespace Botan { - -XMSS_Tools::XMSS_Tools() - { -#if defined(BOTAN_TARGET_CPU_HAS_KNOWN_ENDIANESS) -#if defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN) - m_is_little_endian = true; -#else - m_is_little_endian = false; -#endif -#else - uint16_t data = 0x01; - m_is_little_endian = reinterpret_cast<const byte*>(&data)[0] == 0x01; -#endif - } - -const XMSS_Tools& XMSS_Tools::get() - { - static const XMSS_Tools self; - return self; - } - -} diff --git a/src/lib/pubkey/xmss/xmss_tools.h b/src/lib/pubkey/xmss/xmss_tools.h index ab60665c7..a62f17ebf 100644 --- a/src/lib/pubkey/xmss/xmss_tools.h +++ b/src/lib/pubkey/xmss/xmss_tools.h @@ -11,10 +11,7 @@ #include <stdint.h> #include <iterator> #include <type_traits> -<<<<<<< HEAD #include <botan/cpuid.h> -======= ->>>>>>> 959425d... Added Extended Hash-Based Signatures (XMSS) #include <botan/types.h> #include <botan/secmem.h> diff --git a/src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h b/src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h index 52165684f..a07b0b803 100644 --- a/src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h +++ b/src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h @@ -77,19 +77,9 @@ class XMSS_WOTS_Addressed_PublicKey : public virtual Public_Key return m_pub_key.estimated_strength(); } - virtual size_t max_input_bits() const override + virtual size_t key_length() const override { - return m_pub_key.max_input_bits(); - } - - virtual size_t message_part_size() const override - { - return m_pub_key.message_part_size(); - } - - virtual size_t message_parts() const override - { - return m_pub_key.message_parts(); + return m_pub_key.estimated_strength(); } virtual std::vector<byte> x509_subject_public_key() const override diff --git a/src/lib/pubkey/xmss/xmss_wots_privatekey.h b/src/lib/pubkey/xmss/xmss_wots_privatekey.h index 312db8b7b..179a4b51b 100644 --- a/src/lib/pubkey/xmss/xmss_wots_privatekey.h +++ b/src/lib/pubkey/xmss/xmss_wots_privatekey.h @@ -12,6 +12,7 @@ #include <memory> #include <botan/alg_id.h> #include <botan/assert.h> +#include <botan/exceptn.h> #include <botan/pk_keys.h> #include <botan/types.h> #include <botan/xmss_wots_parameters.h> @@ -150,8 +151,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey, * * @return A XMSS_WOTS_PublicKey. **/ - XMSS_WOTS_PublicKey generate_public_key( - XMSS_Address& adrs); + XMSS_WOTS_PublicKey generate_public_key(XMSS_Address& adrs); /** * Algorithm 4: "WOTS_genPK" @@ -165,10 +165,9 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey, * @param adrs Hash function address encoding the address of * the WOTS+ key pair within a greater structure. **/ - void generate_public_key( - XMSS_WOTS_PublicKey& pub_key, - wots_keysig_t&& in_key_data, - XMSS_Address& adrs); + void generate_public_key(XMSS_WOTS_PublicKey& pub_key, + wots_keysig_t&& in_key_data, + XMSS_Address& adrs); /** * Algorithm 5: "WOTS_sign" @@ -180,9 +179,8 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey, * * @return signature for msg. **/ - wots_keysig_t sign( - const secure_vector<byte>& msg, - XMSS_Address& adrs); + wots_keysig_t sign(const secure_vector<byte>& msg, + XMSS_Address& adrs); /** * Retrieves the secret seed used to generate WOTS+ chains. The seed @@ -195,14 +193,6 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey, return m_private_seed; } - ///** - // * Retrieves the secret seed used to generate WOTS+ chains. The seed - // * should be a uniformly random n-byte value. - // * - // * @return secret seed. - // **/ - //secure_vector<byte>& private_seed() { return m_private_seed; } - /** * Sets the secret seed used to generate WOTS+ chains. The seed * should be a uniformly random n-byte value. @@ -228,7 +218,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey, virtual AlgorithmIdentifier pkcs8_algorithm_identifier() const override { - BOTAN_ASSERT(false, "No AlgorithmIdentifier available for XMSS-WOTS."); + throw Not_Implemented("No AlgorithmIdentifier available for XMSS-WOTS."); } virtual std::unique_ptr<PK_Ops::Signature> @@ -238,7 +228,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey, virtual secure_vector<byte> pkcs8_private_key() const override { - BOTAN_ASSERT(false, "No PKCS8 key format defined for XMSS-WOTS."); + throw Not_Implemented("No PKCS8 key format defined for XMSS-WOTS."); } private: diff --git a/src/lib/pubkey/xmss/xmss_wots_publickey.h b/src/lib/pubkey/xmss/xmss_wots_publickey.h index 9efb04667..626d55225 100644 --- a/src/lib/pubkey/xmss/xmss_wots_publickey.h +++ b/src/lib/pubkey/xmss/xmss_wots_publickey.h @@ -15,6 +15,7 @@ #include <botan/alg_id.h> #include <botan/asn1_oid.h> #include <botan/assert.h> +#include <botan/exceptn.h> #include <botan/pk_keys.h> #include <botan/types.h> #include <botan/xmss_wots_parameters.h> @@ -200,22 +201,28 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key operator wots_keysig_t& () { return m_key; } const secure_vector<byte>& public_seed() const { return m_public_seed; } + secure_vector<byte>& public_seed() { return m_public_seed; } + void set_public_seed(const secure_vector<byte>& public_seed) { m_public_seed = public_seed; } + void set_public_seed(secure_vector<byte>&& public_seed) { m_public_seed = std::move(public_seed); } const wots_keysig_t& key_data() const { return m_key; } + wots_keysig_t& key_data() { return m_key; } + void set_key_data(const wots_keysig_t& key_data) { m_key = key_data; } + void set_key_data(wots_keysig_t&& key_data) { m_key = std::move(key_data); @@ -233,12 +240,12 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key virtual AlgorithmIdentifier algorithm_identifier() const override { - BOTAN_ASSERT(false, "No AlgorithmIdentifier available for XMSS-WOTS."); + throw Not_Implemented("No AlgorithmIdentifier available for XMSS-WOTS."); } virtual bool check_key(RandomNumberGenerator&, bool) const override { - BOTAN_ASSERT(false, "No key strength check implemented for XMSS-WOTS."); + return true; } virtual std::unique_ptr<PK_Ops::Verification> @@ -255,19 +262,9 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key return m_wots_params.estimated_strength(); } - virtual size_t message_part_size() const override - { - return m_wots_params.element_size(); - } - - virtual size_t message_parts() const override - { - return 1; - } - virtual std::vector<byte> x509_subject_public_key() const override { - BOTAN_ASSERT(false, "No x509 key format defined for XMSS-WOTS."); + throw Not_Implemented("No x509 key format defined for XMSS-WOTS."); } bool operator==(const XMSS_WOTS_PublicKey& key) diff --git a/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp b/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp index 82f32b88e..532e4d782 100644 --- a/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp +++ b/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp @@ -21,13 +21,15 @@ XMSS_WOTS_Signature_Operation::XMSS_WOTS_Signature_Operation( m_priv_key(private_key), m_msg_buf(0) { - m_msg_buf.reserve(m_priv_key.message_part_size()); + m_msg_buf.reserve( + m_priv_key.private_key().wots_parameters().element_size()); } void XMSS_WOTS_Signature_Operation::update(const byte msg[], size_t msg_len) { - BOTAN_ASSERT(msg_len == message_part_size() && + BOTAN_ASSERT(msg_len == m_priv_key.private_key().wots_parameters(). + element_size() && m_msg_buf.size() == 0, "XMSS WOTS only supports one message part of size n."); diff --git a/src/lib/pubkey/xmss/xmss_wots_signature_operation.h b/src/lib/pubkey/xmss/xmss_wots_signature_operation.h index 2b469e200..69ba6b4fe 100644 --- a/src/lib/pubkey/xmss/xmss_wots_signature_operation.h +++ b/src/lib/pubkey/xmss/xmss_wots_signature_operation.h @@ -29,23 +29,11 @@ class XMSS_WOTS_Signature_Operation : public virtual PK_Ops::Signature, public XMSS_WOTS_Common_Ops { public: - typedef XMSS_WOTS_Addressed_PrivateKey Key_Type; - XMSS_WOTS_Signature_Operation( const XMSS_WOTS_Addressed_PrivateKey& private_key); virtual ~XMSS_WOTS_Signature_Operation() {} - virtual size_t message_part_size() const override - { - return m_priv_key.message_part_size(); - } - - virtual size_t message_parts() const override - { - return m_priv_key.message_parts(); - } - /** * Creates a XMSS WOTS signature for the message provided through call * to update(). XMSS wots only supports one message part and a fixed diff --git a/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp b/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp index 6bff05b93..d66c508bb 100644 --- a/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp +++ b/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp @@ -21,22 +21,26 @@ XMSS_WOTS_Verification_Operation::XMSS_WOTS_Verification_Operation( m_pub_key(public_key), m_msg_buf(0) { - m_msg_buf.reserve(m_pub_key.message_part_size()); + m_msg_buf.reserve(m_pub_key.public_key().wots_parameters(). + element_size()); } void XMSS_WOTS_Verification_Operation::update(const byte msg[], size_t msg_len) { - BOTAN_ASSERT(msg_len == message_part_size() && + BOTAN_ASSERT(msg_len == m_pub_key.public_key().wots_parameters(). + element_size() && m_msg_buf.size() == 0, "XMSS WOTS only supports one message part of size n."); for(size_t i = 0; i < msg_len; i++) + { m_msg_buf.push_back(msg[i]); + } } bool XMSS_WOTS_Verification_Operation::is_valid_signature(const byte sig[], - size_t sig_len) + size_t sig_len) { const XMSS_WOTS_Parameters& w = m_pub_key.public_key().wots_parameters(); diff --git a/src/lib/pubkey/xmss/xmss_wots_verification_operation.h b/src/lib/pubkey/xmss/xmss_wots_verification_operation.h index d4d961e80..1125a6af8 100644 --- a/src/lib/pubkey/xmss/xmss_wots_verification_operation.h +++ b/src/lib/pubkey/xmss/xmss_wots_verification_operation.h @@ -29,28 +29,11 @@ class XMSS_WOTS_Verification_Operation public XMSS_WOTS_Common_Ops { public: - typedef XMSS_WOTS_Addressed_PublicKey Key_Type; - XMSS_WOTS_Verification_Operation( const XMSS_WOTS_Addressed_PublicKey& public_key); virtual ~XMSS_WOTS_Verification_Operation() {} - virtual size_t max_input_bits() const override - { - return m_pub_key.max_input_bits(); - } - - virtual size_t message_part_size() const override - { - return m_pub_key.message_part_size(); - } - - virtual size_t message_parts() const override - { - return m_pub_key.message_parts(); - } - virtual bool is_valid_signature(const byte sig[], size_t sig_len) override; |