Apply C99-style struct initialization to enc_xform, auth_hash and comp_algo

This commit is contained in:
ozaki-r 2017-07-06 08:27:07 +00:00
parent 6f18d82dd5
commit 8e371e73e6

View File

@ -1,4 +1,4 @@
/* $NetBSD: xform.c,v 1.28 2011/05/26 21:50:03 drochner Exp $ */
/* $NetBSD: xform.c,v 1.29 2017/07/06 08:27:07 ozaki-r Exp $ */
/* $FreeBSD: src/sys/opencrypto/xform.c,v 1.1.2.1 2002/11/21 23:34:23 sam Exp $ */
/* $OpenBSD: xform.c,v 1.19 2002/08/16 22:47:25 dhartmei Exp $ */
@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xform.c,v 1.28 2011/05/26 21:50:03 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: xform.c,v 1.29 2017/07/06 08:27:07 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
@ -90,169 +90,292 @@ const u_int8_t hmac_opad_buffer[128] = {
/* Encryption instances */
const struct enc_xform enc_xform_null = {
CRYPTO_NULL_CBC, "NULL",
.type = CRYPTO_NULL_CBC,
.name = "NULL",
/* NB: blocksize of 4 is to generate a properly aligned ESP header */
4, 0, 0, 256 /* 2048 bits, max key */
.blocksize = 4,
.ivsize = 0,
.minkey = 0,
.maxkey = 256, /* 2048 bits, max key */
};
const struct enc_xform enc_xform_des = {
CRYPTO_DES_CBC, "DES",
8, 8, 8, 8
.type = CRYPTO_DES_CBC,
.name = "DES",
.blocksize = 8,
.ivsize = 8,
.minkey = 8,
.maxkey = 8,
};
const struct enc_xform enc_xform_3des = {
CRYPTO_3DES_CBC, "3DES",
8, 8, 24, 24
.type = CRYPTO_3DES_CBC,
.name = "3DES",
.blocksize = 8,
.ivsize = 8,
.minkey = 24,
.maxkey = 24,
};
const struct enc_xform enc_xform_blf = {
CRYPTO_BLF_CBC, "Blowfish",
8, 8, 5, 56 /* 448 bits, max key */
.type = CRYPTO_BLF_CBC,
.name = "Blowfish",
.blocksize = 8,
.ivsize = 8,
.minkey = 5,
.maxkey = 56, /* 448 bits, max key */
};
const struct enc_xform enc_xform_cast5 = {
CRYPTO_CAST_CBC, "CAST-128",
8, 8, 5, 16
.type = CRYPTO_CAST_CBC,
.name = "CAST-128",
.blocksize = 8,
.ivsize = 8,
.minkey = 5,
.maxkey = 16,
};
const struct enc_xform enc_xform_skipjack = {
CRYPTO_SKIPJACK_CBC, "Skipjack",
8, 8, 10, 10
.type = CRYPTO_SKIPJACK_CBC,
.name = "Skipjack",
.blocksize = 8,
.ivsize = 8,
.minkey = 10,
.maxkey = 10,
};
const struct enc_xform enc_xform_rijndael128 = {
CRYPTO_RIJNDAEL128_CBC, "Rijndael-128/AES",
16, 16, 16, 32
.type = CRYPTO_RIJNDAEL128_CBC,
.name = "Rijndael-128/AES",
.blocksize = 16,
.ivsize = 16,
.minkey = 16,
.maxkey = 32,
};
const struct enc_xform enc_xform_arc4 = {
CRYPTO_ARC4, "ARC4",
1, 0, 1, 32
.type = CRYPTO_ARC4,
.name = "ARC4",
.blocksize = 1,
.ivsize = 0,
.minkey = 1,
.maxkey = 32,
};
const struct enc_xform enc_xform_camellia = {
CRYPTO_CAMELLIA_CBC, "Camellia",
16, 16, 8, 32
.type = CRYPTO_CAMELLIA_CBC,
.name = "Camellia",
.blocksize = 16,
.ivsize = 16,
.minkey = 8,
.maxkey = 32,
};
const struct enc_xform enc_xform_aes_ctr = {
CRYPTO_AES_CTR, "AES-CTR",
16, 8, 16+4, 32+4
.type = CRYPTO_AES_CTR,
.name = "AES-CTR",
.blocksize = 16,
.ivsize = 8,
.minkey = 16 + 4,
.maxkey = 32 + 4,
};
const struct enc_xform enc_xform_aes_gcm = {
CRYPTO_AES_GCM_16, "AES-GCM",
4 /* ??? */, 8, 16+4, 32+4
.type = CRYPTO_AES_GCM_16,
.name = "AES-GCM",
.blocksize = 4, /* ??? */
.ivsize = 8,
.minkey = 16 + 4,
.maxkey = 32 + 4,
};
const struct enc_xform enc_xform_aes_gmac = {
CRYPTO_AES_GMAC, "AES-GMAC",
4 /* ??? */, 8, 16+4, 32+4
.type = CRYPTO_AES_GMAC,
.name = "AES-GMAC",
.blocksize = 4, /* ??? */
.ivsize = 8,
.minkey = 16 + 4,
.maxkey = 32 + 4,
};
/* Authentication instances */
const struct auth_hash auth_hash_null = {
CRYPTO_NULL_HMAC, "NULL-HMAC",
0, 0, 12, 64
.type = CRYPTO_NULL_HMAC,
.name = "NULL-HMAC",
.keysize = 0,
.hashsize = 0,
.authsize = 12,
.blocksize = 64,
};
const struct auth_hash auth_hash_hmac_md5 = {
CRYPTO_MD5_HMAC, "HMAC-MD5",
16, 16, 16, 64
.type = CRYPTO_MD5_HMAC,
.name = "HMAC-MD5",
.keysize = 16,
.hashsize = 16,
.authsize = 16,
.blocksize = 64,
};
const struct auth_hash auth_hash_hmac_sha1 = {
CRYPTO_SHA1_HMAC, "HMAC-SHA1",
20, 20, 20, 64
.type = CRYPTO_SHA1_HMAC,
.name = "HMAC-SHA1",
.keysize = 20,
.hashsize = 20,
.authsize = 20,
.blocksize = 64,
};
const struct auth_hash auth_hash_hmac_ripemd_160 = {
CRYPTO_RIPEMD160_HMAC, "HMAC-RIPEMD-160",
20, 20, 20, 64
.type = CRYPTO_RIPEMD160_HMAC,
.name = "HMAC-RIPEMD-160",
.keysize = 20,
.hashsize = 20,
.authsize = 20,
.blocksize = 64,
};
const struct auth_hash auth_hash_hmac_md5_96 = {
CRYPTO_MD5_HMAC_96, "HMAC-MD5-96",
16, 16, 12, 64
.type = CRYPTO_MD5_HMAC_96,
.name = "HMAC-MD5-96",
.keysize = 16,
.hashsize = 16,
.authsize = 12,
.blocksize = 64,
};
const struct auth_hash auth_hash_hmac_sha1_96 = {
CRYPTO_SHA1_HMAC_96, "HMAC-SHA1-96",
20, 20, 12, 64
.type = CRYPTO_SHA1_HMAC_96,
.name = "HMAC-SHA1-96",
.keysize = 20,
.hashsize = 20,
.authsize = 12,
.blocksize = 64,
};
const struct auth_hash auth_hash_hmac_ripemd_160_96 = {
CRYPTO_RIPEMD160_HMAC_96, "HMAC-RIPEMD-160",
20, 20, 12, 64
.type = CRYPTO_RIPEMD160_HMAC_96,
.name = "HMAC-RIPEMD-160",
.keysize = 20,
.hashsize = 20,
.authsize = 12,
.blocksize = 64,
};
const struct auth_hash auth_hash_key_md5 = {
CRYPTO_MD5_KPDK, "Keyed MD5",
0, 16, 16, 0
.type = CRYPTO_MD5_KPDK,
.name = "Keyed MD5",
.keysize = 0,
.hashsize = 16,
.authsize = 16,
.blocksize = 0,
};
const struct auth_hash auth_hash_key_sha1 = {
CRYPTO_SHA1_KPDK, "Keyed SHA1",
0, 20, 20, 0
.type = CRYPTO_SHA1_KPDK,
.name = "Keyed SHA1",
.keysize = 0,
.hashsize = 20,
.authsize = 20,
.blocksize = 0,
};
const struct auth_hash auth_hash_md5 = {
CRYPTO_MD5, "MD5",
0, 16, 16, 0
.type = CRYPTO_MD5,
.name = "MD5",
.keysize = 0,
.hashsize = 16,
.authsize = 16,
.blocksize = 0,
};
const struct auth_hash auth_hash_sha1 = {
CRYPTO_SHA1, "SHA1",
0, 20, 20, 0
.type = CRYPTO_SHA1,
.name = "SHA1",
.keysize = 0,
.hashsize = 20,
.authsize = 20,
.blocksize = 0,
};
const struct auth_hash auth_hash_hmac_sha2_256 = {
CRYPTO_SHA2_256_HMAC, "HMAC-SHA2",
32, 32, 16, 64
.type = CRYPTO_SHA2_256_HMAC,
.name = "HMAC-SHA2",
.keysize = 32,
.hashsize = 32,
.authsize = 16,
.blocksize = 64,
};
const struct auth_hash auth_hash_hmac_sha2_384 = {
CRYPTO_SHA2_384_HMAC, "HMAC-SHA2-384",
48, 48, 24, 128
.type = CRYPTO_SHA2_384_HMAC,
.name = "HMAC-SHA2-384",
.keysize = 48,
.hashsize = 48,
.authsize = 24,
.blocksize = 128,
};
const struct auth_hash auth_hash_hmac_sha2_512 = {
CRYPTO_SHA2_512_HMAC, "HMAC-SHA2-512",
64, 64, 32, 128
.type = CRYPTO_SHA2_512_HMAC,
.name = "HMAC-SHA2-512",
.keysize = 64,
.hashsize = 64,
.authsize = 32,
.blocksize = 128,
};
const struct auth_hash auth_hash_aes_xcbc_mac_96 = {
CRYPTO_AES_XCBC_MAC_96, "AES-XCBC-MAC-96",
16, 16, 12, 0
.type = CRYPTO_AES_XCBC_MAC_96,
.name = "AES-XCBC-MAC-96",
.keysize = 16,
.hashsize = 16,
.authsize = 12,
.blocksize = 0,
};
const struct auth_hash auth_hash_gmac_aes_128 = {
CRYPTO_AES_128_GMAC, "GMAC-AES-128",
16+4, 16, 16, 16 /* ??? */
.type = CRYPTO_AES_128_GMAC,
.name = "GMAC-AES-128",
.keysize = 16 + 4,
.hashsize = 16,
.authsize = 16,
.blocksize = 16, /* ??? */
};
const struct auth_hash auth_hash_gmac_aes_192 = {
CRYPTO_AES_192_GMAC, "GMAC-AES-192",
24+4, 16, 16, 16 /* ??? */
.type = CRYPTO_AES_192_GMAC,
.name = "GMAC-AES-192",
.keysize = 24 + 4,
.hashsize = 16,
.authsize = 16,
.blocksize = 16, /* ??? */
};
const struct auth_hash auth_hash_gmac_aes_256 = {
CRYPTO_AES_256_GMAC, "GMAC-AES-256",
32+4, 16, 16, 16 /* ??? */
.type = CRYPTO_AES_256_GMAC,
.name = "GMAC-AES-256",
.keysize = 32 + 4,
.hashsize = 16,
.authsize = 16,
.blocksize = 16, /* ??? */
};
/* Compression instance */
const struct comp_algo comp_algo_deflate = {
CRYPTO_DEFLATE_COMP, "Deflate",
90
.type = CRYPTO_DEFLATE_COMP,
.name = "Deflate",
.minlen = 90,
};
const struct comp_algo comp_algo_deflate_nogrow = {
CRYPTO_DEFLATE_COMP_NOGROW, "Deflate",
90
.type = CRYPTO_DEFLATE_COMP_NOGROW,
.name = "Deflate",
.minlen = 90,
};
const struct comp_algo comp_algo_gzip = {
CRYPTO_GZIP_COMP, "GZIP",
90
.type = CRYPTO_GZIP_COMP,
.name = "GZIP",
.minlen = 90,
};