Skip to content

Commit

Permalink
Add oneshot extended functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Jan 15, 2025
1 parent cbfdac6 commit 0dd0572
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
29 changes: 29 additions & 0 deletions include/boost/crypt2/hash/shake128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,35 @@ auto shake128(SizedRange&& data, OutputRange&& out) noexcept -> state
return hasher.get_digest(out);
}

[[nodiscard]] BOOST_CRYPT_EXPORT BOOST_CRYPT_GPU_ENABLED_CONSTEXPR
auto shake128(compat::span<const compat::byte> data, compat::span<compat::byte> out, compat::size_t amount) noexcept -> state
{
shake128_hasher hasher;
hasher.process_bytes(data);
hasher.finalize();
return hasher.get_digest(out, amount);
}

template <concepts::writable_output_range OutputRange>
[[nodiscard]] BOOST_CRYPT_EXPORT BOOST_CRYPT_GPU_ENABLED
auto shake128(compat::span<const compat::byte> data, OutputRange&& out, compat::size_t amount) noexcept -> state
{
shake128_hasher hasher;
hasher.process_bytes(data);
hasher.finalize();
return hasher.get_digest(out, amount);
}

template <compat::sized_range SizedRange, concepts::writable_output_range OutputRange>
[[nodiscard]] BOOST_CRYPT_EXPORT BOOST_CRYPT_GPU_ENABLED
auto shake128(SizedRange&& data, OutputRange&& out, compat::size_t amount) noexcept -> state
{
shake128_hasher hasher;
hasher.process_bytes(data);
hasher.finalize();
return hasher.get_digest(out, amount);
}

#if !BOOST_CRYPT_HAS_CUDA

template <concepts::file_system_path T>
Expand Down
29 changes: 29 additions & 0 deletions include/boost/crypt2/hash/shake256.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,35 @@ auto shake256(SizedRange&& data, OutputRange&& out) noexcept -> state
return hasher.get_digest(out);
}

[[nodiscard]] BOOST_CRYPT_EXPORT BOOST_CRYPT_GPU_ENABLED_CONSTEXPR
auto shake256(compat::span<const compat::byte> data, compat::span<compat::byte> out, std::size_t amount) noexcept -> state
{
shake256_hasher hasher;
hasher.process_bytes(data);
hasher.finalize();
return hasher.get_digest(out, amount);
}

template <concepts::writable_output_range OutputRange>
[[nodiscard]] BOOST_CRYPT_EXPORT BOOST_CRYPT_GPU_ENABLED
auto shake256(compat::span<const compat::byte> data, OutputRange&& out, std::size_t amount) noexcept -> state
{
shake256_hasher hasher;
hasher.process_bytes(data);
hasher.finalize();
return hasher.get_digest(out, amount);
}

template <compat::sized_range SizedRange, concepts::writable_output_range OutputRange>
[[nodiscard]] BOOST_CRYPT_EXPORT BOOST_CRYPT_GPU_ENABLED
auto shake256(SizedRange&& data, OutputRange&& out, std::size_t amount) noexcept -> state
{
shake256_hasher hasher;
hasher.process_bytes(data);
hasher.finalize();
return hasher.get_digest(out, amount);
}

#if !BOOST_CRYPT_HAS_CUDA

template <concepts::file_system_path T>
Expand Down

0 comments on commit 0dd0572

Please sign in to comment.