Overview
Description
Boost.Crypt is cryptographic module aiming for FIPS 140-3 certification.
Warning
|
This library is currently uncertified |
The library is header-only, has no dependencies, and requires C++14.
Motivation
This library will be a ground-up, modern, and memory safe implementation of standard cryptographic routines. Since it is header only and has no dependencies it is trivial to integrate into any project. It also offers native CUDA support to massively parallelize these routines (such as hashing thousands of files simultaneously)
Use Cases
Anywhere where security is needed.
Supported Compilers
Boost.Crypt is tested natively on Ubuntu (x86_64, s390x, and aarch64), macOS (x86_64, and Apple Silicon), and Windows (x32 and x64); as well as emulated PPC64LE and STM32 using QEMU with the following compilers:
-
GCC 7 and later
-
Clang 6 and later
-
Visual Studio 2017 and later
-
Intel OneAPI DPC++ 2024.2 and later
-
CUDA Toolkit 12.5 and later (Both NVCC and NVRTC)
Tested on Github Actions and Drone. Coverage can be found on Codecov.
API Reference
Types
Structures and Classes
Hashers
SHA2 Family of Hashers
SHA3 Family of Hashers
Hash-Based Message Authentication Codes (HMAC)
Deterministic Random Bit Generators (DRBG)
Hash-Based
Non-Prediction Resistant
HMAC-Based
Non-Prediction Resistant
Enums
Constants
-
None
Macros
See: Configuration Macros
State
The state enum class
allows you to verify the validity of the state of an object.
The following are the possible states:
-
success
- The hasher is proceeding without issue -
null
- A null pointer was passed to hasher -
input_too_long
- The number of bytes passed to the hasher object has exceeded the range ofsize_t
-
insufficient_entropy
- The input entropy + nonce length is not at least 3/2 security strength -
out_of_memory
-ENOMEM
returned by memory allocation -
requires_reseed
- The number of cycles an object has been used exceeded the design amount -
uninitialized
- An object has not been initialized properly before use -
state_error
- A misuse has occurred such as a hasher object was not reinitialized after calling.get_digest()
. The simple solution is to call.init()
and try again.
namespace boost {
namespace crypt {
enum class state : boost::crypt::uint8_t
{
success, // no issues
null, // nullptr as parameter
input_too_long, // input data too long (exceeded size_t)
insufficient_entropy, // Entropy + Nonce length was not at least 3/2 security strength
out_of_memory, // Memory exhaustion reported by a function
requires_reseed, // The number of cycles has exceeded the specified amount
uninitialized, // Random bits can not be provided since the generator is uninitialized
requested_too_many_bits, // 2^19 bits is all that's allowed per request
state_error // added more input after get_digest without re-init
};
} // namespace crypt
} // namespace boost
MD5
Warning
|
MD5 is not secure so it must be explicitly enabled as an acknowledgment of the risk of using it. |
This library supports MD5 as described in RFC 1321. There is a wide range of acceptable inputs for the base md5 function:
Hashing Functions
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 16>;
BOOST_CRYPT_GPU_ENABLED inline auto md5(const char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto md5(const char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto md5(const unsigned char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto md5(const unsigned char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto md5(const char16_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto md5(const char16_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto md5(const char32_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto md5(const char32_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto md5(const wchar_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto md5(const wchar_t* str, size_t len) noexcept -> return_type;
inline auto md5(const std::string& str) noexcept -> return_type;
inline auto md5(const std::u16string& str) noexcept -> return_type;
inline auto md5(const std::u32string& str) noexcept -> return_type;
inline auto md5(const std::wstring& str) noexcept -> return_type;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto md5(std::string_view str) noexcept -> return_type;
inline auto md5(std::u16string_view str) noexcept -> return_type;
inline auto md5(std::u32string_view str) noexcept -> return_type;
inline auto md5(std::wstring_view str) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
inline auto md5(std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto md5(cuda::std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_CUDA
} //namespace crypt
} //namespace boost
File Hashing Functions
We also have the ability to scan files and return the MD5 value:
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 16>;
inline auto md5_file(const char* filepath) noexcept -> return_type;
inline auto md5_file(const std::string& filepath) noexcept -> return_type;
inline auto md5_file(std::string_view filepath) noexcept -> return_type;
} // namespace crypt
} // namespace boost
Hashing Object
Lastly, there is also the ability to create a MD5 hashing object and feed it bytes as the user parses them. This class does not use any dynamic memory allocation.
namespace boost {
namespace crypt {
class md5_hasher
{
uisng return_type = boost::crypt::array<uint8_t, 16>;
void init();
template <typename ByteType>
BOOST_CRYPT_GPU_ENABLED inline auto process_byte(ByteType byte) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(ForwardIter buffer, size_t byte_count) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto process_bytes(std::string_view str) noexcept -> state;
inline auto process_bytes(std::u16string_view str) noexcept -> state;
inline auto process_bytes(std::u32string_view str) noexcept -> state;
inline auto process_bytes(std::wstring_view str) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, boost::crypt::size_t extent>
inline auto process_bytes(std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(cuda::std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_CUDA
inline auto get_digest() noexcept -> return_type;
};
} // namespace crypt
} // namespace boost
SHA1
This library supports SHA1 as described in RFC 3174. There is a wide range of acceptable inputs for the base sha1 function:
Hashing Functions
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 20>;
BOOST_CRYPT_GPU_ENABLED inline auto sha1(const char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha1(const char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha1(const unsigned char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha1(const unsigned char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha1(const char16_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha1(const char16_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha1(const char32_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha1(const char32_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha1(const wchar_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha1(const wchar_t* str, size_t len) noexcept -> return_type;
inline auto sha1(const std::string& str) noexcept -> return_type;
inline auto sha1(const std::u16string& str) noexcept -> return_type;
inline auto sha1(const std::u32string& str) noexcept -> return_type;
inline auto sha1(const std::wstring& str) noexcept -> return_type;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto sha1(std::string_view str) noexcept -> return_type;
inline auto sha1(std::u16string_view str) noexcept -> return_type;
inline auto sha1(std::u32string_view str) noexcept -> return_type;
inline auto sha1(std::wstring_view str) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
inline auto md5(std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto md5(cuda::std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_CUDA
} //namespace crypt
} //namespace boost
File Hashing Functions
We also have the ability to scan files and return the sha1 value:
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 16>;
inline auto sha1_file(const char* filepath) noexcept -> return_type;
inline auto sha1_file(const std::string& filepath) noexcept -> return_type;
inline auto sha1_file(std::string_view filepath) noexcept -> return_type;
} // namespace crypt
} // namespace boost
Hashing Object
Lastly, there is also the ability to create a sha1 hashing object and feed it bytes as the user parses them. This class does not use any dynamic memory allocation.
namespace boost {
namespace crypt {
class sha1_hasher
{
uisng return_type = boost::crypt::array<uint8_t, 20>;
void init();
template <typename ByteType>
BOOST_CRYPT_GPU_ENABLED inline auto process_byte(ByteType byte) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(ForwardIter buffer, size_t byte_count) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto process_bytes(std::string_view str) noexcept -> state;
inline auto process_bytes(std::u16string_view str) noexcept -> state;
inline auto process_bytes(std::u32string_view str) noexcept -> state;
inline auto process_bytes(std::wstring_view str) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, boost::crypt::size_t extent>
inline auto process_bytes(std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(cuda::std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_CUDA
inline auto get_digest() noexcept -> boost::crypt::array<boost::crypt::uint8_t, 20>;
};
} // namespace crypt
} // namespace boost
SHA224
This library supports sha224 as described in RFC 6234. There is a wide range of acceptable inputs for the base sha224 function:
Hashing Functions
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 32>;
BOOST_CRYPT_GPU_ENABLED inline auto sha224(const char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha224(const char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha224(const unsigned char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha224(const unsigned char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha224(const char16_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha224(const char16_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha224(const char32_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha224(const char32_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha224(const wchar_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha224(const wchar_t* str, size_t len) noexcept -> return_type;
inline auto sha224(const std::string& str) noexcept -> return_type;
inline auto sha224(const std::u16string& str) noexcept -> return_type;
inline auto sha224(const std::u32string& str) noexcept -> return_type;
inline auto sha224(const std::wstring& str) noexcept -> return_type;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto sha224(std::string_view str) noexcept -> return_type;
inline auto sha224(std::u16string_view str) noexcept -> return_type;
inline auto sha224(std::u32string_view str) noexcept -> return_type;
inline auto sha224(std::wstring_view str) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
inline auto md5(std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto md5(cuda::std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_CUDA
} //namespace crypt
} //namespace boost
File Hashing Functions
We also have the ability to scan files and return the sha224 value:
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 32>;
inline auto sha224_file(const char* filepath) noexcept -> return_type;
inline auto sha224_file(const std::string& filepath) noexcept -> return_type;
inline auto sha224_file(std::string_view filepath) noexcept -> return_type;
} // namespace crypt
} // namespace boost
Hashing Object
Lastly, there is also the ability to create a sha224 hashing object and feed it bytes as the user parses them. This class does not use any dynamic memory allocation.
namespace boost {
namespace crypt {
class sha224_hasher
{
uisng return_type = boost::crypt::array<uint8_t, 32>;
void init();
template <typename ByteType>
BOOST_CRYPT_GPU_ENABLED inline auto process_byte(ByteType byte) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(ForwardIter buffer, size_t byte_count) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto process_bytes(std::string_view str) noexcept -> state;
inline auto process_bytes(std::u16string_view str) noexcept -> state;
inline auto process_bytes(std::u32string_view str) noexcept -> state;
inline auto process_bytes(std::wstring_view str) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, boost::crypt::size_t extent>
inline auto process_bytes(std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(cuda::std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_CUDA
inline auto get_digest() noexcept -> return_type;
};
} // namespace crypt
} // namespace boost
SHA256
This library supports sha256 as described in RFC 6234. There is a wide range of acceptable inputs for the base sha256 function:
Hashing Functions
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 32>;
BOOST_CRYPT_GPU_ENABLED inline auto sha256(const char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha256(const char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha256(const unsigned char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha256(const unsigned char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha256(const char16_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha256(const char16_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha256(const char32_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha256(const char32_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha256(const wchar_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha256(const wchar_t* str, size_t len) noexcept -> return_type;
inline auto sha256(const std::string& str) noexcept -> return_type;
inline auto sha256(const std::u16string& str) noexcept -> return_type;
inline auto sha256(const std::u32string& str) noexcept -> return_type;
inline auto sha256(const std::wstring& str) noexcept -> return_type;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto sha256(std::string_view str) noexcept -> return_type;
inline auto sha256(std::u16string_view str) noexcept -> return_type;
inline auto sha256(std::u32string_view str) noexcept -> return_type;
inline auto sha256(std::wstring_view str) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
inline auto md5(std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto md5(cuda::std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_CUDA
} //namespace crypt
} //namespace boost
File Hashing Functions
We also have the ability to scan files and return the sha256 value:
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 32>;
inline auto sha256_file(const char* filepath) noexcept -> return_type;
inline auto sha256_file(const std::string& filepath) noexcept -> return_type;
inline auto sha256_file(std::string_view filepath) noexcept -> return_type;
} // namespace crypt
} // namespace boost
Hashing Object
Lastly, there is also the ability to create a sha256 hashing object and feed it bytes as the user parses them. This class does not use any dynamic memory allocation.
namespace boost {
namespace crypt {
class sha256_hasher
{
uisng return_type = boost::crypt::array<uint8_t, 32>;
void init();
template <typename ByteType>
BOOST_CRYPT_GPU_ENABLED inline auto process_byte(ByteType byte) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(ForwardIter buffer, size_t byte_count) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto process_bytes(std::string_view str) noexcept -> state;
inline auto process_bytes(std::u16string_view str) noexcept -> state;
inline auto process_bytes(std::u32string_view str) noexcept -> state;
inline auto process_bytes(std::wstring_view str) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, boost::crypt::size_t extent>
inline auto process_bytes(std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(cuda::std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_CUDA
inline auto get_digest() noexcept -> return_type;
};
} // namespace crypt
} // namespace boost
SHA384
This library supports sha384 as described in RFC 6234. There is a wide range of acceptable inputs for the base sha384 function:
Hashing Functions
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 48>;
BOOST_CRYPT_GPU_ENABLED inline auto sha384(const char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha384(const char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha384(const unsigned char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha384(const unsigned char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha384(const char16_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha384(const char16_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha384(const char32_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha384(const char32_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha384(const wchar_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha384(const wchar_t* str, size_t len) noexcept -> return_type;
inline auto sha384(const std::string& str) noexcept -> return_type;
inline auto sha384(const std::u16string& str) noexcept -> return_type;
inline auto sha384(const std::u32string& str) noexcept -> return_type;
inline auto sha384(const std::wstring& str) noexcept -> return_type;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto sha384(std::string_view str) noexcept -> return_type;
inline auto sha384(std::u16string_view str) noexcept -> return_type;
inline auto sha384(std::u32string_view str) noexcept -> return_type;
inline auto sha384(std::wstring_view str) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
inline auto md5(std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto md5(cuda::std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_CUDA
} //namespace crypt
} //namespace boost
File Hashing Functions
We also have the ability to scan files and return the sha384 value:
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 48>;
inline auto sha384_file(const char* filepath) noexcept -> return_type;
inline auto sha384_file(const std::string& filepath) noexcept -> return_type;
inline auto sha384_file(std::string_view filepath) noexcept -> return_type;
} // namespace crypt
} // namespace boost
Hashing Object
Lastly, there is also the ability to create a sha384 hashing object and feed it bytes as the user parses them. This class does not use any dynamic memory allocation.
namespace boost {
namespace crypt {
class sha384_hasher
{
uisng return_type = boost::crypt::array<uint8_t, 48>;
void init();
template <typename ByteType>
BOOST_CRYPT_GPU_ENABLED inline auto process_byte(ByteType byte) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(ForwardIter buffer, size_t byte_count) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto process_bytes(std::string_view str) noexcept -> state;
inline auto process_bytes(std::u16string_view str) noexcept -> state;
inline auto process_bytes(std::u32string_view str) noexcept -> state;
inline auto process_bytes(std::wstring_view str) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, boost::crypt::size_t extent>
inline auto process_bytes(std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(cuda::std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_CUDA
inline auto get_digest() noexcept -> return_type;
};
} // namespace crypt
} // namespace boost
SHA512
This library supports sha512 as described in RFC 6234. There is a wide range of acceptable inputs for the base sha512 function:
Hashing Functions
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 64>;
BOOST_CRYPT_GPU_ENABLED inline auto sha512(const char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512(const char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512(const unsigned char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512(const unsigned char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512(const char16_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512(const char16_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512(const char32_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512(const char32_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512(const wchar_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512(const wchar_t* str, size_t len) noexcept -> return_type;
inline auto sha512(const std::string& str) noexcept -> return_type;
inline auto sha512(const std::u16string& str) noexcept -> return_type;
inline auto sha512(const std::u32string& str) noexcept -> return_type;
inline auto sha512(const std::wstring& str) noexcept -> return_type;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto sha512(std::string_view str) noexcept -> return_type;
inline auto sha512(std::u16string_view str) noexcept -> return_type;
inline auto sha512(std::u32string_view str) noexcept -> return_type;
inline auto sha512(std::wstring_view str) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
inline auto md5(std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto md5(cuda::std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_CUDA
} //namespace crypt
} //namespace boost
File Hashing Functions
We also have the ability to scan files and return the sha512 value:
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 64>;
inline auto sha512_file(const char* filepath) noexcept -> return_type;
inline auto sha512_file(const std::string& filepath) noexcept -> return_type;
inline auto sha512_file(std::string_view filepath) noexcept -> return_type;
} // namespace crypt
} // namespace boost
Hashing Object
Lastly, there is also the ability to create a sha512 hashing object and feed it bytes as the user parses them. This class does not use any dynamic memory allocation.
namespace boost {
namespace crypt {
class sha512_hasher
{
uisng return_type = boost::crypt::array<uint8_t, 64>;
void init();
template <typename ByteType>
BOOST_CRYPT_GPU_ENABLED inline auto process_byte(ByteType byte) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(ForwardIter buffer, size_t byte_count) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto process_bytes(std::string_view str) noexcept -> state;
inline auto process_bytes(std::u16string_view str) noexcept -> state;
inline auto process_bytes(std::u32string_view str) noexcept -> state;
inline auto process_bytes(std::wstring_view str) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, boost::crypt::size_t extent>
inline auto process_bytes(std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(cuda::std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_CUDA
inline auto get_digest() noexcept -> return_type;
};
} // namespace crypt
} // namespace boost
SHA512_224
This library supports sha512_224 as described in RFC 6234. There is a wide range of acceptable inputs for the base sha512_224 function:
Hashing Functions
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 28>;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_224(const char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_224(const char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_224(const unsigned char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_224(const unsigned char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_224(const char16_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_224(const char16_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_224(const char32_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_224(const char32_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_224(const wchar_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_224(const wchar_t* str, size_t len) noexcept -> return_type;
inline auto sha512_224(const std::string& str) noexcept -> return_type;
inline auto sha512_224(const std::u16string& str) noexcept -> return_type;
inline auto sha512_224(const std::u32string& str) noexcept -> return_type;
inline auto sha512_224(const std::wstring& str) noexcept -> return_type;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto sha512_224(std::string_view str) noexcept -> return_type;
inline auto sha512_224(std::u16string_view str) noexcept -> return_type;
inline auto sha512_224(std::u32string_view str) noexcept -> return_type;
inline auto sha512_224(std::wstring_view str) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
inline auto md5(std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto md5(cuda::std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_CUDA
} //namespace crypt
} //namespace boost
File Hashing Functions
We also have the ability to scan files and return the sha512_224 value:
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 28>;
inline auto sha512_224_file(const char* filepath) noexcept -> return_type;
inline auto sha512_224_file(const std::string& filepath) noexcept -> return_type;
inline auto sha512_224_file(std::string_view filepath) noexcept -> return_type;
} // namespace crypt
} // namespace boost
Hashing Object
Lastly, there is also the ability to create a sha512_224 hashing object and feed it bytes as the user parses them. This class does not use any dynamic memory allocation.
namespace boost {
namespace crypt {
class sha512_224_hasher
{
uisng return_type = boost::crypt::array<uint8_t, 28>;
void init();
template <typename ByteType>
BOOST_CRYPT_GPU_ENABLED inline auto process_byte(ByteType byte) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(ForwardIter buffer, size_t byte_count) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto process_bytes(std::string_view str) noexcept -> state;
inline auto process_bytes(std::u16string_view str) noexcept -> state;
inline auto process_bytes(std::u32string_view str) noexcept -> state;
inline auto process_bytes(std::wstring_view str) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, boost::crypt::size_t extent>
inline auto process_bytes(std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(cuda::std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_CUDA
inline auto get_digest() noexcept -> return_type;
};
} // namespace crypt
} // namespace boost
SHA512_256
This library supports sha512_256 as described in RFC 6234. There is a wide range of acceptable inputs for the base sha512_256 function:
Hashing Functions
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 32>;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_256(const char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_256(const char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_256(const unsigned char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_256(const unsigned char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_256(const char16_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_256(const char16_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_256(const char32_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_256(const char32_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_256(const wchar_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha512_256(const wchar_t* str, size_t len) noexcept -> return_type;
inline auto sha512_256(const std::string& str) noexcept -> return_type;
inline auto sha512_256(const std::u16string& str) noexcept -> return_type;
inline auto sha512_256(const std::u32string& str) noexcept -> return_type;
inline auto sha512_256(const std::wstring& str) noexcept -> return_type;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto sha512_256(std::string_view str) noexcept -> return_type;
inline auto sha512_256(std::u16string_view str) noexcept -> return_type;
inline auto sha512_256(std::u32string_view str) noexcept -> return_type;
inline auto sha512_256(std::wstring_view str) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
inline auto md5(std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto md5(cuda::std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_CUDA
} //namespace crypt
} //namespace boost
File Hashing Functions
We also have the ability to scan files and return the sha512_256 value:
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 32>;
inline auto sha512_256_file(const char* filepath) noexcept -> return_type;
inline auto sha512_256_file(const std::string& filepath) noexcept -> return_type;
inline auto sha512_256_file(std::string_view filepath) noexcept -> return_type;
} // namespace crypt
} // namespace boost
Hashing Object
Lastly, there is also the ability to create a sha512_256 hashing object and feed it bytes as the user parses them. This class does not use any dynamic memory allocation.
namespace boost {
namespace crypt {
class sha512_256_hasher
{
uisng return_type = boost::crypt::array<uint8_t, 32>;
void init();
template <typename ByteType>
BOOST_CRYPT_GPU_ENABLED inline auto process_byte(ByteType byte) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(ForwardIter buffer, size_t byte_count) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto process_bytes(std::string_view str) noexcept -> state;
inline auto process_bytes(std::u16string_view str) noexcept -> state;
inline auto process_bytes(std::u32string_view str) noexcept -> state;
inline auto process_bytes(std::wstring_view str) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, boost::crypt::size_t extent>
inline auto process_bytes(std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(cuda::std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_CUDA
inline auto get_digest() noexcept -> return_type;
};
} // namespace crypt
} // namespace boost
SHA3_224
This library supports sha3_224 as described in SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions. There is a wide range of acceptable inputs for the base sha3_224 function:
Hashing Functions
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 28>;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_224(const char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_224(const char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_224(const unsigned char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_224(const unsigned char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_224(const char16_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_224(const char16_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_224(const char32_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_224(const char32_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_224(const wchar_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_224(const wchar_t* str, size_t len) noexcept -> return_type;
inline auto sha3_224(const std::string& str) noexcept -> return_type;
inline auto sha3_224(const std::u16string& str) noexcept -> return_type;
inline auto sha3_224(const std::u32string& str) noexcept -> return_type;
inline auto sha3_224(const std::wstring& str) noexcept -> return_type;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto sha3_224(std::string_view str) noexcept -> return_type;
inline auto sha3_224(std::u16string_view str) noexcept -> return_type;
inline auto sha3_224(std::u32string_view str) noexcept -> return_type;
inline auto sha3_224(std::wstring_view str) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
inline auto md5(std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto md5(cuda::std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_CUDA
} //namespace crypt
} //namespace boost
File Hashing Functions
We also have the ability to scan files and return the sha3_224 value:
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 28>;
inline auto sha3_224_file(const char* filepath) noexcept -> return_type;
inline auto sha3_224_file(const std::string& filepath) noexcept -> return_type;
inline auto sha3_224_file(std::string_view filepath) noexcept -> return_type;
} // namespace crypt
} // namespace boost
Hashing Object
Lastly, there is also the ability to create a sha3_224 hashing object and feed it bytes as the user parses them. This class does not use any dynamic memory allocation.
namespace boost {
namespace crypt {
class sha3_224_hasher
{
uisng return_type = boost::crypt::array<uint8_t, 28>;
void init();
template <typename ByteType>
BOOST_CRYPT_GPU_ENABLED inline auto process_byte(ByteType byte) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(ForwardIter buffer, size_t byte_count) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto process_bytes(std::string_view str) noexcept -> state;
inline auto process_bytes(std::u16string_view str) noexcept -> state;
inline auto process_bytes(std::u32string_view str) noexcept -> state;
inline auto process_bytes(std::wstring_view str) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, boost::crypt::size_t extent>
inline auto process_bytes(std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(cuda::std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_CUDA
inline auto get_digest() noexcept -> return_type;
};
} // namespace crypt
} // namespace boost
SHA3_256
This library supports sha3_256 as described in SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions. There is a wide range of acceptable inputs for the base sha3_256 function:
Hashing Functions
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 32>;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_256(const char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_256(const char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_256(const unsigned char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_256(const unsigned char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_256(const char16_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_256(const char16_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_256(const char32_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_256(const char32_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_256(const wchar_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_256(const wchar_t* str, size_t len) noexcept -> return_type;
inline auto sha3_256(const std::string& str) noexcept -> return_type;
inline auto sha3_256(const std::u16string& str) noexcept -> return_type;
inline auto sha3_256(const std::u32string& str) noexcept -> return_type;
inline auto sha3_256(const std::wstring& str) noexcept -> return_type;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto sha3_256(std::string_view str) noexcept -> return_type;
inline auto sha3_256(std::u16string_view str) noexcept -> return_type;
inline auto sha3_256(std::u32string_view str) noexcept -> return_type;
inline auto sha3_256(std::wstring_view str) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
inline auto md5(std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto md5(cuda::std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_CUDA
} //namespace crypt
} //namespace boost
File Hashing Functions
We also have the ability to scan files and return the sha3_256 value:
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 32>;
inline auto sha3_256_file(const char* filepath) noexcept -> return_type;
inline auto sha3_256_file(const std::string& filepath) noexcept -> return_type;
inline auto sha3_256_file(std::string_view filepath) noexcept -> return_type;
} // namespace crypt
} // namespace boost
Hashing Object
Lastly, there is also the ability to create a sha3_256 hashing object and feed it bytes as the user parses them. This class does not use any dynamic memory allocation.
namespace boost {
namespace crypt {
class sha3_256_hasher
{
uisng return_type = boost::crypt::array<uint8_t, 32>;
void init();
template <typename ByteType>
BOOST_CRYPT_GPU_ENABLED inline auto process_byte(ByteType byte) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(ForwardIter buffer, size_t byte_count) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto process_bytes(std::string_view str) noexcept -> state;
inline auto process_bytes(std::u16string_view str) noexcept -> state;
inline auto process_bytes(std::u32string_view str) noexcept -> state;
inline auto process_bytes(std::wstring_view str) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, boost::crypt::size_t extent>
inline auto process_bytes(std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(cuda::std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_CUDA
inline auto get_digest() noexcept -> return_type;
};
} // namespace crypt
} // namespace boost
SHA3_384
This library supports sha3_384 as described in SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions. There is a wide range of acceptable inputs for the base sha3_384 function:
Hashing Functions
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 48>;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_384(const char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_384(const char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_384(const unsigned char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_384(const unsigned char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_384(const char16_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_384(const char16_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_384(const char32_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_384(const char32_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_384(const wchar_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_384(const wchar_t* str, size_t len) noexcept -> return_type;
inline auto sha3_384(const std::string& str) noexcept -> return_type;
inline auto sha3_384(const std::u16string& str) noexcept -> return_type;
inline auto sha3_384(const std::u32string& str) noexcept -> return_type;
inline auto sha3_384(const std::wstring& str) noexcept -> return_type;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto sha3_384(std::string_view str) noexcept -> return_type;
inline auto sha3_384(std::u16string_view str) noexcept -> return_type;
inline auto sha3_384(std::u32string_view str) noexcept -> return_type;
inline auto sha3_384(std::wstring_view str) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
inline auto md5(std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto md5(cuda::std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_CUDA
} //namespace crypt
} //namespace boost
File Hashing Functions
We also have the ability to scan files and return the sha3_384 value:
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 48>;
inline auto sha3_384_file(const char* filepath) noexcept -> return_type;
inline auto sha3_384_file(const std::string& filepath) noexcept -> return_type;
inline auto sha3_384_file(std::string_view filepath) noexcept -> return_type;
} // namespace crypt
} // namespace boost
Hashing Object
Lastly, there is also the ability to create a sha3_384 hashing object and feed it bytes as the user parses them. This class does not use any dynamic memory allocation.
namespace boost {
namespace crypt {
class sha3_384_hasher
{
uisng return_type = boost::crypt::array<uint8_t, 48>;
void init();
template <typename ByteType>
BOOST_CRYPT_GPU_ENABLED inline auto process_byte(ByteType byte) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(ForwardIter buffer, size_t byte_count) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto process_bytes(std::string_view str) noexcept -> state;
inline auto process_bytes(std::u16string_view str) noexcept -> state;
inline auto process_bytes(std::u32string_view str) noexcept -> state;
inline auto process_bytes(std::wstring_view str) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, boost::crypt::size_t extent>
inline auto process_bytes(std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(cuda::std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_CUDA
inline auto get_digest() noexcept -> return_type;
};
} // namespace crypt
} // namespace boost
SHA3_512
This library supports sha3_512 as described in SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions. There is a wide range of acceptable inputs for the base sha3_512 function:
Hashing Functions
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 64>;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_512(const char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_512(const char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_512(const unsigned char* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_512(const unsigned char* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_512(const char16_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_512(const char16_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_512(const char32_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_512(const char32_t* str, size_t len) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_512(const wchar_t* str) noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED inline auto sha3_512(const wchar_t* str, size_t len) noexcept -> return_type;
inline auto sha3_512(const std::string& str) noexcept -> return_type;
inline auto sha3_512(const std::u16string& str) noexcept -> return_type;
inline auto sha3_512(const std::u32string& str) noexcept -> return_type;
inline auto sha3_512(const std::wstring& str) noexcept -> return_type;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto sha3_512(std::string_view str) noexcept -> return_type;
inline auto sha3_512(std::u16string_view str) noexcept -> return_type;
inline auto sha3_512(std::u32string_view str) noexcept -> return_type;
inline auto sha3_512(std::wstring_view str) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
inline auto md5(std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto md5(cuda::std::span<T, extent> data) noexcept -> return_type;
#endif // BOOST_CRYPT_HAS_CUDA
} //namespace crypt
} //namespace boost
File Hashing Functions
We also have the ability to scan files and return the sha3_512 value:
namespace boost {
namespace crypt {
uisng return_type = boost::crypt::array<uint8_t, 64>;
inline auto sha3_512_file(const char* filepath) noexcept -> return_type;
inline auto sha3_512_file(const std::string& filepath) noexcept -> return_type;
inline auto sha3_512_file(std::string_view filepath) noexcept -> return_type;
} // namespace crypt
} // namespace boost
Hashing Object
Lastly, there is also the ability to create a sha3_512 hashing object and feed it bytes as the user parses them. This class does not use any dynamic memory allocation.
namespace boost {
namespace crypt {
class sha3_512_hasher
{
uisng return_type = boost::crypt::array<uint8_t, 64>;
void init();
template <typename ByteType>
BOOST_CRYPT_GPU_ENABLED inline auto process_byte(ByteType byte) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(ForwardIter buffer, size_t byte_count) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
inline auto process_bytes(std::string_view str) noexcept -> state;
inline auto process_bytes(std::u16string_view str) noexcept -> state;
inline auto process_bytes(std::u32string_view str) noexcept -> state;
inline auto process_bytes(std::wstring_view str) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, boost::crypt::size_t extent>
inline auto process_bytes(std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
#ifdef BOOST_CRYPT_HAS_CUDA
template <typename T, boost::crypt::size_t extent>
BOOST_CRYPT_GPU_ENABLED inline auto process_bytes(cuda::std::span<T, extent> data) noexcept -> state;
#endif // BOOST_CRYPT_HAS_CUDA
inline auto get_digest() noexcept -> return_type;
};
} // namespace crypt
} // namespace boost
HMAC
This library provides a robust implementation of HMAC (Hash-based Message Authentication Code) as specified in RFC 2104. HMAC is a widely used mechanism for message authentication that combines a cryptographic hash function with a secret key to ensure data integrity and authenticity.
Overview
HMAC is designed to provide a secure way to verify both the data integrity and the authenticity of a message. It uses a hash function (such as SHA-256, SHA-3/512, etc.) in combination with a secret key to generate a message authentication code (MAC). The MAC can then be used to verify that the message has not been altered and that it comes from an authenticated sender.
Template Class Implementation
Our HMAC implementation is designed as a template class, allowing it to work seamlessly with any of our hashers. This flexibility means you can choose the most appropriate hashing algorithm for your specific use case without needing to modify the HMAC code itself. Here’s how you might instantiate and use the HMAC class:
boost::crypt::hmac<boost::crypt::sha512_hasher> hmac;
const auto state_1 {hmac.init("key", 3)};
BOOST_TEST(state_1 == boost::crypt::state::success);
const char* msg {"The quick brown fox jumps over the lazy dog"};
const auto state_2 {hmac.process_bytes(msg, std::strlen(msg))};
BOOST_TEST(state_2 == boost::crypt::state::success);
const auto res {hmac.get_digest()};
Key Recovery and Reuse
One of the unique features of our HMAC implementation is the ability to recover the inner and outer keys after initialization. This can be useful in scenarios where you need to compute HMACs for short messages repeatedly, as it allows you to avoid recalculating these keys each time.
Continuing from our above example:
boost::crypt::hmac<boost::crypt::sha512_hasher> hmac;
const auto state_1 {hmac.init("key", 3)};
BOOST_TEST(state_1 == boost::crypt::state::success);
const char* msg {"The quick brown fox jumps over the lazy dog"};
const auto state_2 {hmac.process_bytes(msg, std::strlen(msg))};
BOOST_TEST(state_2 == boost::crypt::state::success);
const auto res {hmac.get_digest()};
const auto outer_key {hmac.get_outer_key()};
const auto inner_key {hmac.get_inner_key()};
// Do some stuff
boost::crypt::hmac<boost::crypt::sha512_hasher> hmac2(inner_key, outer_key);
const char* msg2 {"The quick brown fox jumps over the lazy dog"};
const auto state_3 {hmac2.process_bytes(msg, std::strlen(msg))};
BOOST_TEST(state_3 == boost::crypt::state::success);
const auto res2 {hmac2.get_digest()};
Security Considerations
It is crucial to treat the inner and outer keys with the same level of security as the original secret key. These keys should be stored securely and not exposed to unauthorized parties. By providing this flexibility and functionality, our HMAC implementation aims to offer a secure, efficient, and versatile solution for message authentication in your applications.
Reference
namespace boost {
namespace crypt {
BOOST_CRYPT_EXPORT template <typename HasherType>
class hmac
{
public:
static constexpr boost::crypt::size_t block_size_ {HasherType::block_size};
using return_type = typename HasherType::return_type;
using key_type = boost::crypt::array<boost::crypt::uint8_t, block_size_>;
BOOST_CRYPT_GPU_ENABLED constexpr hmac() noexcept = default;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED constexpr hmac(ForwardIter key, boost::crypt::size_t size) noexcept;
template <typename Container>
BOOST_CRYPT_GPU_ENABLED constexpr hmac(const Container& c) noexcept;
BOOST_CRYPT_GPU_ENABLED constexpr hmac(const key_type& inner_key, const key_type& outer_key) noexcept;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED constexpr auto init(ForwardIter key, boost::crypt::size_t size) noexcept -> state;
template <typename Container>
BOOST_CRYPT_GPU_ENABLED constexpr auto init(const Container& c) noexcept -> state;
template <typename Container>
BOOST_CRYPT_GPU_ENABLED constexpr auto init_from_keys(const Container& inner_key, const Container& outer_key) noexcept -> state;
template <typename ForwardIter>
BOOST_CRYPT_GPU_ENABLED constexpr auto process_bytes(ForwardIter data, boost::crypt::size_t size) noexcept -> state;
template <typename Container>
BOOST_CRYPT_GPU_ENABLED constexpr auto process_bytes(const Container& c) noexcept -> state;
BOOST_CRYPT_GPU_ENABLED constexpr auto get_digest() noexcept -> return_type;
BOOST_CRYPT_GPU_ENABLED constexpr auto get_outer_key() noexcept -> key_type;
BOOST_CRYPT_GPU_ENABLED constexpr auto get_inner_key() noexcept -> key_type;
} //namespace crypt
} //namespace boost
Hash-Based Deterministic Random Bit Generators
Overview
Hash-based Deterministic Random Bit Generators (DRBGs) are cryptographic algorithms that produce a sequence of bits that appear random, but are deterministically generated from an initial seed. These generators are crucial in cryptographic applications where predictability must be avoided and reproducibility is required given the same input. The family of hash DRBGs implemented here leverages cryptographic hash functions to ensure security and randomness properties. The design adheres to standards such as NIST SP 800-90A, which specifies requirements for deterministic random bit generators using hash functions.
Security Considerations
The security of hash DRBGs is primarily dependent on the cryptographic strength of the underlying hash function used. The library supports several popular hash functions from the Boost.Crypt library, including SHA-256, SHA-512, and others.Users are encouraged to choose a hash function that meets their security requirements Key security considerations include:
-
Seed Quality: The initial seed must be sufficiently random and unpredictable. A poor quality seed can compromise the security of the generated bit sequence.
-
Nonce Source: Ensure that you are inputting a nonce when instantiating the generator.
-
Entropy Source: Ensure that the entropy source used to generate the seed is reliable and provides adequate entropy.
-
Re-seeding: Regular reseeding with new entropy is recommended to maintain security, especially in long-running applications.
Prediction Resistance
Prediction resistance refers to the ability of a random number generator to resist attacks that attempt to predict future outputs based on past outputs. A cryptographically secure RNG should be designed in such a way that even if an attacker has observed all previous outputs, they cannot reliably predict future outputs.
See NIST SP 800-90A if you are concerned about approved sources of entropy and nonces.
Reference
namespace boost {
namespace crypt {
namespace drbg {
template <bool prediction_resistance>
using sha1_hash_drbg_t = hash_drbg<sha1_hasher, 128U, 160U, prediction_resistance>;
} // namespace drbg
BOOST_CRYPT_EXPORT using sha1_hash_drbg = drbg::sha1_hash_drbg_t<false>;
BOOST_CRYPT_EXPORT using sha1_hash_drbg_pr = drbg::sha1_hash_drbg_t<true>;
// So on for each hasher available with te correct presets
namespace drbg {
// Max hasher security is defined in NIST SP 800-57 Table 3:
// See: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r5.pdf
//
// 112: None
// 128: SHA-1
// 192: SHA-224, SHA-512/224, SHA3-224
// 256: SHA-256, SHA-512/256, SHA-384, SHA-512, SHA3-256, SHA3-384, SHA3-512
//
// Outlen is defined in NIST SP 800-90A Rev 1 Section 10.1 table 2
// 160: SHA-1
// 224: SHA-224, SHA-512/224
// 256: SHA-256, SHA-512/256
// 384: SHA-384
// 512: SHA-512
template <typename HasherType, boost::crypt::size_t max_hasher_security, boost::crypt::size_t outlen, bool prediction_resistance>
class hash_drbg
{
public:
BOOST_CRYPT_GPU_ENABLED constexpr hash_drbg() noexcept = default;
#ifdef BOOST_CRYPT_HAS_CXX20_CONSTEXPR
BOOST_CRYPT_GPU_ENABLED constexpr ~hash_drbg() noexcept
{
destroy();
}
#endif
template <typename ForwardIter1, typename ForwardIter2 = boost::crypt::uint8_t*, typename ForwardIter3 = boost::crypt::uint8_t*>
BOOST_CRYPT_GPU_ENABLED constexpr auto init(ForwardIter1 entropy, boost::crypt::size_t entropy_size, ForwardIter2 nonce = nullptr, boost::crypt::size_t nonce_size = 0U, ForwardIter3 personalization = nullptr, boost::crypt::size_t personalization_size = 0U) noexcept -> state;
template <typename Container1>
BOOST_CRYPT_GPU_ENABLED constexpr auto init(const Container1& entropy) noexcept -> state;
template <typename Container1, typename Container2>
BOOST_CRYPT_GPU_ENABLED constexpr auto init(const Container1& entropy, const Container2& nonce) noexcept -> state;
template <typename Container1, typename Container2, typename Container3>
BOOST_CRYPT_GPU_ENABLED constexpr auto init(const Container1& entropy, const Container2& nonce, const Container3& personalization) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
constexpr auto init(std::string_view entropy) noexcept -> state;
constexpr auto init(std::string_view entropy, std::string_view nonce) noexcept -> state;
constexpr auto init(std::string_view entropy, std::string_view nonce, std::string_view personalization) noexcept -> state;
#endif
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
constexpr auto init(std::span<T, extent> entropy) noexcept -> state;
template <typename T, std::size_t extent>
constexpr auto init(std::span<T, extent> entropy, std::span<T, extent> nonce) noexcept -> state;
template <typename T, std::size_t extent>
constexpr auto init(std::span<T, extent> entropy, std::span<T, extent> nonce, std::span<T, extent> personalization) noexcept -> state;
#endif
template <typename ForwardIter1, typename ForwardIter2 = boost::crypt::uint8_t*>
BOOST_CRYPT_GPU_ENABLED constexpr auto reseed(ForwardIter1 entropy, boost::crypt::size_t entropy_size,
ForwardIter2 additional_input = nullptr, boost::crypt::size_t additional_input_size = 0U) noexcept -> state;
template <typename Container1>
BOOST_CRYPT_GPU_ENABLED constexpr auto reseed(const Container1& entropy) noexcept -> state;
template <typename Container1, typename Container2>
BOOST_CRYPT_GPU_ENABLED constexpr auto reseed(const Container1& entropy, const Container2& additional_input) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
constexpr auto reseed(const std::string_view entropy) noexcept -> state;
constexpr auto reseed(const std::string_view entropy, const std::string_view additional_input) noexcept -> state;
#endif // BOOST_CRYPT_HAS_STRING_VIEW
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
constexpr auto reseed(std::span<T, extent> entropy) noexcept -> state;
template <typename T, std::size_t extent>
constexpr auto reseed(std::span<T, extent> entropy, std::span<T, extent> additional_input) noexcept -> state;
#endif // BOOST_CRYPT_HAS_SPAN
template <typename ForwardIter1, typename ForwardIter2 = boost::crypt::uint8_t*, typename ForwardIter3 = boost::crypt::uint8_t*>
BOOST_CRYPT_GPU_ENABLED constexpr auto generate(ForwardIter1 data, boost::crypt::size_t requested_bits ForwardIter2 additional_data_1 = nullptr, boost::crypt::size_t additional_data_1_size = 0U, ForwardIter3 additional_data_2 = nullptr, boost::crypt::size_t additional_data_2_size = 0U) noexcept -> state;
BOOST_CRYPT_GPU_ENABLED constexpr auto destroy() noexcept;
};
} // namespace drbg
} // namespace crypt
} // namespace boost
HMAC-Based Deterministic Random Bit Generators
Overview
The HMAC based DRBGs are nearly the same as the hash DRBGs, but internally they use the hmac of a hasher instead of just that hasher directly. These should be preferred for use in new code over the hash equivalents.
Reference
namespace boost {
namespace crypt {
namespace drbg {
template <bool prediction_resistance>
using sha1_hmac_drbg_t = hmac_drbg<hmac<sha1_hasher>, 128U, 160U, prediction_resistance>;
} // namespace drbg
BOOST_CRYPT_EXPORT using sha1_hmac_drbg = drbg::sha1_hmac_drbg_t<false>;
BOOST_CRYPT_EXPORT using sha1_hmac_drbg_pr = drbg::sha1_hmac_drbg_t<true>;
namespace drbg {
// Max hasher security is defined in NIST SP 800-57 Table 3:
// See: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r5.pdf
//
// 112: None
// 128: SHA-1
// 192: SHA-224, SHA-512/224, SHA3-224
// 256: SHA-256, SHA-512/256, SHA-384, SHA-512, SHA3-256, SHA3-384, SHA3-512
//
// Outlen is defined in NIST SP 800-90A Rev 1 Section 10.1 table 2
// 160: SHA-1
// 224: SHA-224, SHA-512/224
// 256: SHA-256, SHA-512/256
// 384: SHA-384
// 512: SHA-512
// Max hasher security is defined in NIST SP 800-57 Table 3:
// See: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r5.pdf
//
// 112: None
// 128: SHA-1
// 192: SHA-224, SHA-512/224, SHA3-224
// 256: SHA-256, SHA-512/256, SHA-384, SHA-512, SHA3-256, SHA3-384, SHA3-512
//
// Outlen is defined in NIST SP 800-90A Rev 1 Section 10.1 table 2
// 160: SHA-1
// 224: SHA-224, SHA-512/224
// 256: SHA-256, SHA-512/256
// 384: SHA-384
// 512: SHA-512
template <typename HMACType, boost::crypt::size_t max_hasher_security, boost::crypt::size_t outlen, bool prediction_resistance>
class hmac_drbg
{
public:
BOOST_CRYPT_GPU_ENABLED constexpr hmac_drbg() = default;
template <typename ForwardIter1, typename ForwardIter2, typename ForwardIter3 = const boost::crypt::uint8_t*>
BOOST_CRYPT_GPU_ENABLED constexpr auto init(ForwardIter1 entropy, boost::crypt::size_t entropy_size, ForwardIter2 nonce = nullptr, boost::crypt::size_t nonce_size = 0, ForwardIter3 personalization = nullptr, boost::crypt::size_t personalization_size = 0) noexcept -> state;
template <typename Container1, typename Container2, typename Container3>
BOOST_CRYPT_GPU_ENABLED constexpr auto init(const Container1& entropy, const Container2& nonce, const Container3& personalization) noexcept -> state;
template <typename Container1, typename Container2>
BOOST_CRYPT_GPU_ENABLED constexpr auto init(const Container1& entropy, const Container2& nonce) noexcept -> state;
template <typename Container1>
BOOST_CRYPT_GPU_ENABLED constexpr auto init(const Container1& entropy) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
constexpr auto init(std::string_view entropy) noexcept -> state;
constexpr auto init(std::string_view entropy, std::string_view nonce) noexcept -> state;
constexpr auto init(std::string_view entropy, std::string_view nonce, std::string_view personalization) noexcept -> state;
#endif
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
constexpr auto init(std::span<T, extent> entropy) noexcept -> state;
template <typename T, std::size_t extent>
constexpr auto init(std::span<T, extent> entropy, std::span<T, extent> nonce) noexcept -> state;
template <typename T, std::size_t extent>
constexpr auto init(std::span<T, extent> entropy, std::span<T, extent> nonce, std::span<T, extent> personalization) noexcept -> state;
#endif
template <typename ForwardIter1, typename ForwardIter2 = const boost::crypt::uint8_t*>
BOOST_CRYPT_GPU_ENABLED constexpr auto reseed(ForwardIter1 entropy, boost::crypt::size_t entropy_size, ForwardIter2 additional_input = nullptr, boost::crypt::size_t additional_input_size = 0) noexcept -> state;
template <typename Container1>
BOOST_CRYPT_GPU_ENABLED constexpr auto reseed(const Container1& entropy) noexcept -> state;
template <typename Container1, typename Container2>
BOOST_CRYPT_GPU_ENABLED constexpr auto reseed(const Container1& entropy, const Container2& additional_input) noexcept -> state;
#ifdef BOOST_CRYPT_HAS_STRING_VIEW
constexpr auto reseed(std::string_view entropy) noexcept -> state;
constexpr auto reseed(std::string_view entropy, std::string_view additional_input) noexcept -> state;
#endif
#ifdef BOOST_CRYPT_HAS_SPAN
template <typename T, std::size_t extent>
constexpr auto reseed(std::span<T, extent> entropy) noexcept -> state;
template <typename T, std::size_t extent>
constexpr auto reseed(std::span<T, extent> entropy, std::span<T, extent> additional_input) noexcept -> state;
#endif
template <typename ForwardIter1, typename ForwardIter2 = const boost::crypt::uint8_t*, typename ForwardIter3 = const boost::crypt::uint8_t*>
BOOST_CRYPT_GPU_ENABLED constexpr auto generate(ForwardIter1 data, boost::crypt::size_t requested_bits, ForwardIter2 additional_data_1 = nullptr, boost::crypt::size_t additional_data_1_size = 0, ForwardIter3 additional_data_2 = nullptr, boost::crypt::size_t additional_data_2_size = 0) noexcept -> state;
template <typename Container1>
BOOST_CRYPT_GPU_ENABLED constexpr auto generate(Container1& data) noexcept -> state;
template <typename Container1, typename Container2>
BOOST_CRYPT_GPU_ENABLED constexpr auto generate(Container1& data, const Container2& additional_data_1) noexcept -> state;
template <typename Container1, typename Container2, typename Container3>
BOOST_CRYPT_GPU_ENABLED constexpr auto generate(Container1& data, const Container2& additional_data_1, const Container3& additional_data_2) noexcept -> state;
};
} // namespace drbg
} // namespace crypt
} // namespace boost
Configuration Macros
User Configurable Macros
-
BOOST_CRYPT_ENABLE_MD5
: Without this define#include <boost/crypt/hash/md5.hpp>
will issue a#error
because it is in-secure.
Automatic Configuration Macros
-
BOOST_CRYPT_HAS_STRING_VIEW
: This is defined when compiling with at least C++17 and your standard library has a complete implementation of<string_view>
. -
BOOST_CRYPT_HAS_SPAN
: This is defined when compiling with at least C++20 and your standard library has a complete implementation of<span>
. -
BOOST_CRYPT_HAS_CUDA
: This is defined when compiling with either NVCC or NVRTC regardless of the host compiler.
References
The following books, papers and blog posts serve as the basis for the algorithms used in the library:
-
Ronald L. Rivest, RFC 1321: The MD5 Message-Digest Algorithm, 1992
-
Donald E. Eastlake and Paul E. Jones, RFC 3174: US Secure Hash Algorithm 1 (SHA1), 2001
-
Donald E. Eastlake and Tony Hansen, RFC 6234: US Secure Hash Algorithms, 2011
-
National Institute of Standards and Technology (NIST), FIPS PUB 180-4: Secure Hash Standard (SHS), 2015
-
National Institute of Standards and Technology (NIST), FIPS PUB 140-3: Security Requirements for Cryptographic Modules, 2019
Copyright and License
This documentation is copyright 2024 Matt Borland and Chris Kormanyos and is distributed under the Boost Software License, Version 1.0.