#ifndef _THREEFISHAPI_H_ #define _THREEFISHAPI_H_ /** * @file threefishApi.h * @brief A Threefish cipher API and its functions. * @{ * * This API and the functions that implement this API simplify the usage * of the Threefish cipher. The design and the way to use the functions * follow the openSSL design but at the same time take care of some Threefish * specific behaviour and possibilities. * * These are the low level functions that deal with Threefisch blocks only. * Implementations for cipher modes such as ECB, CFB, or CBC may use these * functions. * @code // Threefish cipher context data ThreefishKey512_t keyCtx; // Initialize the context threefishSetKey(&keyCtx, Threefish512, key, tweak); // Encrypt threefishEncryptBlockBytes(&keyCtx, input, cipher); @endcode */ #include #define KeyScheduleConst 0x1BD11BDAA9FC1A22L #ifdef __cplusplus extern "C" { #endif /** * Context for Threefish key and tweak words. * * This structure was setup with some know-how of the internal * Skein structures, in particular ordering of header and size dependent * variables. If Skein implementation changes this, the adapt these * structures as well. */ typedef struct ThreefishKey512 { uint64_t key[(512/64)+1]; /* + parity */ uint64_t tweak[3]; } ThreefishKey512_t; /** * Set Threefish key and tweak data. * * This function sets the key and tweak data for the Threefish cipher of * the given size. The key data must have the same length (number of bits) * as the state size * * @param keyCtx * Pointer to a Threefish key structure. * @param keyData * Pointer to the key words (word has 64 bits). * @param tweak * Pointer to the two tweak words (word has 64 bits). */ void threefishSetKey512(ThreefishKey512_t *keyCtx, uint64_t *keyData, uint64_t *tweak); void threefishEncrypt512(ThreefishKey512_t *keyCtx, uint64_t *input, uint64_t *output); void threefishDecrypt512(ThreefishKey512_t* keyCtx, uint64_t* input, uint64_t* output); #ifdef __cplusplus } #endif /** * @} */ #endif