Annotate noexcept and constexpr with HEDLEY, and add interval containment, ChaCha, and the dyadic range tables.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
875f09fec1
commit
0d8a5a8131
97 changed files with 9212 additions and 1159 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "hedley/hedley.h"
|
||||
#include "simde/simde/x86/avx2.h"
|
||||
|
|
@ -103,15 +104,21 @@ HEDLEY_PRAGMA(GCC diagnostic pop)
|
|||
/// `eval` / `eval01` (`set_epi64x(0, pos)`). The first AddRoundKey
|
||||
/// includes `rd_key[0]` so this matches the one-block `eval` for any
|
||||
/// key, not only the all-zero key this PRG currently installs.
|
||||
HEDLEY_NO_THROW
|
||||
HEDLEY_ALWAYS_INLINE
|
||||
static void eval(block_type seed, block_type * HEDLEY_RESTRICT output,
|
||||
psnip_uint32_t count, psnip_uint32_t pos = 0) noexcept
|
||||
psnip_uint32_t count, psnip_uint32_t pos = 0)
|
||||
{
|
||||
if (HEDLEY_UNLIKELY(count == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// `pos + i` is a uint32 add. A span that passes UINT32_MAX must
|
||||
// fail the same way buffered_prg does, rather than wrap to 0.
|
||||
if (count > 1 &&
|
||||
pos > static_cast<psnip_uint32_t>(~static_cast<psnip_uint32_t>(0)) - (count - 1u))
|
||||
{
|
||||
throw std::invalid_argument("prg lane index is out of range");
|
||||
}
|
||||
|
||||
require_block_aligned(output);
|
||||
block_type * HEDLEY_RESTRICT out =
|
||||
|
|
@ -161,6 +168,7 @@ HEDLEY_PRAGMA(GCC diagnostic pop)
|
|||
/// `left[i] == eval(seeds[i], 0)`, `right[i] == eval(seeds[i], 1)`.
|
||||
HEDLEY_NO_THROW
|
||||
HEDLEY_ALWAYS_INLINE
|
||||
HEDLEY_NON_NULL(1, 2, 3)
|
||||
static void eval01_x4(const block_type * HEDLEY_RESTRICT seeds,
|
||||
block_type * HEDLEY_RESTRICT left,
|
||||
block_type * HEDLEY_RESTRICT right) noexcept
|
||||
|
|
@ -193,6 +201,7 @@ HEDLEY_PRAGMA(GCC diagnostic pop)
|
|||
/// Four independent `eval(seed, pos)` as one 4-block round-major AES.
|
||||
HEDLEY_NO_THROW
|
||||
HEDLEY_ALWAYS_INLINE
|
||||
HEDLEY_NON_NULL(1, 2)
|
||||
static void eval_x4(const block_type * HEDLEY_RESTRICT seeds,
|
||||
block_type * HEDLEY_RESTRICT output, psnip_uint32_t pos) noexcept
|
||||
{
|
||||
|
|
@ -223,6 +232,7 @@ HEDLEY_PRAGMA(GCC diagnostic pop)
|
|||
/// Eight independent `eval(seed, pos)` as one 8-block round-major AES.
|
||||
HEDLEY_NO_THROW
|
||||
HEDLEY_ALWAYS_INLINE
|
||||
HEDLEY_NON_NULL(1, 2)
|
||||
static void eval_x8(const block_type * HEDLEY_RESTRICT seeds,
|
||||
block_type * HEDLEY_RESTRICT output, psnip_uint32_t pos) noexcept
|
||||
{
|
||||
|
|
@ -252,6 +262,7 @@ HEDLEY_PRAGMA(GCC diagnostic pop)
|
|||
|
||||
/// Raw-bit subtractive share of `T` for party `Party` (see `prg.hpp`).
|
||||
template <typename T, std::size_t Party>
|
||||
HEDLEY_NO_THROW
|
||||
static auto expand(block_type seed, psnip_uint32_t pos = 0) noexcept;
|
||||
|
||||
private:
|
||||
|
|
@ -261,6 +272,7 @@ HEDLEY_PRAGMA(GCC diagnostic pop)
|
|||
/// rounds 1..last and the MMO feed-forward `XOR seed[i]`.
|
||||
HEDLEY_NO_THROW
|
||||
HEDLEY_ALWAYS_INLINE
|
||||
HEDLEY_NON_NULL(1, 2)
|
||||
static void aes_mmo_rounds_x4(block_type * HEDLEY_RESTRICT blk,
|
||||
const block_type * HEDLEY_RESTRICT seed) noexcept
|
||||
{
|
||||
|
|
@ -283,6 +295,7 @@ HEDLEY_PRAGMA(GCC unroll(14))
|
|||
|
||||
HEDLEY_NO_THROW
|
||||
HEDLEY_ALWAYS_INLINE
|
||||
HEDLEY_NON_NULL(1, 2)
|
||||
static void aes_mmo_rounds_x8(block_type * HEDLEY_RESTRICT blk,
|
||||
const block_type * HEDLEY_RESTRICT seed) noexcept
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue