diff options
author | Jack Lloyd <[email protected]> | 2020-11-03 08:13:09 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2020-11-03 13:59:29 -0500 |
commit | f560e43c6b5efa951c17075a3c55775bcd76ea17 (patch) | |
tree | 340993aeadd403530f9fbe8f2b3161c92c8fe49b /src/lib/base | |
parent | 0ee1130583efbc6c98869347d0f8dabe59004aa7 (diff) |
More header merging
Diffstat (limited to 'src/lib/base')
-rw-r--r-- | src/lib/base/key_spec.h | 90 | ||||
-rw-r--r-- | src/lib/base/sym_algo.h | 84 |
2 files changed, 85 insertions, 89 deletions
diff --git a/src/lib/base/key_spec.h b/src/lib/base/key_spec.h index 6db20a9b6..85dcebe37 100644 --- a/src/lib/base/key_spec.h +++ b/src/lib/base/key_spec.h @@ -8,93 +8,7 @@ #ifndef BOTAN_KEY_LEN_SPECIFICATION_H_ #define BOTAN_KEY_LEN_SPECIFICATION_H_ -#include <botan/types.h> - -namespace Botan { - -/** -* Represents the length requirements on an algorithm key -*/ -class BOTAN_PUBLIC_API(2,0) Key_Length_Specification final - { - public: - /** - * Constructor for fixed length keys - * @param keylen the supported key length - */ - explicit Key_Length_Specification(size_t keylen) : - m_min_keylen(keylen), - m_max_keylen(keylen), - m_keylen_mod(1) - { - } - - /** - * Constructor for variable length keys - * @param min_k the smallest supported key length - * @param max_k the largest supported key length - * @param k_mod the number of bytes the key must be a multiple of - */ - Key_Length_Specification(size_t min_k, - size_t max_k, - size_t k_mod = 1) : - m_min_keylen(min_k), - m_max_keylen(max_k ? max_k : min_k), - m_keylen_mod(k_mod) - { - } - - /** - * @param length is a key length in bytes - * @return true iff this length is a valid length for this algo - */ - bool valid_keylength(size_t length) const - { - return ((length >= m_min_keylen) && - (length <= m_max_keylen) && - (length % m_keylen_mod == 0)); - } - - /** - * @return minimum key length in bytes - */ - size_t minimum_keylength() const - { - return m_min_keylen; - } - - /** - * @return maximum key length in bytes - */ - size_t maximum_keylength() const - { - return m_max_keylen; - } - - /** - * @return key length multiple in bytes - */ - size_t keylength_multiple() const - { - return m_keylen_mod; - } - - /* - * Multiplies all length requirements with the given factor - * @param n the multiplication factor - * @return a key length specification multiplied by the factor - */ - Key_Length_Specification multiple(size_t n) const - { - return Key_Length_Specification(n * m_min_keylen, - n * m_max_keylen, - n * m_keylen_mod); - } - - private: - size_t m_min_keylen, m_max_keylen, m_keylen_mod; - }; - -} +#include <botan/sym_algo.h> +BOTAN_DEPRECATED_HEADER(key_spec.h) #endif diff --git a/src/lib/base/sym_algo.h b/src/lib/base/sym_algo.h index 7d82a5740..41d999292 100644 --- a/src/lib/base/sym_algo.h +++ b/src/lib/base/sym_algo.h @@ -8,13 +8,95 @@ #ifndef BOTAN_SYMMETRIC_ALGORITHM_H_ #define BOTAN_SYMMETRIC_ALGORITHM_H_ -#include <botan/key_spec.h> #include <botan/symkey.h> #include <botan/types.h> namespace Botan { /** +* Represents the length requirements on an algorithm key +*/ +class BOTAN_PUBLIC_API(2,0) Key_Length_Specification final + { + public: + /** + * Constructor for fixed length keys + * @param keylen the supported key length + */ + explicit Key_Length_Specification(size_t keylen) : + m_min_keylen(keylen), + m_max_keylen(keylen), + m_keylen_mod(1) + { + } + + /** + * Constructor for variable length keys + * @param min_k the smallest supported key length + * @param max_k the largest supported key length + * @param k_mod the number of bytes the key must be a multiple of + */ + Key_Length_Specification(size_t min_k, + size_t max_k, + size_t k_mod = 1) : + m_min_keylen(min_k), + m_max_keylen(max_k ? max_k : min_k), + m_keylen_mod(k_mod) + { + } + + /** + * @param length is a key length in bytes + * @return true iff this length is a valid length for this algo + */ + bool valid_keylength(size_t length) const + { + return ((length >= m_min_keylen) && + (length <= m_max_keylen) && + (length % m_keylen_mod == 0)); + } + + /** + * @return minimum key length in bytes + */ + size_t minimum_keylength() const + { + return m_min_keylen; + } + + /** + * @return maximum key length in bytes + */ + size_t maximum_keylength() const + { + return m_max_keylen; + } + + /** + * @return key length multiple in bytes + */ + size_t keylength_multiple() const + { + return m_keylen_mod; + } + + /* + * Multiplies all length requirements with the given factor + * @param n the multiplication factor + * @return a key length specification multiplied by the factor + */ + Key_Length_Specification multiple(size_t n) const + { + return Key_Length_Specification(n * m_min_keylen, + n * m_max_keylen, + n * m_keylen_mod); + } + + private: + size_t m_min_keylen, m_max_keylen, m_keylen_mod; + }; + +/** * This class represents a symmetric algorithm object. */ class BOTAN_PUBLIC_API(2,0) SymmetricAlgorithm |