diff options
author | Jack Lloyd <[email protected]> | 2017-12-27 14:24:59 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-12-27 14:24:59 -0500 |
commit | 67e4bce79ee991abdde7e9d3c01f8948bcbcc775 (patch) | |
tree | 3cbb3c657109aff688dfd0e8dcf0a4773d5ea884 /src/lib | |
parent | 02d6b74810a61dd63bc09ea5a6db5f528fcec120 (diff) | |
parent | 61d22f79bcef4c22f95e29b2fdd038c95443480a (diff) |
Merge GH #1374 Remove unneeded XMSS-WOTS operations
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/pubkey/xmss/info.txt | 3 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_common_ops.cpp | 41 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_common_ops.h | 83 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_privatekey.cpp | 13 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_privatekey.h | 5 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_publickey.cpp | 13 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_publickey.h | 4 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp | 54 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_signature_operation.h | 61 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp | 72 | ||||
-rw-r--r-- | src/lib/pubkey/xmss/xmss_wots_verification_operation.h | 48 |
11 files changed, 0 insertions, 397 deletions
diff --git a/src/lib/pubkey/xmss/info.txt b/src/lib/pubkey/xmss/info.txt index 4ecf5da31..154401af7 100644 --- a/src/lib/pubkey/xmss/info.txt +++ b/src/lib/pubkey/xmss/info.txt @@ -22,9 +22,6 @@ xmss_wots_publickey.h <header:internal> xmss_wots_addressed_privatekey.h xmss_wots_addressed_publickey.h -xmss_wots_common_ops.h -xmss_wots_signature_operation.h -xmss_wots_verification_operation.h xmss_signature.h xmss_signature_operation.h xmss_verification_operation.h diff --git a/src/lib/pubkey/xmss/xmss_wots_common_ops.cpp b/src/lib/pubkey/xmss/xmss_wots_common_ops.cpp deleted file mode 100644 index d147949c6..000000000 --- a/src/lib/pubkey/xmss/xmss_wots_common_ops.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/** - * XMSS WOTS Common Ops - * Operations shared by XMSS WOTS signature generation and verification - * operations. - * - * (C) 2016,2017 Matthias Gierlings - * - * Botan is released under the Simplified BSD License (see license.txt) - **/ - -#include <botan/internal/xmss_wots_common_ops.h> - -namespace Botan { - -void -XMSS_WOTS_Common_Ops::chain(secure_vector<uint8_t>& result, - size_t start_idx, - size_t steps, - XMSS_Address& adrs, - const secure_vector<uint8_t>& seed, - XMSS_Hash& hash) - { - for(size_t i = start_idx; - i < (start_idx + steps) && i < m_wots_params.wots_parameter(); - i++) - { - adrs.set_hash_address(i); - - //Calculate tmp XOR bitmask - adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Mask_Mode); - xor_buf(result, hash.prf(seed, adrs.bytes()), result.size()); - - // Calculate key - adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Key_Mode); - - //Calculate f(key, tmp XOR bitmask) - hash.f(result, hash.prf(seed, adrs.bytes()), result); - } - } - -} diff --git a/src/lib/pubkey/xmss/xmss_wots_common_ops.h b/src/lib/pubkey/xmss/xmss_wots_common_ops.h deleted file mode 100644 index 9e0b5991d..000000000 --- a/src/lib/pubkey/xmss/xmss_wots_common_ops.h +++ /dev/null @@ -1,83 +0,0 @@ -/** - * XMSS WOTS Common Operations - * (C) 2016,2017 Matthias Gierlings - * - * Botan is released under the Simplified BSD License (see license.txt) - **/ - -#ifndef BOTAN_XMSS_WOTS_COMMON_OPS_H_ -#define BOTAN_XMSS_WOTS_COMMON_OPS_H_ - -#include <cstddef> -#include <botan/types.h> -#include <botan/xmss_wots_parameters.h> -#include <botan/xmss_address.h> -#include <botan/xmss_hash.h> - -namespace Botan { - -/** - * Operations shared by XMSS WOTS signature generation and verification - * operations. - **/ -class XMSS_WOTS_Common_Ops - { - public: - XMSS_WOTS_Common_Ops(XMSS_WOTS_Parameters::ots_algorithm_t oid) - : m_wots_params(oid), m_hash(m_wots_params.hash_function_name()) {} - - - protected: - /** - * Algorithm 2: Chaining Function. - * - * @param[out] result Contains the n-byte input string "x" upon call to chain(), - * that will be replaced with the value obtained by iterating - * the cryptographic hash function "F" steps times on the - * input x using the outputs of the PRNG "G". - * @param[in] start_idx The start index. - * @param[in] steps A number of steps. - * @param[in] adrs An OTS Hash Address. - * @param[in] seed A Seed. - **/ - inline void chain(secure_vector<uint8_t>& result, - size_t start_idx, - size_t steps, - XMSS_Address& adrs, - const secure_vector<uint8_t>& seed) - { - chain(result, start_idx, steps, adrs, seed, m_hash); - } - - /** - * Algorithm 2: Chaining Function. - * - * This overload is used in multithreaded scenarios, where it is - * required to provide seperate instances of XMSS_Hash to each - * thread. - * - * @param[out] result Contains the n-byte input string "x" upon call to chain(), - * that will be replaced with the value obtained by iterating - * the cryptographic hash function "F" steps times on the - * input x using the outputs of the PRNG "G". - * @param[in] start_idx The start index. - * @param[in] steps A number of steps. - * @param[in] adrs An OTS Hash Address. - * @param[in] seed A Seed. - * @param[in] hash Instance of XMSS_Hash, that may only by the thead - * executing chain. - **/ - void chain(secure_vector<uint8_t>& result, - size_t start_idx, - size_t steps, - XMSS_Address& adrs, - const secure_vector<uint8_t>& seed, - XMSS_Hash& hash); - - XMSS_WOTS_Parameters m_wots_params; - XMSS_Hash m_hash; - }; - -} - -#endif diff --git a/src/lib/pubkey/xmss/xmss_wots_privatekey.cpp b/src/lib/pubkey/xmss/xmss_wots_privatekey.cpp index 8a1ac05ef..5b48d2d4d 100644 --- a/src/lib/pubkey/xmss/xmss_wots_privatekey.cpp +++ b/src/lib/pubkey/xmss/xmss_wots_privatekey.cpp @@ -8,7 +8,6 @@ * Botan is released under the Simplified BSD License (see license.txt) **/ -#include <botan/internal/xmss_wots_signature_operation.h> #include <botan/xmss_wots_privatekey.h> namespace Botan { @@ -80,16 +79,4 @@ XMSS_WOTS_PrivateKey::sign(const secure_vector<uint8_t>& msg, return sig; } -std::unique_ptr<PK_Ops::Signature> -XMSS_WOTS_PrivateKey::create_signature_op(RandomNumberGenerator&, - const std::string&, - const std::string& provider) const - { - if(provider == "base" || provider.empty()) - return std::unique_ptr<PK_Ops::Signature>( - new XMSS_WOTS_Signature_Operation(*this)); - - throw Provider_Not_Found(algo_name(), provider); - } - } diff --git a/src/lib/pubkey/xmss/xmss_wots_privatekey.h b/src/lib/pubkey/xmss/xmss_wots_privatekey.h index 24459def1..550bfb86b 100644 --- a/src/lib/pubkey/xmss/xmss_wots_privatekey.h +++ b/src/lib/pubkey/xmss/xmss_wots_privatekey.h @@ -298,11 +298,6 @@ class XMSS_WOTS_PrivateKey final : public virtual XMSS_WOTS_PublicKey, throw Not_Implemented("No AlgorithmIdentifier available for XMSS-WOTS."); } - std::unique_ptr<PK_Ops::Signature> - create_signature_op(RandomNumberGenerator&, - const std::string&, - const std::string& provider) const override; - secure_vector<uint8_t> private_key_bits() const override { throw Not_Implemented("No PKCS8 key format defined for XMSS-WOTS."); diff --git a/src/lib/pubkey/xmss/xmss_wots_publickey.cpp b/src/lib/pubkey/xmss/xmss_wots_publickey.cpp index 04b4c352b..c944d6b10 100644 --- a/src/lib/pubkey/xmss/xmss_wots_publickey.cpp +++ b/src/lib/pubkey/xmss/xmss_wots_publickey.cpp @@ -8,7 +8,6 @@ * Botan is released under the Simplified BSD License (see license.txt) **/ -#include <botan/internal/xmss_wots_verification_operation.h> #include <botan/xmss_wots_publickey.h> namespace Botan { @@ -65,16 +64,4 @@ XMSS_WOTS_PublicKey::pub_key_from_signature(const secure_vector<uint8_t>& msg, return result; } -std::unique_ptr<PK_Ops::Verification> -XMSS_WOTS_PublicKey::create_verification_op(const std::string&, - const std::string& provider) const - { - if(provider == "base" || provider.empty()) - { - return std::unique_ptr<PK_Ops::Verification>( - new XMSS_WOTS_Verification_Operation(*this)); - } - throw Provider_Not_Found(algo_name(), provider); - } - } diff --git a/src/lib/pubkey/xmss/xmss_wots_publickey.h b/src/lib/pubkey/xmss/xmss_wots_publickey.h index 97c7bd3e2..7052dfb7c 100644 --- a/src/lib/pubkey/xmss/xmss_wots_publickey.h +++ b/src/lib/pubkey/xmss/xmss_wots_publickey.h @@ -246,10 +246,6 @@ class XMSS_WOTS_PublicKey : virtual public Public_Key return true; } - std::unique_ptr<PK_Ops::Verification> - create_verification_op(const std::string&, - const std::string& provider) const override; - size_t estimated_strength() const override { return m_wots_params.estimated_strength(); diff --git a/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp b/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp deleted file mode 100644 index 54473b700..000000000 --- a/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/** - * XMSS WOTS Signature Operation - * Signature generation operation for Winternitz One Time Signatures for use - * in Extended Hash-Based Signatures (XMSS). - * - * This operation is not intended for stand-alone use and thus not registered - * in the Botan algorithm registry. - * - * (C) 2016,2017 Matthias Gierlings - * - * Botan is released under the Simplified BSD License (see license.txt) - **/ - -#include <botan/internal/xmss_wots_signature_operation.h> - -namespace Botan { - -XMSS_WOTS_Signature_Operation::XMSS_WOTS_Signature_Operation( - const XMSS_WOTS_Addressed_PrivateKey& private_key) - : XMSS_WOTS_Common_Ops(private_key.private_key().wots_parameters().oid()), - m_priv_key(private_key), - m_msg_buf(0) - { - m_msg_buf.reserve( - m_priv_key.private_key().wots_parameters().element_size()); - } - -void -XMSS_WOTS_Signature_Operation::update(const uint8_t msg[], size_t msg_len) - { - 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."); - - for(size_t i = 0; i < msg_len; i++) - { m_msg_buf.push_back(msg[i]); } - } - -secure_vector<uint8_t> -XMSS_WOTS_Signature_Operation::sign(RandomNumberGenerator&) - { - secure_vector<uint8_t> result(0); - result.reserve(m_wots_params.len() * m_wots_params.element_size()); - XMSS_WOTS_PrivateKey& priv_key = m_priv_key.private_key(); - for(const auto& node : priv_key.sign(m_msg_buf, m_priv_key.address())) - { - std::copy(node.begin(), node.end(), std::back_inserter(result)); - } - - return result; - } - -} diff --git a/src/lib/pubkey/xmss/xmss_wots_signature_operation.h b/src/lib/pubkey/xmss/xmss_wots_signature_operation.h deleted file mode 100644 index 6cfe4521b..000000000 --- a/src/lib/pubkey/xmss/xmss_wots_signature_operation.h +++ /dev/null @@ -1,61 +0,0 @@ -/** - * XMSS WOTS Signature Operation - * (C) 2016,2017 Matthias Gierlings - * - * Botan is released under the Simplified BSD License (see license.txt) - **/ - -#ifndef BOTAN_XMSS_WOTS_SIGNATURE_OPERATION_H_ -#define BOTAN_XMSS_WOTS_SIGNATURE_OPERATION_H_ - -#include <cstddef> -#include <iterator> -#include <botan/types.h> -#include <botan/pk_ops.h> -#include <botan/internal/xmss_wots_addressed_privatekey.h> -#include <botan/internal/xmss_wots_common_ops.h> - -namespace Botan { - -/** - * Signature generation operation for Winternitz One Time Signatures for use - * in Extended Hash-Based Signatures (XMSS). - * - * This operation is not intended for stand-alone use and thus not registered - * in the Botan algorithm registry. - ***/ -class XMSS_WOTS_Signature_Operation final : public virtual PK_Ops::Signature, - public XMSS_WOTS_Common_Ops - { - public: - XMSS_WOTS_Signature_Operation( - const XMSS_WOTS_Addressed_PrivateKey& private_key); - - virtual ~XMSS_WOTS_Signature_Operation() = default; - - /** - * Creates a XMSS WOTS signature for the message provided through call - * to update(). XMSS wots only supports one message part and a fixed - * message size of "n" bytes where "n" equals the element size of - * the chosen XMSS WOTS signature method. The random number generator - * argument is supplied for interface compatibility and remains unused. - * - * @return serialized Winternitz One Time Signature. - **/ - secure_vector<uint8_t> sign(RandomNumberGenerator&) override; - - void update(const uint8_t msg[], size_t msg_len) override; - - private: - wots_keysig_t sign(const secure_vector<uint8_t>& msg, - const wots_keysig_t& priv_key, - XMSS_Address& adrs, - const secure_vector<uint8_t>& seed); - XMSS_WOTS_Addressed_PrivateKey m_priv_key; - secure_vector<uint8_t> m_msg_buf; - }; - -} - -#endif - diff --git a/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp b/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp deleted file mode 100644 index 480fbdff7..000000000 --- a/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/** - * XMSS WOTS Verification Operation - * Provides signature verification capabilities for Winternitz One Time - * Signatures used in Extended Hash-Based Signatures (XMSS). - * - * This operation is not intended for stand-alone use and thus not registered - * in the Botan algorithm registry. - * - * (C) 2016,2017 Matthias Gierlings - * - * Botan is released under the Simplified BSD License (see license.txt) - **/ - -#include <botan/internal/xmss_wots_verification_operation.h> - -namespace Botan { - -XMSS_WOTS_Verification_Operation::XMSS_WOTS_Verification_Operation( - const XMSS_WOTS_Addressed_PublicKey& public_key) - : XMSS_WOTS_Common_Ops(public_key.public_key().wots_parameters().oid()), - m_pub_key(public_key), - m_msg_buf(0) - { - m_msg_buf.reserve(m_pub_key.public_key().wots_parameters(). - element_size()); - } - -void -XMSS_WOTS_Verification_Operation::update(const uint8_t msg[], size_t msg_len) - { - 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 uint8_t sig[], - size_t sig_len) - { - const XMSS_WOTS_Parameters& w = m_pub_key.public_key().wots_parameters(); - - BOTAN_ASSERT(sig_len == w.element_size() * w.len(), - "Invalid signature size."); - - wots_keysig_t signature(0); - signature.reserve(sig_len); - - size_t begin = 0; - size_t end = 0; - while(signature.size() < w.len()) - { - begin = end; - end = begin + w.element_size(); - signature.push_back(secure_vector<uint8_t>(sig + begin, sig + end)); - } - - XMSS_WOTS_PublicKey pubkey_msg(w.oid(), - m_msg_buf, - signature, - m_pub_key.address(), - m_pub_key.public_key().public_seed()); - - return pubkey_msg.key_data() == m_pub_key.public_key().key_data(); - } - -} - diff --git a/src/lib/pubkey/xmss/xmss_wots_verification_operation.h b/src/lib/pubkey/xmss/xmss_wots_verification_operation.h deleted file mode 100644 index 3dce165b0..000000000 --- a/src/lib/pubkey/xmss/xmss_wots_verification_operation.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * XMSS_WOTS_Verification_Operation.h - * (C) 2016,2017 Matthias Gierlings - * - * Botan is released under the Simplified BSD License (see license.txt) - **/ - -#ifndef BOTAN_XMSS_WOTS_VERIFICATION_OPERATION_H_ -#define BOTAN_XMSS_WOTS_VERIFICATION_OPERATION_H_ - -#include <cstddef> -#include <iterator> -#include <botan/types.h> -#include <botan/pk_ops.h> -#include <botan/internal/xmss_wots_addressed_publickey.h> -#include <botan/internal/xmss_wots_common_ops.h> - -namespace Botan { - -/** - * Provides signature verification capabilities for Winternitz One Time - * Signatures used in Extended Merkle Tree Signatures (XMSS). - * - * This operation is not intended for stand-alone use and thus not registered - * in the Botan algorithm registry. - **/ -class XMSS_WOTS_Verification_Operation - final : public virtual PK_Ops::Verification, - public XMSS_WOTS_Common_Ops - { - public: - XMSS_WOTS_Verification_Operation( - const XMSS_WOTS_Addressed_PublicKey& public_key); - - virtual ~XMSS_WOTS_Verification_Operation() = default; - - bool is_valid_signature(const uint8_t sig[], size_t sig_len) override; - - void update(const uint8_t msg[], size_t msg_len) override; - - private: - XMSS_WOTS_Addressed_PublicKey m_pub_key; - secure_vector<uint8_t> m_msg_buf; - }; - -} - -#endif |