11 #ifndef __DECAF_SHAKE_HXX__
12 #define __DECAF_SHAKE_HXX__
16 #include <sys/types.h>
19 #if __cplusplus >= 201103L
20 #define DECAF_NOEXCEPT noexcept
21 #define DECAF_DELETE = delete
23 #define DECAF_NOEXCEPT throw()
126 static inline const struct decaf_kparams_s *get_params();
154 static inline const struct decaf_kparams_s *get_params();
158 #if __cplusplus >= 201103L
179 inline const struct decaf_kparams_s *SHAKE<128>::get_params() { return &DECAF_SHAKE128_params_s; }
180 inline const struct decaf_kparams_s *SHAKE<256>::get_params() {
return &DECAF_SHAKE256_params_s; }
181 inline const struct decaf_kparams_s *SHA3<224>::get_params() {
return &DECAF_SHA3_224_params_s; }
182 inline const struct decaf_kparams_s *SHA3<256>::get_params() {
return &DECAF_SHA3_256_params_s; }
183 inline const struct decaf_kparams_s *SHA3<384>::get_params() {
return &DECAF_SHA3_384_params_s; }
184 inline const struct decaf_kparams_s *SHA3<512>::get_params() {
return &DECAF_SHA3_512_params_s; }
188 template<>
inline const struct decaf_kparams_s *SHAKE<128>::get_params() {
return &DECAF_SHAKE128_params_s; }
189 template<>
inline const struct decaf_kparams_s *SHAKE<256>::get_params() {
return &DECAF_SHAKE256_params_s; }
190 template<>
inline const struct decaf_kparams_s *SHA3<224>::get_params() {
return &DECAF_SHA3_224_params_s; }
191 template<>
inline const struct decaf_kparams_s *SHA3<256>::get_params() {
return &DECAF_SHA3_256_params_s; }
192 template<>
inline const struct decaf_kparams_s *SHA3<384>::get_params() {
return &DECAF_SHA3_384_params_s; }
193 template<>
inline const struct decaf_kparams_s *SHA3<512>::get_params() {
return &DECAF_SHA3_512_params_s; }
200 #undef DECAF_NOEXCEPT
A reference to a block of data, which (when accessed through this base class) is const.
Definition: secure_buffer.hxx:159
size_t size() const DECAF_NOEXCEPT
Get the size.
Definition: secure_buffer.hxx:202
A reference to a writable block of data.
Definition: secure_buffer.hxx:264
const unsigned char * data() const DECAF_NOEXCEPT
Get const data.
Definition: secure_buffer.hxx:276
Hash function derived from Keccak FUTURE: throw ProtocolException when hash is misused by calling upd...
Definition: shake.hxx:34
SecureBuffer output()
Output the default number of bytes.
Definition: shake.hxx:106
void reset() DECAF_NOEXCEPT
Reset the hash to the empty string.
Definition: shake.hxx:116
SecureBuffer output(size_t len)
Output bytes from the sponge.
Definition: shake.hxx:58
~KeccakHash() DECAF_NOEXCEPT
Destructor zeroizes state.
Definition: shake.hxx:119
void update(const uint8_t *__restrict__ in, size_t len) DECAF_NOEXCEPT
Add more data to running hash.
Definition: shake.hxx:46
size_t default_output_size() const DECAF_NOEXCEPT
Return the sponge's default output size.
Definition: shake.hxx:96
void output(Buffer b)
Output bytes from the sponge.
Definition: shake.hxx:80
KeccakHash & operator<<(const Block &s) DECAF_NOEXCEPT
Add more data, stream version.
Definition: shake.hxx:52
size_t max_output_size() const DECAF_NOEXCEPT
Return the sponge's maximum output size.
Definition: shake.hxx:101
void update(const Block &s) DECAF_NOEXCEPT
Add more data to running hash, C++ version.
Definition: shake.hxx:49
KeccakHash & operator+=(const Block &s) DECAF_NOEXCEPT
Same as <<.
Definition: shake.hxx:55
An exception for when crypto (ie point decode) has failed.
Definition: secure_buffer.hxx:126
Fixed-output-length SHA3.
Definition: shake.hxx:123
SHA3() DECAF_NOEXCEPT
Initializer.
Definition: shake.hxx:136
static const size_t MAX_OUTPUT_BYTES
Number of bytes of output.
Definition: shake.hxx:130
static SecureBuffer hash(const Block &b, size_t nbytes=MAX_OUTPUT_BYTES)
Hash bytes with this SHA3 instance.
Definition: shake.hxx:141
static const size_t DEFAULT_OUTPUT_BYTES
Number of bytes of output.
Definition: shake.hxx:133
Variable-output-length SHAKE.
Definition: shake.hxx:151
static SecureBuffer hash(const Block &b, size_t outlen)
Hash bytes with this SHAKE instance.
Definition: shake.hxx:171
static const size_t DEFAULT_OUTPUT_BYTES
Default number of bytes to output.
Definition: shake.hxx:165
SHAKE() DECAF_NOEXCEPT
Initializer.
Definition: shake.hxx:168
static const size_t MAX_OUTPUT_BYTES
Number of bytes of output.
Definition: shake.hxx:161
@ DECAF_SUCCESS
The operation succeeded.
Definition: common.h:121
Namespace for all libdecaf C++ objects.
Definition: ed255.hxx:41
std::vector< unsigned char, SanitizingAllocator< unsigned char, 0 > > SecureBuffer
A variant of std::vector which securely zerozes its state when destructed.
Definition: secure_buffer.hxx:79
C++ self-zeroizing buffer.
void DECAF_API_VIS decaf_sha3_destroy(decaf_keccak_sponge_t sponge)
Destroy a DECAF_SHA3 or DECAF_SHAKE sponge context by overwriting it with 0.
size_t DECAF_API_VIS decaf_sha3_max_output_bytes(const decaf_keccak_sponge_t sponge)
Return the default output length of the sponge construction, for the purpose of C++ default operators...
struct decaf_keccak_sponge_s decaf_keccak_sponge_t[1]
Convenience GMP-style one-element array version.
Definition: shake.h:33
decaf_error_t DECAF_API_VIS decaf_sha3_update(struct decaf_keccak_sponge_s *__restrict__ sponge, const uint8_t *in, size_t len)
Absorb data into a DECAF_SHA3 or DECAF_SHAKE hash context.
decaf_error_t DECAF_API_VIS decaf_sha3_output(decaf_keccak_sponge_t sponge, uint8_t *__restrict__ out, size_t len)
Squeeze output data from a DECAF_SHA3 or DECAF_SHAKE hash context.
void DECAF_API_VIS decaf_sha3_init(decaf_keccak_sponge_t sponge, const struct decaf_kparams_s *params)
Initialize a sponge context object.
decaf_error_t DECAF_API_VIS decaf_sha3_final(decaf_keccak_sponge_t sponge, uint8_t *__restrict__ out, size_t len)
Squeeze output data from a DECAF_SHA3 or DECAF_SHAKE hash context.
size_t DECAF_API_VIS decaf_sha3_default_output_bytes(const decaf_keccak_sponge_t sponge)
Return the default output length of the sponge construction, for the purpose of C++ default operators...
void DECAF_API_VIS decaf_sha3_reset(decaf_keccak_sponge_t sponge)
Reset the sponge to the empty string.