Changeset View
Changeset View
Standalone View
Standalone View
sys/crypto/skein/skein_block.c
/*********************************************************************** | /*********************************************************************** | ||||
** | ** | ||||
** Implementation of the Skein block functions. | ** Implementation of the Skein block functions. | ||||
** | ** | ||||
** Source code author: Doug Whiting, 2008. | ** Source code author: Doug Whiting, 2008. | ||||
** | ** | ||||
** This algorithm and source code is released to the public domain. | ** This algorithm and source code is released to the public domain. | ||||
** | ** | ||||
** Compile-time switches: | ** Compile-time switches: | ||||
** | ** | ||||
** SKEIN_USE_ASM -- set bits (256/512/1024) to select which | ** SKEIN_USE_ASM -- set bits (256/512/1024) to select which | ||||
** versions use ASM code for block processing | ** versions use ASM code for block processing | ||||
** [default: use C for all block sizes] | ** [default: use C for all block sizes] | ||||
** | ** | ||||
************************************************************************/ | ************************************************************************/ | ||||
#include <sys/cdefs.h> | |||||
__FBSDID("$FreeBSD$"); | |||||
#include <sys/endian.h> | |||||
#include <sys/types.h> | |||||
#ifdef _KERNEL | |||||
#include <sys/systm.h> | |||||
#else | |||||
#include <string.h> | #include <string.h> | ||||
#endif | |||||
#include "skein.h" | #include "skein.h" | ||||
#ifndef SKEIN_USE_ASM | #ifndef SKEIN_USE_ASM | ||||
#define SKEIN_USE_ASM (0) /* default is all C code (no ASM) */ | #define SKEIN_USE_ASM (0) /* default is all C code (no ASM) */ | ||||
#endif | #endif | ||||
#ifndef SKEIN_LOOP | #ifndef SKEIN_LOOP | ||||
#define SKEIN_LOOP 001 /* default: unroll 256 and 512, but not 1024 */ | #define SKEIN_LOOP 001 /* default: unroll 256 and 512, but not 1024 */ | ||||
#endif | #endif | ||||
#define BLK_BITS (WCNT*64) /* some useful definitions for code here */ | #define BLK_BITS (WCNT*64) /* some useful definitions for code here */ | ||||
#define KW_TWK_BASE (0) | #define KW_TWK_BASE (0) | ||||
#define KW_KEY_BASE (3) | #define KW_KEY_BASE (3) | ||||
#define ks (kw + KW_KEY_BASE) | #define ks (kw + KW_KEY_BASE) | ||||
#define ts (kw + KW_TWK_BASE) | #define ts (kw + KW_TWK_BASE) | ||||
#ifdef SKEIN_DEBUG | #ifdef SKEIN_DEBUG | ||||
#define DebugSaveTweak(ctx) { ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } | #define DebugSaveTweak(ctx) { ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } | ||||
#else | #else | ||||
#define DebugSaveTweak(ctx) | #define DebugSaveTweak(ctx) | ||||
#endif | #endif | ||||
/*****************************************************************/ | |||||
/* functions to process blkCnt (nonzero) full block(s) of data. */ | |||||
void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd); | |||||
void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd); | |||||
void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd); | |||||
/***************************** Skein_256 ******************************/ | /***************************** Skein_256 ******************************/ | ||||
#if !(SKEIN_USE_ASM & 256) | #if !(SKEIN_USE_ASM & 256) | ||||
void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd) | void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd) | ||||
{ /* do it in C */ | { /* do it in C */ | ||||
enum | enum | ||||
{ | { | ||||
WCNT = SKEIN_256_STATE_WORDS | WCNT = SKEIN_256_STATE_WORDS | ||||
▲ Show 20 Lines • Show All 643 Lines • Show Last 20 Lines |