** Skein block function constants (shared across Ref and Opt code)
******************************************************************/
enum {
- /* Skein_256 round rotation constants */
+ /* SKEIN_256 round rotation constants */
R_256_0_0 = 14, R_256_0_1 = 16,
R_256_1_0 = 52, R_256_1_1 = 57,
R_256_2_0 = 23, R_256_2_1 = 40,
R_256_6_0 = 58, R_256_6_1 = 22,
R_256_7_0 = 32, R_256_7_1 = 32,
- /* Skein_512 round rotation constants */
+ /* SKEIN_512 round rotation constants */
R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37,
R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42,
R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39,
R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43,
R_512_7_0 = 8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22,
- /* Skein1024 round rotation constants */
+ /* SKEIN_1024 round rotation constants */
R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 = 8, R1024_0_3 = 47,
R1024_0_4 = 8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37,
R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55,
* struct skein_ctx ctx; // a Skein hash or MAC context
*
* // prepare context, here for a Skein with a state size of 512 bits.
- * skein_ctx_prepare(&ctx, Skein512);
+ * skein_ctx_prepare(&ctx, SKEIN_512);
*
* // Initialize the context to set the requested hash length in bits
* // here request a output hash size of 31 bits (Skein supports variable
* Which Skein size to use
*/
enum skein_size {
- Skein256 = 256, /*!< Skein with 256 bit state */
- Skein512 = 512, /*!< Skein with 512 bit state */
- Skein1024 = 1024 /*!< Skein with 1024 bit state */
+ SKEIN_256 = 256, /*!< Skein with 256 bit state */
+ SKEIN_512 = 512, /*!< Skein with 512 bit state */
+ SKEIN_1024 = 1024 /*!< Skein with 1024 bit state */
};
/**
* functions.
*
@code
- // Threefish cipher context data
- struct threefish_key key_ctx;
+ // Threefish cipher context data
+ struct threefish_key key_ctx;
- // Initialize the context
- threefish_set_key(&key_ctx, Threefish512, key, tweak);
+ // Initialize the context
+ threefish_set_key(&key_ctx, THREEFISH_512, key, tweak);
- // Encrypt
- threefish_encrypt_block_bytes(&key_ctx, input, cipher);
+ // Encrypt
+ threefish_encrypt_block_bytes(&key_ctx, input, cipher);
@endcode
*/
* Which Threefish size to use
*/
enum threefish_size {
- Threefish256 = 256, /*!< Skein with 256 bit state */
- Threefish512 = 512, /*!< Skein with 512 bit state */
- Threefish1024 = 1024 /*!< Skein with 1024 bit state */
+ THREEFISH_256 = 256, /*!< Skein with 256 bit state */
+ THREEFISH_512 = 512, /*!< Skein with 512 bit state */
+ THREEFISH_1024 = 1024 /*!< Skein with 1024 bit state */
};
/**
* the save chaining variables.
*/
switch (ctx->skein_size) {
- case Skein256:
+ case SKEIN_256:
ret = skein_256_init_ext(&ctx->m.s256, hash_bit_len,
tree_info, NULL, 0);
break;
- case Skein512:
+ case SKEIN_512:
ret = skein_512_init_ext(&ctx->m.s512, hash_bit_len,
tree_info, NULL, 0);
break;
- case Skein1024:
+ case SKEIN_1024:
ret = skein_1024_init_ext(&ctx->m.s1024, hash_bit_len,
tree_info, NULL, 0);
break;
Skein_Assert(hash_bit_len, SKEIN_BAD_HASHLEN);
switch (ctx->skein_size) {
- case Skein256:
+ case SKEIN_256:
ret = skein_256_init_ext(&ctx->m.s256, hash_bit_len,
tree_info,
(const u8 *)key, key_len);
break;
- case Skein512:
+ case SKEIN_512:
ret = skein_512_init_ext(&ctx->m.s512, hash_bit_len,
tree_info,
(const u8 *)key, key_len);
break;
- case Skein1024:
+ case SKEIN_1024:
ret = skein_1024_init_ext(&ctx->m.s1024, hash_bit_len,
tree_info,
(const u8 *)key, key_len);
Skein_Assert(ctx, SKEIN_FAIL);
switch (ctx->skein_size) {
- case Skein256:
+ case SKEIN_256:
ret = skein_256_update(&ctx->m.s256, (const u8 *)msg,
msg_byte_cnt);
break;
- case Skein512:
+ case SKEIN_512:
ret = skein_512_update(&ctx->m.s512, (const u8 *)msg,
msg_byte_cnt);
break;
- case Skein1024:
+ case SKEIN_1024:
ret = skein_1024_update(&ctx->m.s1024, (const u8 *)msg,
msg_byte_cnt);
break;
Skein_Assert(ctx, SKEIN_FAIL);
switch (ctx->skein_size) {
- case Skein256:
+ case SKEIN_256:
ret = skein_256_final(&ctx->m.s256, (u8 *)hash);
break;
- case Skein512:
+ case SKEIN_512:
ret = skein_512_final(&ctx->m.s512, (u8 *)hash);
break;
- case Skein1024:
+ case SKEIN_1024:
ret = skein_1024_final(&ctx->m.s1024, (u8 *)hash);
break;
}
tweak[0] |= (words[1] & 0xffffffffL) << 32;
tweak[1] |= words[2] & 0xffffffffL;
- threefish_set_key(&key, Threefish256, ctx->X, tweak);
+ threefish_set_key(&key, THREEFISH_256, ctx->X, tweak);
/* get input block in little-endian format */
Skein_Get64_LSB_First(w, blk_ptr, SKEIN_256_STATE_WORDS);
tweak[0] |= (words[1] & 0xffffffffL) << 32;
tweak[1] |= words[2] & 0xffffffffL;
- threefish_set_key(&key, Threefish512, ctx->X, tweak);
+ threefish_set_key(&key, THREEFISH_512, ctx->X, tweak);
/* get input block in little-endian format */
Skein_Get64_LSB_First(w, blk_ptr, SKEIN_512_STATE_WORDS);
tweak[0] |= (words[1] & 0xffffffffL) << 32;
tweak[1] |= words[2] & 0xffffffffL;
- threefish_set_key(&key, Threefish1024, ctx->X, tweak);
+ threefish_set_key(&key, THREEFISH_1024, ctx->X, tweak);
/* get input block in little-endian format */
Skein_Get64_LSB_First(w, blk_ptr, SKEIN1024_STATE_WORDS);
#define DebugSaveTweak(ctx)
#endif
-/***************************** Skein_256 ******************************/
+/***************************** SKEIN_256 ******************************/
#if !(SKEIN_USE_ASM & 256)
void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr,
size_t blk_cnt, size_t byte_cnt_add)
#endif
#endif
-/***************************** Skein_512 ******************************/
+/***************************** SKEIN_512 ******************************/
#if !(SKEIN_USE_ASM & 512)
void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr,
size_t blk_cnt, size_t byte_cnt_add)
#endif
#endif
-/***************************** Skein1024 ******************************/
+/***************************** SKEIN_1024 ******************************/
#if !(SKEIN_USE_ASM & 1024)
void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr,
size_t blk_cnt, size_t byte_cnt_add)
u64 *out)
{
switch (key_ctx->state_size) {
- case Threefish256:
+ case THREEFISH_256:
threefish_encrypt_256(key_ctx, in, out);
break;
- case Threefish512:
+ case THREEFISH_512:
threefish_encrypt_512(key_ctx, in, out);
break;
- case Threefish1024:
+ case THREEFISH_1024:
threefish_encrypt_1024(key_ctx, in, out);
break;
}
u64 *out)
{
switch (key_ctx->state_size) {
- case Threefish256:
+ case THREEFISH_256:
threefish_decrypt_256(key_ctx, in, out);
break;
- case Threefish512:
+ case THREEFISH_512:
threefish_decrypt_512(key_ctx, in, out);
break;
- case Threefish1024:
+ case THREEFISH_1024:
threefish_decrypt_1024(key_ctx, in, out);
break;
}