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 Threefisch 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 keyCtx;
23 // Initialize the context
24 threefishSetKey(&keyCtx, Threefish512, key, tweak);
27 threefishEncryptBlockBytes(&keyCtx, input, cipher);
31 #include <linux/types.h>
34 #define KeyScheduleConst 0x1BD11BDAA9FC1A22L
37 * Which Threefish size to use
40 Threefish256 = 256, /*!< Skein with 256 bit state */
41 Threefish512 = 512, /*!< Skein with 512 bit state */
42 Threefish1024 = 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 threefishSetKey(struct threefish_key *keyCtx,
76 enum threefish_size stateSize,
77 u64 *keyData, u64 *tweak);
80 * Encrypt Threefisch block (bytes).
82 * The buffer must have at least the same length (number of bits) aas the
83 * state size for this key. The function uses the first @c stateSize 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 threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out);
97 * Encrypt Threefisch block (words).
99 * The buffer must have at least the same length (number of bits) aas the
100 * state size for this key. The function uses the first @c stateSize bits
101 * of the input buffer, encrypts them and stores the result in the output
104 * The wordsize ist set to 64 bits.
107 * Pointer to a Threefish key structure.
109 * Poionter to plaintext data buffer.
111 * Pointer to cipher buffer.
113 void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in,
117 * Decrypt Threefisch block (bytes).
119 * The buffer must have at least the same length (number of bits) aas the
120 * state size for this key. The function uses the first @c stateSize bits
121 * of the input buffer, decrypts them and stores the result in the output
125 * Pointer to a Threefish key structure.
127 * Poionter to cipher data buffer.
129 * Pointer to plaintext buffer.
131 void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out);
134 * Decrypt Threefisch block (words).
136 * The buffer must have at least the same length (number of bits) aas the
137 * state size for this key. The function uses the first @c stateSize bits
138 * of the input buffer, encrypts them and stores the result in the output
141 * The wordsize ist set to 64 bits.
144 * Pointer to a Threefish key structure.
146 * Poionter to cipher data buffer.
148 * Pointer to plaintext buffer.
150 void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in,
153 void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output);
154 void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output);
155 void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input,
157 void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output);
158 void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output);
159 void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input,