From owner-svn-soc-all@FreeBSD.ORG Wed Jul 31 17:55:47 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 90D342A1 for ; Wed, 31 Jul 2013 17:55:47 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7D7522FEF for ; Wed, 31 Jul 2013 17:55:47 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6VHtlxt081248 for ; Wed, 31 Jul 2013 17:55:47 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6VHtlsr081245 for svn-soc-all@FreeBSD.org; Wed, 31 Jul 2013 17:55:47 GMT (envelope-from def@FreeBSD.org) Date: Wed, 31 Jul 2013 17:55:47 GMT Message-Id: <201307311755.r6VHtlsr081245@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255399 - soc2013/def/crashdump-head/sys/crypto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Jul 2013 17:55:47 -0000 Author: def Date: Wed Jul 31 17:55:47 2013 New Revision: 255399 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255399 Log: Change xts_start, xts_lastblock, xts_fullblock to be non-static. Move inline functions of XTS to a header file. Modified: soc2013/def/crashdump-head/sys/crypto/xts.c soc2013/def/crashdump-head/sys/crypto/xts.h Modified: soc2013/def/crashdump-head/sys/crypto/xts.c ============================================================================== --- soc2013/def/crashdump-head/sys/crypto/xts.c Wed Jul 31 17:50:48 2013 (r255398) +++ soc2013/def/crashdump-head/sys/crypto/xts.c Wed Jul 31 17:55:47 2013 (r255399) @@ -32,12 +32,6 @@ #include #include -#ifdef _KERNEL -#include -#else -#include -#endif - void xts_aes_keysetup(struct xts_ctx *ctx, const uint8_t *key, uint32_t keybits) { @@ -63,42 +57,7 @@ .pa_id = XTS_ALG_AES, }; -static __inline void -xor128(void *dst, const void *src1, const void *src2) -{ - const uint64_t *s1 = (const uint64_t *)src1; - const uint64_t *s2 = (const uint64_t *)src2; - uint64_t *d = (uint64_t *)dst; - - d[0] = s1[0] ^ s2[0]; - d[1] = s1[1] ^ s2[1]; -} - -static __inline int -shl128(uint64_t *d, const uint64_t *s) -{ - int c0, c1; - - c0 = s[0] & (1ULL << 63) ? 1 : 0; - c1 = s[1] & (1ULL << 63) ? 1 : 0; - d[0] = s[0] << 1; - d[1] = s[1] << 1 | c0; - - return (c1); -} - -static __inline void -gf_mul128(uint64_t *dst, const uint64_t *src) -{ - static const uint8_t gf_128_fdbk = 0x87; - int carry; - - carry = shl128(dst, src); - if (carry != 0) - ((uint8_t *)dst)[0] ^= gf_128_fdbk; -} - -static __inline void +void xts_fullblock(algop_crypt_t *data_crypt, const struct xts_ctx *data_ctx, uint64_t *tweak, const uint8_t *src, uint8_t *dst) { @@ -108,7 +67,7 @@ gf_mul128(tweak, tweak); } -static __inline void +void xts_lastblock(algop_crypt_t *data_crypt, const struct xts_ctx *data_ctx, uint64_t *tweak, const uint8_t *src, uint8_t *dst, int len) { @@ -124,7 +83,7 @@ xor128(dst, dst, tweak); } -static __inline void +void xts_start(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, uint64_t *tweak, uint64_t sector, const uint8_t *xtweak) { Modified: soc2013/def/crashdump-head/sys/crypto/xts.h ============================================================================== --- soc2013/def/crashdump-head/sys/crypto/xts.h Wed Jul 31 17:50:48 2013 (r255398) +++ soc2013/def/crashdump-head/sys/crypto/xts.h Wed Jul 31 17:55:47 2013 (r255399) @@ -32,6 +32,13 @@ #include #include #include +#include + +#ifdef _KERNEL +#include +#else +#include +#endif #define XTS_BLK_BYTES 16 #define XTS_BLK_MASK (XTS_BLK_BYTES - 1) @@ -58,6 +65,50 @@ int pa_id; }; +static __inline void +xor128(void *dst, const void *src1, const void *src2) +{ + const uint64_t *s1 = (const uint64_t *)src1; + const uint64_t *s2 = (const uint64_t *)src2; + uint64_t *d = (uint64_t *)dst; + + d[0] = s1[0] ^ s2[0]; + d[1] = s1[1] ^ s2[1]; +} + +static __inline int +shl128(uint64_t *d, const uint64_t *s) +{ + int c0, c1; + + c0 = s[0] & (1ULL << 63) ? 1 : 0; + c1 = s[1] & (1ULL << 63) ? 1 : 0; + d[0] = s[0] << 1; + d[1] = s[1] << 1 | c0; + + return (c1); +} + +static __inline void +gf_mul128(uint64_t *dst, const uint64_t *src) +{ + static const uint8_t gf_128_fdbk = 0x87; + int carry; + + carry = shl128(dst, src); + if (carry != 0) + ((uint8_t *)dst)[0] ^= gf_128_fdbk; +} + +void xts_fullblock(algop_crypt_t *data_crypt, const struct xts_ctx *data_ctx, + uint64_t *tweak, const uint8_t *src, uint8_t *dst); + +void xts_lastblock(algop_crypt_t *data_crypt, const struct xts_ctx *data_ctx, + uint64_t *tweak, const uint8_t *src, uint8_t *dst, int len); + +void xts_start(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, + uint64_t *tweak, uint64_t sector, const uint8_t *xtweak); + void xts_block_encrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, uint64_t sector, const uint8_t *xtweak, int len,