1 #ifndef _library__skein__hpp__included__
2 #define _library__skein__hpp__included__
11 * Skein hash function (v1.3).
16 * Variant to use (256-bit, 512-bit, 1024-bit)
18 enum variant
{ PIPE_256
, PIPE_512
, PIPE_1024
};
20 * Data type for piece of data.
25 T_PERSONALIZATION
= 8,
32 * Create a new hash state.
34 * Parameter v: The variant to use.
35 * Parameter outbits: Number of output bits.
36 * Throws std::runtime_error: Variant is invalid.
38 hash(variant v
, uint64_t outbits
) throw(std::runtime_error
);
44 * Write data to be hashed.
46 * Parameter data: The data to append.
47 * Parameter datalen: Number of bytes in data.
48 * Parameter type: The data type. Must be monotonically increasing.
49 * Throws std::runtime_error: Types not monotonic, or invalid type.
51 * Note: Data types 4 (CONFIG) and 63 (OUTPUT) are not allowed.
53 void write(const uint8_t* data
, size_t datalen
, datatype type
= T_MESSAGE
) throw(std::runtime_error
);
55 * Read the output hash.
57 * Parameter output: Buffer to store the output to.
59 void read(uint8_t* output
) throw();
61 * Read partial output hash.
63 * Parameter output: Buffer to store the output to.
64 * Parameter startblock: The block number (each block is 256/512/1024 bits depending on variant) to start from.
65 * Parameter bits: Number of bits to output.
67 void read_partial(uint8_t* output
, uint64_t startblock
, uint64_t bits
) throw();
69 void typechange(uint8_t newtype
);
71 void flush_buffer(uint8_t type
, bool final
);
74 void (*compress
)(uint64_t* out
, const uint64_t* data
, const uint64_t* key
, const uint64_t* tweak
);
92 * Note: To seed the PRNG, write the initial seed there.
96 * (Re)seed the PRNG and mark it seeded.
98 * Parameter buffer: Buffer to read the seed from.
99 * Parameter size: Number of bytes in seed.
101 void write(const void* buffer
, size_t size
) throw();
103 * Read data from PRNG.
105 * Parameter buffer: Buffer to write the data to.
106 * Parameter size: Number of random bytes to write.
107 * Throws std::runtime_error: Generator is not seeded.
109 void read(void* buffer
, size_t size
) throw(std::runtime_error
);
113 bool is_seeded() const throw();
120 * Zeroize a block of memory.
122 * Parameter ptr: Pointer to start of block.
123 * Parameter size: Size of block to zeroize.
125 void zeroize(void* ptr
, size_t size
);