svn commit: r324019 - in head/sys: crypto/via opencrypto

Conrad Meyer cem at FreeBSD.org
Tue Sep 26 17:52:54 UTC 2017


Author: cem
Date: Tue Sep 26 17:52:52 2017
New Revision: 324019
URL: https://svnweb.freebsd.org/changeset/base/324019

Log:
  opencrypto: Use C99 initializers for auth_hash instances
  
  A misordering in the Via padlock driver really strongly suggested that these
  should use C99 named initializers.
  
  No functional change.
  
  Sponsored by:	Dell EMC Isilon

Modified:
  head/sys/crypto/via/padlock_hash.c
  head/sys/opencrypto/xform_md5.c
  head/sys/opencrypto/xform_null.c
  head/sys/opencrypto/xform_rmd160.c
  head/sys/opencrypto/xform_sha1.c
  head/sys/opencrypto/xform_sha2.c

Modified: head/sys/crypto/via/padlock_hash.c
==============================================================================
--- head/sys/crypto/via/padlock_hash.c	Tue Sep 26 17:35:53 2017	(r324018)
+++ head/sys/crypto/via/padlock_hash.c	Tue Sep 26 17:52:52 2017	(r324019)
@@ -81,21 +81,27 @@ static void padlock_sha1_final(uint8_t *hash, struct p
 static void padlock_sha256_final(uint8_t *hash, struct padlock_sha_ctx *ctx);
 
 static struct auth_hash padlock_hmac_sha1 = {
-	CRYPTO_SHA1_HMAC, "HMAC-SHA1",
-	SHA1_HMAC_BLOCK_LEN, SHA1_HASH_LEN, sizeof(struct padlock_sha_ctx),
-	SHA1_HMAC_BLOCK_LEN,
-        (void (*)(void *))padlock_sha_init, NULL, NULL,
-	(int (*)(void *, const uint8_t *, uint16_t))padlock_sha_update,
-	(void (*)(uint8_t *, void *))padlock_sha1_final
+	.type = CRYPTO_SHA1_HMAC,
+	.name = "HMAC-SHA1",
+	.keysize = SHA1_HMAC_BLOCK_LEN,
+	.hashsize = SHA1_HASH_LEN,
+	.ctxsize = sizeof(struct padlock_sha_ctx),
+	.blocksize = SHA1_HMAC_BLOCK_LEN,
+        .Init = (void (*)(void *))padlock_sha_init,
+	.Update = (int (*)(void *, const uint8_t *, uint16_t))padlock_sha_update,
+	.Final = (void (*)(uint8_t *, void *))padlock_sha1_final,
 };
 
 static struct auth_hash padlock_hmac_sha256 = {
-	CRYPTO_SHA2_256_HMAC, "HMAC-SHA2-256",
-	SHA2_256_HMAC_BLOCK_LEN, SHA2_256_HASH_LEN,
-	sizeof(struct padlock_sha_ctx), SHA2_256_HMAC_BLOCK_LEN,
-        (void (*)(void *))padlock_sha_init, NULL, NULL,
-	(int (*)(void *, const uint8_t *, uint16_t))padlock_sha_update,
-	(void (*)(uint8_t *, void *))padlock_sha256_final
+	.type = CRYPTO_SHA2_256_HMAC,
+	.name = "HMAC-SHA2-256",
+	.keysize = SHA2_256_HMAC_BLOCK_LEN,
+	.hashsize = SHA2_256_HASH_LEN,
+	.ctxsize = sizeof(struct padlock_sha_ctx),
+	.blocksize = SHA2_256_HMAC_BLOCK_LEN,
+        .Init = (void (*)(void *))padlock_sha_init,
+	.Update = (int (*)(void *, const uint8_t *, uint16_t))padlock_sha_update,
+	.Final = (void (*)(uint8_t *, void *))padlock_sha256_final,
 };
 
 MALLOC_DECLARE(M_PADLOCK);

Modified: head/sys/opencrypto/xform_md5.c
==============================================================================
--- head/sys/opencrypto/xform_md5.c	Tue Sep 26 17:35:53 2017	(r324018)
+++ head/sys/opencrypto/xform_md5.c	Tue Sep 26 17:52:52 2017	(r324019)
@@ -57,17 +57,27 @@ static	int MD5Update_int(void *, const u_int8_t *, u_i
 
 /* Authentication instances */
 struct auth_hash auth_hash_hmac_md5 = {
-	CRYPTO_MD5_HMAC, "HMAC-MD5",
-	MD5_HMAC_BLOCK_LEN, MD5_HASH_LEN, sizeof(MD5_CTX), MD5_HMAC_BLOCK_LEN,
-	(void (*) (void *)) MD5Init, NULL, NULL, MD5Update_int,
-	(void (*) (u_int8_t *, void *)) MD5Final
+	.type = CRYPTO_MD5_HMAC,
+	.name = "HMAC-MD5",
+	.keysize = MD5_HMAC_BLOCK_LEN,
+	.hashsize = MD5_HASH_LEN,
+	.ctxsize = sizeof(MD5_CTX),
+	.blocksize = MD5_HMAC_BLOCK_LEN,
+	.Init = (void (*) (void *)) MD5Init,
+	.Update = MD5Update_int,
+	.Final = (void (*) (u_int8_t *, void *)) MD5Final,
 };
 
 struct auth_hash auth_hash_key_md5 = {
-	CRYPTO_MD5_KPDK, "Keyed MD5",
-	0, MD5_KPDK_HASH_LEN, sizeof(MD5_CTX), 0,
-	(void (*)(void *)) MD5Init, NULL, NULL, MD5Update_int,
-	(void (*)(u_int8_t *, void *)) MD5Final
+	.type = CRYPTO_MD5_KPDK,
+	.name = "Keyed MD5",
+	.keysize = 0,
+	.hashsize = MD5_KPDK_HASH_LEN,
+	.ctxsize = sizeof(MD5_CTX),
+	.blocksize = 0,
+	.Init = (void (*)(void *)) MD5Init,
+	.Update = MD5Update_int,
+	.Final = (void (*)(u_int8_t *, void *)) MD5Final,
 };
 
 /*

Modified: head/sys/opencrypto/xform_null.c
==============================================================================
--- head/sys/opencrypto/xform_null.c	Tue Sep 26 17:35:53 2017	(r324018)
+++ head/sys/opencrypto/xform_null.c	Tue Sep 26 17:52:52 2017	(r324019)
@@ -76,10 +76,18 @@ struct enc_xform enc_xform_null = {
 };
 
 /* Authentication instances */
-struct auth_hash auth_hash_null = {	/* NB: context isn't used */
-	CRYPTO_NULL_HMAC, "NULL-HMAC",
-	0, NULL_HASH_LEN, sizeof(int), NULL_HMAC_BLOCK_LEN,
-	null_init, null_reinit, null_reinit, null_update, null_final
+struct auth_hash auth_hash_null = {
+	.type = CRYPTO_NULL_HMAC,
+	.name = "NULL-HMAC",
+	.keysize = 0,
+	.hashsize = NULL_HASH_LEN,
+	.ctxsize = sizeof(int),	/* NB: context isn't used */
+	.blocksize = NULL_HMAC_BLOCK_LEN,
+	.Init = null_init,
+	.Setkey = null_reinit,
+	.Reinit = null_reinit,
+	.Update = null_update,
+	.Final = null_final,
 };
 
 /*

Modified: head/sys/opencrypto/xform_rmd160.c
==============================================================================
--- head/sys/opencrypto/xform_rmd160.c	Tue Sep 26 17:35:53 2017	(r324018)
+++ head/sys/opencrypto/xform_rmd160.c	Tue Sep 26 17:52:52 2017	(r324019)
@@ -57,11 +57,15 @@ static	int RMD160Update_int(void *, const u_int8_t *, 
 
 /* Authentication instances */
 struct auth_hash auth_hash_hmac_ripemd_160 = {
-	CRYPTO_RIPEMD160_HMAC, "HMAC-RIPEMD-160",
-	RIPEMD160_HMAC_BLOCK_LEN, RIPEMD160_HASH_LEN, sizeof(RMD160_CTX),
-	RIPEMD160_HMAC_BLOCK_LEN,
-	(void (*)(void *)) RMD160Init, NULL, NULL, RMD160Update_int,
-	(void (*)(u_int8_t *, void *)) RMD160Final
+	.type = CRYPTO_RIPEMD160_HMAC,
+	.name = "HMAC-RIPEMD-160",
+	.keysize = RIPEMD160_HMAC_BLOCK_LEN,
+	.hashsize = RIPEMD160_HASH_LEN,
+	.ctxsize = sizeof(RMD160_CTX),
+	.blocksize = RIPEMD160_HMAC_BLOCK_LEN,
+	.Init = (void (*)(void *)) RMD160Init,
+	.Update = RMD160Update_int,
+	.Final = (void (*)(u_int8_t *, void *)) RMD160Final,
 };
 
 /*

Modified: head/sys/opencrypto/xform_sha1.c
==============================================================================
--- head/sys/opencrypto/xform_sha1.c	Tue Sep 26 17:35:53 2017	(r324018)
+++ head/sys/opencrypto/xform_sha1.c	Tue Sep 26 17:52:52 2017	(r324019)
@@ -59,15 +59,27 @@ static	void SHA1Final_int(u_int8_t *, void *);
 
 /* Authentication instances */
 struct auth_hash auth_hash_hmac_sha1 = {
-	CRYPTO_SHA1_HMAC, "HMAC-SHA1",
-	SHA1_HMAC_BLOCK_LEN, SHA1_HASH_LEN, sizeof(SHA1_CTX), SHA1_HMAC_BLOCK_LEN,
-	SHA1Init_int, NULL, NULL, SHA1Update_int, SHA1Final_int
+	.type = CRYPTO_SHA1_HMAC,
+	.name = "HMAC-SHA1",
+	.keysize = SHA1_HMAC_BLOCK_LEN,
+	.hashsize = SHA1_HASH_LEN,
+	.ctxsize = sizeof(SHA1_CTX),
+	.blocksize = SHA1_HMAC_BLOCK_LEN,
+	.Init = SHA1Init_int,
+	.Update = SHA1Update_int,
+	.Final = SHA1Final_int,
 };
 
 struct auth_hash auth_hash_key_sha1 = {
-	CRYPTO_SHA1_KPDK, "Keyed SHA1",
-	0, SHA1_KPDK_HASH_LEN, sizeof(SHA1_CTX), 0,
-	SHA1Init_int, NULL, NULL, SHA1Update_int, SHA1Final_int
+	.type = CRYPTO_SHA1_KPDK,
+	.name = "Keyed SHA1",
+	.keysize = 0,
+	.hashsize = SHA1_KPDK_HASH_LEN,
+	.ctxsize = sizeof(SHA1_CTX),
+	.blocksize = 0,
+	.Init = SHA1Init_int,
+	.Update = SHA1Update_int,
+	.Final = SHA1Final_int,
 };
 
 /*

Modified: head/sys/opencrypto/xform_sha2.c
==============================================================================
--- head/sys/opencrypto/xform_sha2.c	Tue Sep 26 17:35:53 2017	(r324018)
+++ head/sys/opencrypto/xform_sha2.c	Tue Sep 26 17:52:52 2017	(r324019)
@@ -61,27 +61,39 @@ static	int SHA512Update_int(void *, const u_int8_t *, 
 
 /* Authentication instances */
 struct auth_hash auth_hash_hmac_sha2_256 = {
-	CRYPTO_SHA2_256_HMAC, "HMAC-SHA2-256",
-	SHA2_256_HMAC_BLOCK_LEN, SHA2_256_HASH_LEN, sizeof(SHA256_CTX),
-	SHA2_256_HMAC_BLOCK_LEN,
-	(void (*)(void *)) SHA256_Init, NULL, NULL, SHA256Update_int,
-	(void (*)(u_int8_t *, void *)) SHA256_Final
+	.type = CRYPTO_SHA2_256_HMAC,
+	.name = "HMAC-SHA2-256",
+	.keysize = SHA2_256_HMAC_BLOCK_LEN,
+	.hashsize = SHA2_256_HASH_LEN,
+	.ctxsize = sizeof(SHA256_CTX),
+	.blocksize = SHA2_256_HMAC_BLOCK_LEN,
+	.Init = (void (*)(void *)) SHA256_Init,
+	.Update = SHA256Update_int,
+	.Final = (void (*)(u_int8_t *, void *)) SHA256_Final,
 };
 
 struct auth_hash auth_hash_hmac_sha2_384 = {
-	CRYPTO_SHA2_384_HMAC, "HMAC-SHA2-384",
-	SHA2_384_HMAC_BLOCK_LEN, SHA2_384_HASH_LEN, sizeof(SHA384_CTX),
-	SHA2_384_HMAC_BLOCK_LEN,
-	(void (*)(void *)) SHA384_Init, NULL, NULL, SHA384Update_int,
-	(void (*)(u_int8_t *, void *)) SHA384_Final
+	.type = CRYPTO_SHA2_384_HMAC,
+	.name = "HMAC-SHA2-384",
+	.keysize = SHA2_384_HMAC_BLOCK_LEN,
+	.hashsize = SHA2_384_HASH_LEN,
+	.ctxsize = sizeof(SHA384_CTX),
+	.blocksize = SHA2_384_HMAC_BLOCK_LEN,
+	.Init = (void (*)(void *)) SHA384_Init,
+	.Update = SHA384Update_int,
+	.Final = (void (*)(u_int8_t *, void *)) SHA384_Final,
 };
 
 struct auth_hash auth_hash_hmac_sha2_512 = {
-	CRYPTO_SHA2_512_HMAC, "HMAC-SHA2-512",
-	SHA2_512_HMAC_BLOCK_LEN, SHA2_512_HASH_LEN, sizeof(SHA512_CTX),
-	SHA2_512_HMAC_BLOCK_LEN,
-	(void (*)(void *)) SHA512_Init, NULL, NULL, SHA512Update_int,
-	(void (*)(u_int8_t *, void *)) SHA512_Final
+	.type = CRYPTO_SHA2_512_HMAC,
+	.name = "HMAC-SHA2-512",
+	.keysize = SHA2_512_HMAC_BLOCK_LEN,
+	.hashsize = SHA2_512_HASH_LEN,
+	.ctxsize = sizeof(SHA512_CTX),
+	.blocksize = SHA2_512_HMAC_BLOCK_LEN,
+	.Init = (void (*)(void *)) SHA512_Init,
+	.Update = SHA512Update_int,
+	.Final = (void (*)(u_int8_t *, void *)) SHA512_Final,
 };
 
 /*


More information about the svn-src-head mailing list