6 * @file threefish_api.h
7 * @brief A Threefish cipher API and its functions.
10 * This API and the functions that implement this API simplify the usage
11 * of the Threefish cipher. The design and the way to use the functions
12 * follow the openSSL design but at the same time take care of some Threefish
13 * specific behaviour and possibilities.
15 * These are the low level functions that deal with Threefish blocks only.
16 * Implementations for cipher modes such as ECB, CFB, or CBC may use these
20 // Threefish cipher context data
21 struct threefish_key key_ctx;
23 // Initialize the context
24 threefish_set_key(&key_ctx, THREEFISH_512, key, tweak);
27 threefish_encrypt_block_bytes(&key_ctx, input, cipher);
31 #include <linux/types.h>
32 #include "skein_base.h"
34 #define KEY_SCHEDULE_CONST 0x1BD11BDAA9FC1A22L
37 * Which Threefish size to use
40 THREEFISH_256 = 256, /*!< Skein with 256 bit state */
41 THREEFISH_512 = 512, /*!< Skein with 512 bit state */
42 THREEFISH_1024 = 1024 /*!< Skein with 1024 bit state */
46 * Context for Threefish key and tweak words.
48 * This structure was setup with some know-how of the internal
49 * Skein structures, in particular ordering of header and size dependent
50 * variables. If Skein implementation changes this, the adapt these
53 struct threefish_key {
55 u64 key[SKEIN_MAX_STATE_WORDS+1]; /* max number of key words*/
60 * Set Threefish key and tweak data.
62 * This function sets the key and tweak data for the Threefish cipher of
63 * the given size. The key data must have the same length (number of bits)
67 * Pointer to a Threefish key structure.
69 * Which Skein size to use.
71 * Pointer to the key words (word has 64 bits).
73 * Pointer to the two tweak words (word has 64 bits).
75 void threefish_set_key(struct threefish_key *key_ctx,
76 enum threefish_size state_size,
77 u64 *key_data, u64 *tweak);
80 * Encrypt Threefish block (bytes).
82 * The buffer must have at least the same length (number of bits) as the
83 * state size for this key. The function uses the first @c state_size bits
84 * of the input buffer, encrypts them and stores the result in the output
88 * Pointer to a Threefish key structure.
90 * Poionter to plaintext data buffer.
92 * Pointer to cipher buffer.
94 void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in,
98 * Encrypt Threefish block (words).
100 * The buffer must have at least the same length (number of bits) as the
101 * state size for this key. The function uses the first @c state_size bits
102 * of the input buffer, encrypts them and stores the result in the output
105 * The wordsize ist set to 64 bits.
108 * Pointer to a Threefish key structure.
110 * Poionter to plaintext data buffer.
112 * Pointer to cipher buffer.
114 void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in,
118 * Decrypt Threefish block (bytes).
120 * The buffer must have at least the same length (number of bits) as the
121 * state size for this key. The function uses the first @c state_size bits
122 * of the input buffer, decrypts them and stores the result in the output
126 * Pointer to a Threefish key structure.
128 * Poionter to cipher data buffer.
130 * Pointer to plaintext buffer.
132 void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in,
136 * Decrypt Threefish block (words).
138 * The buffer must have at least the same length (number of bits) as the
139 * state size for this key. The function uses the first @c state_size bits
140 * of the input buffer, encrypts them and stores the result in the output
143 * The wordsize ist set to 64 bits.
146 * Pointer to a Threefish key structure.
148 * Poionter to cipher data buffer.
150 * Pointer to plaintext buffer.
152 void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in,
155 void threefish_encrypt_256(struct threefish_key *key_ctx, u64 *input,
157 void threefish_encrypt_512(struct threefish_key *key_ctx, u64 *input,
159 void threefish_encrypt_1024(struct threefish_key *key_ctx, u64 *input,
161 void threefish_decrypt_256(struct threefish_key *key_ctx, u64 *input,
163 void threefish_decrypt_512(struct threefish_key *key_ctx, u64 *input,
165 void threefish_decrypt_1024(struct threefish_key *key_ctx, u64 *input,