diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/third_party/botan/src/lib/pubkey/mce/code_based_util.h | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/third_party/botan/src/lib/pubkey/mce/code_based_util.h')
-rw-r--r-- | comm/third_party/botan/src/lib/pubkey/mce/code_based_util.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/comm/third_party/botan/src/lib/pubkey/mce/code_based_util.h b/comm/third_party/botan/src/lib/pubkey/mce/code_based_util.h new file mode 100644 index 0000000000..5b0a9195a0 --- /dev/null +++ b/comm/third_party/botan/src/lib/pubkey/mce/code_based_util.h @@ -0,0 +1,57 @@ +/* + * (C) Copyright Projet SECRET, INRIA, Rocquencourt + * (C) Bhaskar Biswas and Nicolas Sendrier + * + * (C) 2014 cryptosource GmbH + * (C) 2014 Falko Strenzke fstrenzke@cryptosource.de + * + * Botan is released under the Simplified BSD License (see license.txt) + * + */ + +#ifndef BOTAN_CODE_BASED_UTIL_H_ +#define BOTAN_CODE_BASED_UTIL_H_ + +#include <botan/gf2m_small_m.h> + +namespace Botan { + +/** +* Expand an input to a bit mask depending on it being being zero or non-zero +* @param tst the input +* @return the mask 0xFFFF if tst is non-zero and 0 otherwise +*/ +template<typename T> +uint16_t expand_mask_16bit(T tst) + { + const uint16_t result = (tst != 0); + return ~(result - 1); + } + +inline gf2m gray_to_lex(gf2m gray) + { + gf2m result = gray ^ (gray >> 8); + result ^= (result >> 4); + result ^= (result >> 2); + result ^= (result >> 1); + return result; + } + +inline gf2m lex_to_gray(gf2m lex) + { + return (lex >> 1) ^ lex; + } + +inline size_t bit_size_to_byte_size(size_t bit_size) + { + return (bit_size - 1) / 8 + 1; + } + +inline size_t bit_size_to_32bit_size(size_t bit_size) + { + return (bit_size - 1) / 32 + 1; + } + +} + +#endif |