Author: allanjude Date: Tue May 31 04:12:14 2016 New Revision: 301010 URL: https://svnweb.freebsd.org/changeset/base/301010
Log: Connect the SHA-512t256 and Skein hashing algorithms to ZFS Support for the new hashing algorithms in ZFS was introduced in r289422 However it was disconnected because FreeBSD lacked implementations of SHA-512 (truncated to 256 bits), and Skein. These implementations were introduced in r300921 and r300966 respectively This commit connects them to ZFS and enabled these new checksum algorithms This new algorithms are not supported by the boot blocks, so do not use them on your root dataset if you boot from ZFS. Relnotes: yes Sponsored by: ScaleEngine Inc. Modified: head/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c head/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h head/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sha256.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/skein_zfs.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_checksum.h head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c head/sys/conf/files head/sys/crypto/skein/skein_port.h head/sys/modules/zfs/Makefile Modified: head/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c Tue May 31 04:10:15 2016 (r301009) +++ head/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c Tue May 31 04:12:14 2016 (r301010) @@ -232,8 +232,6 @@ zpool_feature_init(void) "org.open-zfs:large_blocks", "large_blocks", "Support for blocks larger than 128KB.", ZFEATURE_FLAG_PER_DATASET, large_blocks_deps); - -#ifdef illumos zfeature_register(SPA_FEATURE_SHA512, "org.illumos:sha512", "sha512", "SHA-512/256 hash algorithm.", @@ -242,6 +240,8 @@ zpool_feature_init(void) "org.illumos:skein", "skein", "Skein hash algorithm.", ZFEATURE_FLAG_PER_DATASET, NULL); + +#ifdef illumos zfeature_register(SPA_FEATURE_EDONR, "org.illumos:edonr", "edonr", "Edon-R hash algorithm.", Modified: head/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h Tue May 31 04:10:15 2016 (r301009) +++ head/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h Tue May 31 04:12:14 2016 (r301010) @@ -52,9 +52,9 @@ typedef enum spa_feature { SPA_FEATURE_BOOKMARKS, SPA_FEATURE_FS_SS_LIMIT, SPA_FEATURE_LARGE_BLOCKS, -#ifdef illumos SPA_FEATURE_SHA512, SPA_FEATURE_SKEIN, +#ifdef illumos SPA_FEATURE_EDONR, #endif SPA_FEATURES Modified: head/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c Tue May 31 04:10:15 2016 (r301009) +++ head/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c Tue May 31 04:12:14 2016 (r301010) @@ -72,9 +72,9 @@ zfs_prop_init(void) { "fletcher4", ZIO_CHECKSUM_FLETCHER_4 }, { "sha256", ZIO_CHECKSUM_SHA256 }, { "noparity", ZIO_CHECKSUM_NOPARITY }, -#ifdef illumos { "sha512", ZIO_CHECKSUM_SHA512 }, { "skein", ZIO_CHECKSUM_SKEIN }, +#ifdef illumos { "edonr", ZIO_CHECKSUM_EDONR }, #endif { NULL } @@ -87,13 +87,13 @@ zfs_prop_init(void) { "sha256", ZIO_CHECKSUM_SHA256 }, { "sha256,verify", ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY }, -#ifdef illumos { "sha512", ZIO_CHECKSUM_SHA512 }, { "sha512,verify", ZIO_CHECKSUM_SHA512 | ZIO_CHECKSUM_VERIFY }, { "skein", ZIO_CHECKSUM_SKEIN }, { "skein,verify", ZIO_CHECKSUM_SKEIN | ZIO_CHECKSUM_VERIFY }, +#ifdef illumos { "edonr,verify", ZIO_CHECKSUM_EDONR | ZIO_CHECKSUM_VERIFY }, #endif Modified: head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files Tue May 31 04:10:15 2016 (r301009) +++ head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files Tue May 31 04:12:14 2016 (r301010) @@ -74,6 +74,7 @@ ZFS_COMMON_OBJS += \ rrwlock.o \ sa.o \ sha256.o \ + skein_zfs.o \ spa.o \ spa_config.o \ spa_errlog.o \ Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sha256.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sha256.c Tue May 31 04:10:15 2016 (r301009) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sha256.c Tue May 31 04:12:14 2016 (r301010) @@ -29,8 +29,10 @@ #include <sys/zio.h> #ifdef _KERNEL #include <crypto/sha2/sha256.h> +#include <crypto/sha2/sha512t.h> #else #include <sha256.h> +#include <sha512t.h> #endif /*ARGSUSED*/ @@ -58,17 +60,16 @@ zio_checksum_SHA256(const void *buf, uin zcp->zc_word[3] = BE_64(tmp.zc_word[3]); } -#ifdef illumos /*ARGSUSED*/ void zio_checksum_SHA512_native(const void *buf, uint64_t size, const void *ctx_template, zio_cksum_t *zcp) { - SHA2_CTX ctx; + SHA512_CTX ctx; - SHA2Init(SHA512_256, &ctx); - SHA2Update(&ctx, buf, size); - SHA2Final(zcp, &ctx); + SHA512_256_Init(&ctx); + SHA512_256_Update(&ctx, buf, size); + SHA512_256_Final((unsigned char *)zcp, &ctx); } /*ARGSUSED*/ @@ -84,4 +85,3 @@ zio_checksum_SHA512_byteswap(const void zcp->zc_word[2] = BSWAP_64(tmp.zc_word[2]); zcp->zc_word[3] = BSWAP_64(tmp.zc_word[3]); } -#endif Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/skein_zfs.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/skein_zfs.c Tue May 31 04:10:15 2016 (r301009) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/skein_zfs.c Tue May 31 04:12:14 2016 (r301010) @@ -23,7 +23,11 @@ */ #include <sys/zfs_context.h> #include <sys/zio.h> -#include <sys/skein.h> +#ifdef _KERNEL +#include <crypto/skein/skein.h> +#else +#include <skein.h> +#endif /* * Computes a native 256-bit skein MAC checksum. Please note that this Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Tue May 31 04:10:15 2016 (r301009) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Tue May 31 04:12:14 2016 (r301010) @@ -82,9 +82,9 @@ enum zio_checksum { ZIO_CHECKSUM_SHA256, ZIO_CHECKSUM_ZILOG2, ZIO_CHECKSUM_NOPARITY, -#ifdef illumos ZIO_CHECKSUM_SHA512, ZIO_CHECKSUM_SKEIN, +#ifdef illumos ZIO_CHECKSUM_EDONR, #endif ZIO_CHECKSUM_FUNCTIONS Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_checksum.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_checksum.h Tue May 31 04:10:15 2016 (r301009) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_checksum.h Tue May 31 04:12:14 2016 (r301010) @@ -82,7 +82,6 @@ extern zio_checksum_info_t zio_checksum_ * Checksum routines. */ extern zio_checksum_t zio_checksum_SHA256; -#ifdef illumos extern zio_checksum_t zio_checksum_SHA512_native; extern zio_checksum_t zio_checksum_SHA512_byteswap; @@ -92,6 +91,7 @@ extern zio_checksum_t zio_checksum_skein extern zio_checksum_tmpl_init_t zio_checksum_skein_tmpl_init; extern zio_checksum_tmpl_free_t zio_checksum_skein_tmpl_free; +#ifdef illumos /* Edon-R */ extern zio_checksum_t zio_checksum_edonr_native; extern zio_checksum_t zio_checksum_edonr_byteswap; Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c Tue May 31 04:10:15 2016 (r301009) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c Tue May 31 04:12:14 2016 (r301010) @@ -123,7 +123,6 @@ zio_checksum_info_t zio_checksum_table[Z NULL, NULL, ZCHECKSUM_FLAG_EMBEDDED, "zilog2"}, {{zio_checksum_off, zio_checksum_off}, NULL, NULL, 0, "noparity"}, -#ifdef illumos {{zio_checksum_SHA512_native, zio_checksum_SHA512_byteswap}, NULL, NULL, ZCHECKSUM_FLAG_METADATA | ZCHECKSUM_FLAG_DEDUP | ZCHECKSUM_FLAG_NOPWRITE, "sha512"}, @@ -131,6 +130,7 @@ zio_checksum_info_t zio_checksum_table[Z zio_checksum_skein_tmpl_init, zio_checksum_skein_tmpl_free, ZCHECKSUM_FLAG_METADATA | ZCHECKSUM_FLAG_DEDUP | ZCHECKSUM_FLAG_SALTED | ZCHECKSUM_FLAG_NOPWRITE, "skein"}, +#ifdef illumos {{zio_checksum_edonr_native, zio_checksum_edonr_byteswap}, zio_checksum_edonr_tmpl_init, zio_checksum_edonr_tmpl_free, ZCHECKSUM_FLAG_METADATA | ZCHECKSUM_FLAG_SALTED | @@ -145,7 +145,6 @@ zio_checksum_info_t zio_checksum_table[Z spa_feature_t zio_checksum_to_feature(enum zio_checksum cksum) { -#ifdef illumos VERIFY((cksum & ~ZIO_CHECKSUM_MASK) == 0); switch (cksum) { @@ -153,10 +152,11 @@ zio_checksum_to_feature(enum zio_checksu return (SPA_FEATURE_SHA512); case ZIO_CHECKSUM_SKEIN: return (SPA_FEATURE_SKEIN); +#ifdef illumos case ZIO_CHECKSUM_EDONR: return (SPA_FEATURE_EDONR); - } #endif + } return (SPA_FEATURE_NONE); } Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Tue May 31 04:10:15 2016 (r301009) +++ head/sys/conf/files Tue May 31 04:12:14 2016 (r301010) @@ -197,6 +197,7 @@ cddl/contrib/opensolaris/uts/common/fs/z cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/sha256.c optional zfs compile-with "${ZFS_C}" +cddl/contrib/opensolaris/uts/common/fs/zfs/skein_zfs.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c optional zfs compile-with "${ZFS_C}" @@ -577,6 +578,8 @@ crypto/sha1.c optional carp | crypto | crypto/sha2/sha256c.c optional crypto | geom_bde | ipsec | random !random_loadable | \ sctp | zfs crypto/sha2/sha512c.c optional crypto | geom_bde | ipsec | zfs +crypto/skein/skein.c optional crypto | zfs +crypto/skein/skein_block.c optional crypto | zfs crypto/siphash/siphash.c optional inet | inet6 crypto/siphash/siphash_test.c optional inet | inet6 ddb/db_access.c optional ddb Modified: head/sys/crypto/skein/skein_port.h ============================================================================== --- head/sys/crypto/skein/skein_port.h Tue May 31 04:10:15 2016 (r301009) +++ head/sys/crypto/skein/skein_port.h Tue May 31 04:12:14 2016 (r301010) @@ -19,7 +19,9 @@ #include <sys/endian.h> #include <sys/types.h> +#ifndef _OPENSOLARIS_SYS_TYPES_H_ /* Avoid redefining this typedef */ typedef unsigned int uint_t; /* native unsigned integer */ +#endif typedef u_int8_t u08b_t; /* 8-bit unsigned integer */ typedef u_int32_t uint_32t; /* 32-bit unsigned integer */ typedef u_int64_t u64b_t; /* 64-bit unsigned integer */ Modified: head/sys/modules/zfs/Makefile ============================================================================== --- head/sys/modules/zfs/Makefile Tue May 31 04:10:15 2016 (r301009) +++ head/sys/modules/zfs/Makefile Tue May 31 04:12:14 2016 (r301010) @@ -70,6 +70,9 @@ SRCS+= zutil.c .PATH: ${SYSDIR}/crypto/sha2 SRCS+= sha256c.c sha512c.c +.PATH: ${SYSDIR}/crypto/skein +SRCS+= skein.c skein_block.c + .PATH: ${SUNW}/common/zfs .include "${SUNW}/uts/common/Makefile.files" .PATH: ${SUNW}/uts/common/fs/zfs _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"