diff --git a/doc/dev_ref/oids.rst b/doc/dev_ref/oids.rst index f8ea9446a8e..11a774ef4d2 100644 --- a/doc/dev_ref/oids.rst +++ b/doc/dev_ref/oids.rst @@ -66,6 +66,8 @@ Values currently assigned are:: SphincsPlus-haraka-256s-r3.1 OBJECT IDENTIFIER ::= { SphincsPlus-haraka 5 } SphincsPlus-haraka-256f-r3.1 OBJECT IDENTIFIER ::= { SphincsPlus-haraka 6 } + HSS-LMS-Private-Key OBJECT IDENTIFIER ::= { publicKey 13 } + symmetricKey OBJECT IDENTIFIER ::= { randombit 3 } ocbModes OBJECT IDENTIFIER ::= { symmetricKey 2 } diff --git a/src/lib/pubkey/hss_lms/hss_lms_utils.h b/src/lib/pubkey/hss_lms/hss_lms_utils.h index d4469320a83..e89d3d9e090 100644 --- a/src/lib/pubkey/hss_lms/hss_lms_utils.h +++ b/src/lib/pubkey/hss_lms/hss_lms_utils.h @@ -64,9 +64,13 @@ class PseudorandomKeyGeneration { void gen(std::span out, HashFunction& hash, std::span seed) const; private: + /// Input buffer containing the prefix: 'identifier || u32str(q) || u16str(i) || u8str(j)' std::vector m_input_buffer; + /// Subspan of m_input_buffer representing 'u32str(q)' std::span m_q; + /// Subspan of m_input_buffer representing 'u26str(i)' std::span m_i; + /// Pointer to m_input_buffer at 'u8str(j)' uint8_t* m_j; }; diff --git a/src/lib/pubkey/hss_lms/info.txt b/src/lib/pubkey/hss_lms/info.txt index 70dcb9cfcf8..17946ed2557 100644 --- a/src/lib/pubkey/hss_lms/info.txt +++ b/src/lib/pubkey/hss_lms/info.txt @@ -22,4 +22,5 @@ rng sha2_32 shake trunc_hash +tree_hash diff --git a/src/lib/pubkey/hss_lms/lm_ots.h b/src/lib/pubkey/hss_lms/lm_ots.h index 8bde0b72aa7..f781c4178b6 100644 --- a/src/lib/pubkey/hss_lms/lm_ots.h +++ b/src/lib/pubkey/hss_lms/lm_ots.h @@ -57,7 +57,10 @@ using LMS_Message = Strong, struct LMS_Message_>; /** * @brief Enum of available LM-OTS algorithm types. * - * See RFC 8554 Section 4.1. + * The supported parameter sets are defined in RFC 8554 Section 4.1. and + * draft-fluhrer-lms-more-parm-sets-11 Section 4. HSS/LMS typecodes are + * introduced in RFC 8554 Section 3.2. and their format specified in + * Section 3.3. */ enum class LMOTS_Algorithm_Type : uint32_t { // --- RFC 8554 --- diff --git a/src/lib/pubkey/hss_lms/lms.h b/src/lib/pubkey/hss_lms/lms.h index 0312dc2f20d..2016a8bd1ab 100644 --- a/src/lib/pubkey/hss_lms/lms.h +++ b/src/lib/pubkey/hss_lms/lms.h @@ -21,7 +21,10 @@ namespace Botan { /** * @brief Enum of available LMS algorithm types. * - * See RFC 8554 Section 5.1. + * The supported parameter sets are defined in RFC 8554 Section 5.1. and + * draft-fluhrer-lms-more-parm-sets-11 Section 5. HSS/LMS typecodes are + * introduced in RFC 8554 Section 3.2. and their format specified in + * Section 3.3. */ enum class LMS_Algorithm_Type : uint32_t { // --- RFC 8554 --- diff --git a/src/lib/utils/concepts.h b/src/lib/utils/concepts.h index 0222ed4dfa7..fa586dd22fc 100644 --- a/src/lib/utils/concepts.h +++ b/src/lib/utils/concepts.h @@ -29,18 +29,6 @@ struct is_strong_type> : std::true_type {}; template constexpr bool is_strong_type_v = is_strong_type...>::value; -/** - * Checks whether a strong type has the @p Capability included in its @p Tags type pack. - */ -template -constexpr auto strong_type_has_capability(Strong) { - if constexpr((std::is_same_v || ...)) { - return std::true_type(); - } else { - return std::false_type(); - } -} - namespace concepts { // TODO: C++20 use std::convertible_to<> that was not available in Android NDK @@ -130,9 +118,8 @@ template concept contiguous_strong_type = strong_type && contiguous_container; template -concept strong_type_with_capability = requires(T a) { - { strong_type_has_capability(a) } -> std::same_as; - }; +concept strong_type_with_capability = T::template +has_capability(); // std::integral is a concept that is shipped with C++20 but Android NDK is not // yet there. diff --git a/src/lib/utils/info.txt b/src/lib/utils/info.txt index cf13472cabd..20b874b7dc6 100644 --- a/src/lib/utils/info.txt +++ b/src/lib/utils/info.txt @@ -45,7 +45,6 @@ safeint.h scan_name.h stl_util.h timer.h -tree_hash.h diff --git a/src/lib/utils/stl_util.h b/src/lib/utils/stl_util.h index d5d7662fa3a..d9b3d99c979 100644 --- a/src/lib/utils/stl_util.h +++ b/src/lib/utils/stl_util.h @@ -157,6 +157,11 @@ class BufferSlicer final { return load_be(take(sizeof(T)).data(), 0); } + template + auto copy_le() { + return load_le(take(sizeof(T)).data(), 0); + } + void skip(const size_t count) { take(count); } size_t remaining() const { return m_remaining.size(); } diff --git a/src/lib/utils/strong_type.h b/src/lib/utils/strong_type.h index dda41492da6..b6a2d0069c9 100644 --- a/src/lib/utils/strong_type.h +++ b/src/lib/utils/strong_type.h @@ -157,6 +157,11 @@ class Strong : public detail::Strong_Adapter { public: using detail::Strong_Adapter::Strong_Adapter; + template + constexpr static bool has_capability() { + return (std::is_same_v || ...); + } + private: using Tag = TagTypeT; }; diff --git a/src/lib/utils/tree_hash/info.txt b/src/lib/utils/tree_hash/info.txt new file mode 100644 index 00000000000..ddbcded3f24 --- /dev/null +++ b/src/lib/utils/tree_hash/info.txt @@ -0,0 +1,12 @@ + +TREE_HASH -> 20231006 + + + +name -> "Tree Hash" + + + +tree_hash.h + + diff --git a/src/lib/utils/tree_hash.h b/src/lib/utils/tree_hash/tree_hash.h similarity index 99% rename from src/lib/utils/tree_hash.h rename to src/lib/utils/tree_hash/tree_hash.h index 6c2f1014f9f..db1e4c94a42 100644 --- a/src/lib/utils/tree_hash.h +++ b/src/lib/utils/tree_hash/tree_hash.h @@ -43,9 +43,6 @@ concept tree_node_index = strong_type_with_capability concept tree_layer_index = strong_type_with_capability; -template -struct strong_span_type {}; - /** * @brief An adress in a Tree. */