Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused variants of Skein #14708

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ dist_noinst_DATA += README.md RELEASES.md
dist_noinst_DATA += module/lua/README.zfs module/os/linux/spl/README.md

# Include all the extra licensing information for modules
dist_noinst_DATA += module/icp/algs/skein/THIRDPARTYLICENSE
dist_noinst_DATA += module/icp/algs/skein/THIRDPARTYLICENSE.descrip
dist_noinst_DATA += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman
dist_noinst_DATA += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman.descrip
dist_noinst_DATA += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl
Expand Down
161 changes: 40 additions & 121 deletions include/sys/skein.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
/*
* Interface declarations for Skein hashing.
* Source code author: Doug Whiting, 2008.
* This algorithm and source code is released to the public domain.
* CDDL HEADER START
*
* The following compile-time switches may be defined to control some
* tradeoffs between speed, code size, error checking, and security.
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* The "default" note explains what happens when the switch is not defined.
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or https://opensource.org/licenses/CDDL-1.0.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* SKEIN_DEBUG -- make callouts from inside Skein code
* to examine/display intermediate values.
* [default: no callouts (no overhead)]
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* 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
* CDDL HEADER END
*/
/* Copyright 2013 Doug Whiting. This code is released to the public domain. */
#ifndef _SYS_SKEIN_H_
#define _SYS_SKEIN_H_

/*
* Implementation of the Skein 512-bit hash function, based
* on the public domain implementation by Doug Whiting.
*
* Copyright (c) 2008,2013 Doug Whiting
*/

#ifndef _SYS_SKEIN_H
#define _SYS_SKEIN_H

#ifdef _KERNEL
#include <sys/types.h> /* get size_t definition */
#include <sys/types.h>
#else
#include <stdint.h>
#include <stdlib.h>
Expand All @@ -34,74 +40,34 @@
extern "C" {
#endif

enum {
SKEIN_SUCCESS = 0, /* return codes from Skein calls */
SKEIN_FAIL = 1,
SKEIN_BAD_HASHLEN = 2
};

#define SKEIN_MODIFIER_WORDS (2) /* number of modifier (tweak) words */

#define SKEIN_256_STATE_WORDS (4)
#define SKEIN_512_STATE_WORDS (8)
#define SKEIN1024_STATE_WORDS (16)
#define SKEIN_MAX_STATE_WORDS (16)

#define SKEIN_256_STATE_BYTES (8 * SKEIN_256_STATE_WORDS)
#define SKEIN_512_STATE_WORDS 8
#define SKEIN_512_STATE_BYTES (8 * SKEIN_512_STATE_WORDS)
#define SKEIN1024_STATE_BYTES (8 * SKEIN1024_STATE_WORDS)

#define SKEIN_256_STATE_BITS (64 * SKEIN_256_STATE_WORDS)
#define SKEIN_512_STATE_BITS (64 * SKEIN_512_STATE_WORDS)
#define SKEIN1024_STATE_BITS (64 * SKEIN1024_STATE_WORDS)

#define SKEIN_256_BLOCK_BYTES (8 * SKEIN_256_STATE_WORDS)
#define SKEIN_512_BLOCK_BYTES (8 * SKEIN_512_STATE_WORDS)
#define SKEIN1024_BLOCK_BYTES (8 * SKEIN1024_STATE_WORDS)

typedef struct {
size_t hashBitLen; /* size of hash result, in bits */
size_t bCnt; /* current byte count in buffer b[] */
/* tweak words: T[0]=byte cnt, T[1]=flags */
uint64_t T[SKEIN_MODIFIER_WORDS];
uint64_t T[2]; /* tweak words: T[0]=byte cnt, T[1]=flags */
} Skein_Ctxt_Hdr_t;

typedef struct { /* 256-bit Skein hash context structure */
Skein_Ctxt_Hdr_t h; /* common header context variables */
uint64_t X[SKEIN_256_STATE_WORDS]; /* chaining variables */
/* partial block buffer (8-byte aligned) */
uint8_t b[SKEIN_256_BLOCK_BYTES];
} Skein_256_Ctxt_t;

typedef struct { /* 512-bit Skein hash context structure */
Skein_Ctxt_Hdr_t h; /* common header context variables */
uint64_t X[SKEIN_512_STATE_WORDS]; /* chaining variables */
/* partial block buffer (8-byte aligned) */
uint8_t b[SKEIN_512_BLOCK_BYTES];
} Skein_512_Ctxt_t;

typedef struct { /* 1024-bit Skein hash context structure */
Skein_Ctxt_Hdr_t h; /* common header context variables */
uint64_t X[SKEIN1024_STATE_WORDS]; /* chaining variables */
/* partial block buffer (8-byte aligned) */
uint8_t b[SKEIN1024_BLOCK_BYTES];
} Skein1024_Ctxt_t;

/* Skein APIs for (incremental) "straight hashing" */
int Skein_256_Init(Skein_256_Ctxt_t *ctx, size_t hashBitLen);
int Skein_512_Init(Skein_512_Ctxt_t *ctx, size_t hashBitLen);
int Skein1024_Init(Skein1024_Ctxt_t *ctx, size_t hashBitLen);
} SKEIN_CTX;

int Skein_256_Update(Skein_256_Ctxt_t *ctx, const uint8_t *msg,
size_t msgByteCnt);
int Skein_512_Update(Skein_512_Ctxt_t *ctx, const uint8_t *msg,
size_t msgByteCnt);
int Skein1024_Update(Skein1024_Ctxt_t *ctx, const uint8_t *msg,
size_t msgByteCnt);
/* Skein APIs for (incremental) "straight hashing" */
extern void Skein_512_Init(SKEIN_CTX *ctx, size_t hashBitLen);
extern void Skein_512_Update(SKEIN_CTX *ctx, const uint8_t *msg, size_t cnt);
extern void Skein_512_Final(SKEIN_CTX *ctx, uint8_t *hashVal);

int Skein_256_Final(Skein_256_Ctxt_t *ctx, uint8_t *hashVal);
int Skein_512_Final(Skein_512_Ctxt_t *ctx, uint8_t *hashVal);
int Skein1024_Final(Skein1024_Ctxt_t *ctx, uint8_t *hashVal);
/*
* Skein APIs for MAC and tree hash:
* Final_Pad: pad, do final block, but no OUTPUT type
* Output: do just the output stage
*/
extern void Skein_512_Final_Pad(SKEIN_CTX *ctx, uint8_t *hashVal);

/*
* Skein APIs for "extended" initialization: MAC keys, tree hashing.
Expand All @@ -117,58 +83,11 @@ int Skein1024_Final(Skein1024_Ctxt_t *ctx, uint8_t *hashVal);
* to precompute the MAC IV, then a copy of the context saved and
* reused for each new MAC computation.
*/
int Skein_256_InitExt(Skein_256_Ctxt_t *ctx, size_t hashBitLen,
uint64_t treeInfo, const uint8_t *key, size_t keyBytes);
int Skein_512_InitExt(Skein_512_Ctxt_t *ctx, size_t hashBitLen,
extern void Skein_512_InitExt(SKEIN_CTX *ctx, size_t hashBitLen,
uint64_t treeInfo, const uint8_t *key, size_t keyBytes);
int Skein1024_InitExt(Skein1024_Ctxt_t *ctx, size_t hashBitLen,
uint64_t treeInfo, const uint8_t *key, size_t keyBytes);

/*
* Skein APIs for MAC and tree hash:
* Final_Pad: pad, do final block, but no OUTPUT type
* Output: do just the output stage
*/
int Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, uint8_t *hashVal);
int Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, uint8_t *hashVal);
int Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, uint8_t *hashVal);

#ifndef SKEIN_TREE_HASH
#define SKEIN_TREE_HASH (1)
#endif
#if SKEIN_TREE_HASH
int Skein_256_Output(Skein_256_Ctxt_t *ctx, uint8_t *hashVal);
int Skein_512_Output(Skein_512_Ctxt_t *ctx, uint8_t *hashVal);
int Skein1024_Output(Skein1024_Ctxt_t *ctx, uint8_t *hashVal);
#endif

/*
* When you initialize a Skein KCF hashing method you can pass this param
* structure in cm_param to fine-tune the algorithm's defaults.
*/
typedef struct skein_param {
size_t sp_digest_bitlen; /* length of digest in bits */
} skein_param_t;

/* Module definitions */
#ifdef SKEIN_MODULE_IMPL
#define CKM_SKEIN_256_MAC "CKM_SKEIN_256_MAC"
#define CKM_SKEIN_512_MAC "CKM_SKEIN_512_MAC"
#define CKM_SKEIN1024_MAC "CKM_SKEIN1024_MAC"

typedef enum skein_mech_type {
SKEIN_256_MAC_MECH_INFO_TYPE,
SKEIN_512_MAC_MECH_INFO_TYPE,
SKEIN1024_MAC_MECH_INFO_TYPE
} skein_mech_type_t;

#define VALID_SKEIN_MAC_MECH(__mech) \
((int)(__mech) >= SKEIN_256_MAC_MECH_INFO_TYPE && \
(__mech) <= SKEIN1024_MAC_MECH_INFO_TYPE)
#endif /* SKEIN_MODULE_IMPL */

#ifdef __cplusplus
}
#endif

#endif /* _SYS_SKEIN_H_ */
#endif /* _SYS_SKEIN_H */
1 change: 0 additions & 1 deletion lib/libicp/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ nodist_libicp_la_SOURCES = \
module/icp/algs/sha2/sha512_impl.c \
module/icp/algs/skein/skein.c \
module/icp/algs/skein/skein_block.c \
module/icp/algs/skein/skein_iv.c \
module/icp/illumos-crypto.c \
module/icp/io/aes.c \
module/icp/io/sha2_mod.c \
Expand Down
1 change: 0 additions & 1 deletion module/Kbuild.in
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ ICP_OBJS := \
algs/sha2/sha512_impl.o \
algs/skein/skein.o \
algs/skein/skein_block.o \
algs/skein/skein_iv.o \
api/kcf_cipher.o \
api/kcf_ctxops.o \
api/kcf_mac.o \
Expand Down
3 changes: 0 additions & 3 deletions module/icp/algs/skein/THIRDPARTYLICENSE

This file was deleted.

1 change: 0 additions & 1 deletion module/icp/algs/skein/THIRDPARTYLICENSE.descrip

This file was deleted.

Loading
Loading