/*
* Implementation of the Skein block functions.
* Source code author: Doug Whiting, 2008.
* This algorithm and source code is released to the public domain.
* Compile-time switches:
* SKEIN_USE_ASM -- set bits (256/512/1024) to select which
* versions use ASM code for block processing
* [default: use C for all block sizes]
*/
/* Copyright 2013 Doug Whiting. This code is released to the public domain. */
#include "skein_impl.h"
#ifndef SKEIN_USE_ASM
#endif
#ifndef SKEIN_LOOP
#endif
/* some useful definitions for code here */
#define KW_TWK_BASE (0)
/* no debugging in Illumos version */
/* Skein_256 */
#if !(SKEIN_USE_ASM & 256)
void
{ /* do it in C */
enum {
};
#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
#else
#define SKEIN_UNROLL_256 (0)
#endif
#if SKEIN_UNROLL_256
#if (RCNT % SKEIN_UNROLL_256)
#endif
size_t r;
/* key schedule words : chaining vars + tweak + "rotation" */
#else
#endif
/* local copy of context vars, for speed */
#ifdef SKEIN_DEBUG
/* use for debugging (help compiler put Xn in registers) */
#endif
do {
/*
* this implementation only supports 2**64 input bytes
* (no carry out here)
*/
/* precompute the key schedule for this block */
/* get input block in little-endian format */
Xptr); /* show starting state values */
/* run the rounds */
#if SKEIN_UNROLL_256 == 0
#define I256(R) \
#else /* looping version */
#define I256(R) \
/* loop thru it */
#endif
{
#define R256_8_rounds(R) \
I256(2 * (R)); \
R256_8_rounds(0);
(SKEIN_UNROLL_256 > (NN)))
#if R256_Unroll_R(1)
R256_8_rounds(1);
#endif
#if R256_Unroll_R(2)
R256_8_rounds(2);
#endif
#if R256_Unroll_R(3)
R256_8_rounds(3);
#endif
#if R256_Unroll_R(4)
R256_8_rounds(4);
#endif
#if R256_Unroll_R(5)
R256_8_rounds(5);
#endif
#if R256_Unroll_R(6)
R256_8_rounds(6);
#endif
#if R256_Unroll_R(7)
R256_8_rounds(7);
#endif
#if R256_Unroll_R(8)
R256_8_rounds(8);
#endif
#if R256_Unroll_R(9)
R256_8_rounds(9);
#endif
#if R256_Unroll_R(10)
R256_8_rounds(10);
#endif
#if R256_Unroll_R(11)
R256_8_rounds(11);
#endif
#if R256_Unroll_R(12)
R256_8_rounds(12);
#endif
#if R256_Unroll_R(13)
R256_8_rounds(13);
#endif
#if R256_Unroll_R(14)
R256_8_rounds(14);
#endif
#if (SKEIN_UNROLL_256 > 14)
#error "need more unrolling in Skein_256_Process_Block"
#endif
}
/*
* do the final "feedforward" xor, update context chaining vars
*/
}
while (--blkCnt);
}
#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF)
{
return ((uint8_t *)Skein_256_Process_Block_CodeSize) -
}
Skein_256_Unroll_Cnt(void)
{
return (SKEIN_UNROLL_256);
}
#endif
#endif
/* Skein_512 */
#if !(SKEIN_USE_ASM & 512)
void
{ /* do it in C */
enum {
};
#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
#else
#define SKEIN_UNROLL_512 (0)
#endif
#if SKEIN_UNROLL_512
#if (RCNT % SKEIN_UNROLL_512)
#endif
size_t r;
/* key schedule words : chaining vars + tweak + "rotation" */
#else
#endif
/* local copy of vars, for speed */
#ifdef SKEIN_DEBUG
/* use for debugging (help compiler put Xn in registers) */
#endif
do {
/*
* this implementation only supports 2**64 input bytes
* (no carry out here)
*/
/* precompute the key schedule for this block */
/* get input block in little-endian format */
Xptr);
/* run the rounds */
#if SKEIN_UNROLL_512 == 0
#define I512(R) \
#else /* looping version */
#define I512(R) \
/* loop thru it */
#endif /* end of looped code definitions */
{
I512(2 * (R)); \
R512_8_rounds(0);
(SKEIN_UNROLL_512 > (NN)))
#if R512_Unroll_R(1)
R512_8_rounds(1);
#endif
#if R512_Unroll_R(2)
R512_8_rounds(2);
#endif
#if R512_Unroll_R(3)
R512_8_rounds(3);
#endif
#if R512_Unroll_R(4)
R512_8_rounds(4);
#endif
#if R512_Unroll_R(5)
R512_8_rounds(5);
#endif
#if R512_Unroll_R(6)
R512_8_rounds(6);
#endif
#if R512_Unroll_R(7)
R512_8_rounds(7);
#endif
#if R512_Unroll_R(8)
R512_8_rounds(8);
#endif
#if R512_Unroll_R(9)
R512_8_rounds(9);
#endif
#if R512_Unroll_R(10)
R512_8_rounds(10);
#endif
#if R512_Unroll_R(11)
R512_8_rounds(11);
#endif
#if R512_Unroll_R(12)
R512_8_rounds(12);
#endif
#if R512_Unroll_R(13)
R512_8_rounds(13);
#endif
#if R512_Unroll_R(14)
R512_8_rounds(14);
#endif
#if (SKEIN_UNROLL_512 > 14)
#error "need more unrolling in Skein_512_Process_Block"
#endif
}
/*
* do the final "feedforward" xor, update context chaining vars
*/
}
while (--blkCnt);
}
#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF)
{
return ((uint8_t *)Skein_512_Process_Block_CodeSize) -
}
Skein_512_Unroll_Cnt(void)
{
return (SKEIN_UNROLL_512);
}
#endif
#endif
/* Skein1024 */
#if !(SKEIN_USE_ASM & 1024)
void
{
/* do it in C, always looping (unrolled is bigger AND slower!) */
enum {
};
#ifdef SKEIN_LOOP /* configure how much to unroll the loop */
#else
#define SKEIN_UNROLL_1024 (0)
#endif
#if (SKEIN_UNROLL_1024 != 0)
#if (RCNT % SKEIN_UNROLL_1024)
#endif
size_t r;
/* key schedule words : chaining vars + tweak + "rotation" */
#else
#endif
/* local copy of vars, for speed */
#ifdef SKEIN_DEBUG
/* use for debugging (help compiler put Xn in registers) */
#endif
do {
/*
* this implementation only supports 2**64 input bytes
* (no carry out here)
*/
/* precompute the key schedule for this block */
/* get input block in little-endian format */
Xptr);
#if SKEIN_UNROLL_1024 == 0
#define I1024(R) \
#else /* looping version */
#define I1024(R) \
/* loop thru it */
#endif
{
I1024(2 * (R)); \
R1024_8_rounds(0);
(SKEIN_UNROLL_1024 > (NN)))
#if R1024_Unroll_R(1)
R1024_8_rounds(1);
#endif
#if R1024_Unroll_R(2)
R1024_8_rounds(2);
#endif
#if R1024_Unroll_R(3)
R1024_8_rounds(3);
#endif
#if R1024_Unroll_R(4)
R1024_8_rounds(4);
#endif
#if R1024_Unroll_R(5)
R1024_8_rounds(5);
#endif
#if R1024_Unroll_R(6)
R1024_8_rounds(6);
#endif
#if R1024_Unroll_R(7)
R1024_8_rounds(7);
#endif
#if R1024_Unroll_R(8)
R1024_8_rounds(8);
#endif
#if R1024_Unroll_R(9)
R1024_8_rounds(9);
#endif
#if R1024_Unroll_R(10)
R1024_8_rounds(10);
#endif
#if R1024_Unroll_R(11)
R1024_8_rounds(11);
#endif
#if R1024_Unroll_R(12)
R1024_8_rounds(12);
#endif
#if R1024_Unroll_R(13)
R1024_8_rounds(13);
#endif
#if R1024_Unroll_R(14)
R1024_8_rounds(14);
#endif
#if (SKEIN_UNROLL_1024 > 14)
#error "need more unrolling in Skein_1024_Process_Block"
#endif
}
/*
* do the final "feedforward" xor, update context chaining vars
*/
} while (--blkCnt);
}
#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF)
{
return ((uint8_t *)Skein1024_Process_Block_CodeSize) -
}
Skein1024_Unroll_Cnt(void)
{
return (SKEIN_UNROLL_1024);
}
#endif
#endif