skein_impl.h revision 45818ee124adeaaf947698996b4f4c722afc6d1f
/*
* Internal definitions for Skein hashing.
* Source code author: Doug Whiting, 2008.
* This algorithm and source code is released to the public domain.
*
* The following compile-time switches may be defined to control some
* tradeoffs between speed, code size, error checking, and security.
*
* The "default" note explains what happens when the switch is not defined.
*
* SKEIN_DEBUG -- make callouts from inside Skein code
* [default: no callouts (no overhead)]
*
* SKEIN_ERR_CHECK -- how error checking is handled inside Skein
* code. If not defined, most error checking
* is disabled (for performance). Otherwise,
* the switch value is interpreted as:
* 0: use assert() to flag errors
* 1: return SKEIN_FAIL to flag errors
*/
/* Copyright 2013 Doug Whiting. This code is released to the public domain. */
#ifndef _SKEIN_IMPL_H_
#define _SKEIN_IMPL_H_
#include "skein_impl.h"
#include "skein_port.h"
#ifdef _KERNEL
#else
#include <strings.h>
#endif
/*
* "Internal" Skein definitions
* -- not needed for sequential hashing API, but will be
* helpful for other uses of Skein (e.g., tree hash mode).
* -- included here so that they can be shared between
* reference and optimized code.
*/
/* tweak word T[1]: bit field starting positions */
/* offset 64 because it's the second word */
/* bits 112..118: level in hash tree */
/* bit 119: partial final input byte */
/* bits 120..125: type field */
/* bits 126: first block flag */
/* bit 127: final block flag */
/* tweak word T[1]: flag bit definition(s) */
/* tweak word T[1]: tree level bit field mask */
/* tweak word T[1]: block type field */
#define SKEIN_BLK_TYPE_KEY (0) /* key, for MAC and KDF */
#define SKEIN_T1_BLK_TYPE(T) \
/* key, for MAC and KDF */
/* configuration block */
/* personalization string */
/* public key (for digital signature hashing) */
/* key identifier for KDF */
/* nonce for PRNG */
/* message processing */
/* output stage */
/* field bit mask */
#define SKEIN_T1_BLK_TYPE_CFG_FINAL \
#define SKEIN_T1_BLK_TYPE_OUT_FINAL \
#define SKEIN_VERSION (1)
#ifndef SKEIN_ID_STRING_LE /* allow compile-time personalization */
#endif
/* bit field definitions in config block treeInfo word */
#define SKEIN_CFG_TREE_LEAF_SIZE_POS (0)
#define SKEIN_CFG_TREE_NODE_SIZE_POS (8)
#define SKEIN_CFG_TREE_MAX_LEVEL_POS (16)
#define SKEIN_CFG_TREE_LEAF_SIZE_MSK \
#define SKEIN_CFG_TREE_NODE_SIZE_MSK \
#define SKEIN_CFG_TREE_MAX_LEVEL_MSK \
/* use as treeInfo in InitExt() call for sequential processing */
#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0)
/*
*/
do { \
} while (0)
/* set both tweak words at once */
do { \
} while (0)
/*
* set up for starting with a new type: h.T[0]=0; h.T[1] = NEW_TYPE; h.bCnt=0;
*/
do { \
SKEIN_T1_BLK_TYPE_ ## BLK_TYPE); \
} while (0)
#define Skein_Clear_First_Flag(hdr) \
do { \
} while (0)
#define Skein_Set_Bit_Pad_Flag(hdr) \
do { \
} while (0)
do { \
} while (0)
/*
* "Internal" Skein definitions for debugging and error checking
* Note: in Illumos we always disable debugging features.
*/
/* run-time checks (e.g., bad params, uninitialized context)? */
#ifndef SKEIN_ERR_CHECK
/* default: ignore all Asserts, for performance */
#define Skein_Assert(x, retCode)
#define Skein_assert(x)
#elif defined(SKEIN_ASSERT)
#define Skein_assert(x) ASSERT(x)
#else
/* caller error */
#define Skein_Assert(x, retCode) \
do { \
if (!(x)) \
return (retCode); \
} while (0)
/* internal error */
#define Skein_assert(x) ASSERT(x)
#endif
/*
* Skein block function constants (shared across Ref and Opt code)
*/
enum {
/* Skein_256 round rotation constants */
/* Skein_512 round rotation constants */
/* Skein1024 round rotation constants */
};
/* number of rounds for the different block sizes */
#define SKEIN_256_ROUNDS_TOTAL (72)
#define SKEIN_512_ROUNDS_TOTAL (72)
#define SKEIN1024_ROUNDS_TOTAL (80)
extern const uint64_t SKEIN_256_IV_128[];
extern const uint64_t SKEIN_256_IV_160[];
extern const uint64_t SKEIN_256_IV_224[];
extern const uint64_t SKEIN_256_IV_256[];
extern const uint64_t SKEIN_512_IV_128[];
extern const uint64_t SKEIN_512_IV_160[];
extern const uint64_t SKEIN_512_IV_224[];
extern const uint64_t SKEIN_512_IV_256[];
extern const uint64_t SKEIN_512_IV_384[];
extern const uint64_t SKEIN_512_IV_512[];
extern const uint64_t SKEIN1024_IV_384[];
extern const uint64_t SKEIN1024_IV_512[];
extern const uint64_t SKEIN1024_IV_1024[];
#endif /* _SKEIN_IMPL_H_ */