Skip to content
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: 1 addition & 1 deletion external/cddl/osnet/dist/uts/common/fs/zfs/skein_zfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <sys/zfs_context.h>
#include <sys/zio.h>
#ifdef _KERNEL
#include <crypto/skein/skein.h>
#include <sys/skein.h>
#else
#include <skein.h>
#endif
Expand Down
55 changes: 55 additions & 0 deletions external/cddl/osnet/dist/uts/common/fs/zfs/sys/lz4.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* LZ4 - Fast LZ compression algorithm
* Header File
* BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* You can contact the author at :
* - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
* - LZ4 source repository : http://code.google.com/p/lz4/
*/

#ifndef _LZ4_H
#define _LZ4_H

#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif

extern size_t lz4_compress(void *, void *, size_t, size_t, int);
extern int lz4_decompress(void *, void *, size_t, size_t, int);

#if defined(_KERNEL) || defined(_FAKE_KERNEL)
extern void lz4_init(void);
extern void lz4_fini(void);
#endif

#ifdef __cplusplus
}
#endif

#endif /* _LZ4_H */
183 changes: 183 additions & 0 deletions external/cddl/osnet/dist/uts/common/fs/zfs/sys/skein.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
/*
* Interface declarations 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
* to examine/display intermediate values.
* [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 _SYS_SKEIN_H_
#define _SYS_SKEIN_H_

#ifdef _KERNEL
#include <sys/types.h> /* get size_t definition */
#else
#include <sys/stdint.h>
#include <sys/stdlib.h>
#endif

#ifdef __cplusplus
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_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];
} 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);

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);

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 "extended" initialization: MAC keys, tree hashing.
* After an InitExt() call, just use Update/Final calls as with Init().
*
* Notes: Same parameters as _Init() calls, plus treeInfo/key/keyBytes.
* When keyBytes == 0 and treeInfo == SKEIN_SEQUENTIAL,
* the results of InitExt() are identical to calling Init().
* The function Init() may be called once to "precompute" the IV for
* a given hashBitLen value, then by saving a copy of the context
* the IV computation may be avoided in later calls.
* Similarly, the function InitExt() may be called once per MAC key
* 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,
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 "CKM_SKEIN_256"
#define CKM_SKEIN_512 "CKM_SKEIN_512"
#define CKM_SKEIN1024 "CKM_SKEIN1024"
#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_MECH_INFO_TYPE,
SKEIN_512_MECH_INFO_TYPE,
SKEIN1024_MECH_INFO_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_DIGEST_MECH(__mech) \
((int)(__mech) >= SKEIN_256_MECH_INFO_TYPE && \
(__mech) <= SKEIN1024_MECH_INFO_TYPE)
#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_ */
59 changes: 59 additions & 0 deletions external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_bootenv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/

/*
* Copyright 2020 Toomas Soome <tsoome@me.com>
*/

#ifndef _ZFS_BOOTENV_H
#define _ZFS_BOOTENV_H

/*
* Define macros for label bootenv nvlist pair keys.
*/

#ifdef __cplusplus
extern "C" {
#endif

#define BOOTENV_VERSION "version"

#define BE_ILLUMOS_VENDOR "illumos"

#ifdef __NETBSDBSD__
#define BE_NETBSD_VENDOR "netbsd"

#ifdef __FreeBSD__
#define BE_FREEBSD_VENDOR "freebsd"

#define BE_GRUB_VENDOR "grub"
#define BE_LINUX_VENDOR "linux"

#include "zfs_bootenv_os.h"

#define GRUB_ENVMAP BE_GRUB_VENDOR ":" "envmap"

#define NETBSD_BOOTONCE BE_NETBSD_VENDOR ":" "bootonce"
#define NETBSD_BOOTONCE_USED BE_NETBSD_VENDOR ":" "bootonce-used"
#define NETBSD_NVSTORE BE_NETBSD_VENDOR ":" "nvstore"
#define ILLUMOS_BOOTONCE BE_ILLUMOS_VENDOR ":" "bootonce"
#define ILLUMOS_BOOTONCE_USED BE_ILLUMOS_VENDOR ":" "bootonce-used"
#define ILLUMOS_NVSTORE BE_ILLUMOS_VENDOR ":" "nvstore"

#define OS_BOOTONCE BOOTENV_OS ":" "bootonce"
#define OS_BOOTONCE_USED BOOTENV_OS ":" "bootonce-used"
#define OS_NVSTORE BOOTENV_OS ":" "nvstore"

#ifdef __cplusplus
}
#endif

#endif /* _ZFS_BOOTENV_H */
33 changes: 33 additions & 0 deletions external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_bootenv_os.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/

/*
* Copyright 2020 Toomas Soome <tsoome@me.com>
*/

#ifndef _ZFS_BOOTENV_OS_H
#define _ZFS_BOOTENV_OS_H

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __FreeBSD__
#define BOOTENV_OS BE_FREEBSD_VENDOR

#ifdef __NetBSD__
#define BOOTENV_OS BE_NETBSD_VENDOR

#ifdef __cplusplus
}
#endif

#endif /* _ZFS_BOOTENV_OS_H */
Loading