socsvn commit: r255399 - soc2013/def/crashdump-head/sys/crypto

def at FreeBSD.org def at FreeBSD.org
Wed Jul 31 17:55:47 UTC 2013


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 <sys/endian.h>
 #include <crypto/xts.h>
 
-#ifdef _KERNEL
-#include <sys/libkern.h>
-#else
-#include <string.h>
-#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 <crypto/camellia/camellia.h>
 #include <crypto/rijndael/rijndael.h>
 #include <crypto/hmac/hmac.h>
+#include <sys/endian.h>
+
+#ifdef _KERNEL
+#include <sys/libkern.h>
+#else
+#include <string.h>
+#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,


More information about the svn-soc-all mailing list