#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xform.c,v 1.32 2026/04/29 14:51:58 christos Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
#include <opencrypto/cryptodev.h>
#include <opencrypto/xform.h>
MALLOC_DEFINE(M_XDATA, "xform", "xform data buffers");
const uint8_t hmac_ipad_buffer[128] = {
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36
};
const uint8_t hmac_opad_buffer[128] = {
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C,
0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C
};
const struct enc_xform enc_xform_null = {
.type = CRYPTO_NULL_CBC,
.name = "NULL",
.blocksize = 4,
.ivsize = 0,
.minkey = 0,
.maxkey = 256,
};
const struct enc_xform enc_xform_des = {
.type = CRYPTO_DES_CBC,
.name = "DES",
.blocksize = 8,
.ivsize = 8,
.minkey = 8,
.maxkey = 8,
};
const struct enc_xform enc_xform_3des = {
.type = CRYPTO_3DES_CBC,
.name = "3DES",
.blocksize = 8,
.ivsize = 8,
.minkey = 24,
.maxkey = 24,
};
const struct enc_xform enc_xform_blf = {
.type = CRYPTO_BLF_CBC,
.name = "Blowfish",
.blocksize = 8,
.ivsize = 8,
.minkey = 5,
.maxkey = 56,
};
const struct enc_xform enc_xform_cast5 = {
.type = CRYPTO_CAST_CBC,
.name = "CAST-128",
.blocksize = 8,
.ivsize = 8,
.minkey = 5,
.maxkey = 16,
};
const struct enc_xform enc_xform_skipjack = {
.type = CRYPTO_SKIPJACK_CBC,
.name = "Skipjack",
.blocksize = 8,
.ivsize = 8,
.minkey = 10,
.maxkey = 10,
};
const struct enc_xform enc_xform_aes = {
.type = CRYPTO_AES_CBC,
.name = "AES",
.blocksize = 16,
.ivsize = 16,
.minkey = 16,
.maxkey = 32,
};
const struct enc_xform enc_xform_arc4 = {
.type = CRYPTO_ARC4,
.name = "ARC4",
.blocksize = 1,
.ivsize = 0,
.minkey = 1,
.maxkey = 32,
};
const struct enc_xform enc_xform_camellia = {
.type = CRYPTO_CAMELLIA_CBC,
.name = "Camellia",
.blocksize = 16,
.ivsize = 16,
.minkey = 8,
.maxkey = 32,
};
const struct enc_xform enc_xform_aes_ctr = {
.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 = {
.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 = {
.type = CRYPTO_AES_GMAC,
.name = "AES-GMAC",
.blocksize = 4,
.ivsize = 8,
.minkey = 16 + 4,
.maxkey = 32 + 4,
};
const struct auth_hash auth_hash_null = {
.type = CRYPTO_NULL_HMAC,
.name = "NULL-HMAC",
.keysize = 0,
.hashsize = 0,
.authsize = 12,
.blocksize = 64,
};
const struct auth_hash auth_hash_hmac_md5 = {
.type = CRYPTO_MD5_HMAC,
.name = "HMAC-MD5",
.keysize = 16,
.hashsize = 16,
.authsize = 16,
.blocksize = 64,
};
const struct auth_hash auth_hash_hmac_sha1 = {
.type = CRYPTO_SHA1_HMAC,
.name = "HMAC-SHA1",
.keysize = 20,
.hashsize = 20,
.authsize = 20,
.blocksize = 64,
};
const struct auth_hash auth_hash_hmac_ripemd_160 = {
.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 = {
.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 = {
.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 = {
.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 = {
.type = CRYPTO_MD5_KPDK,
.name = "Keyed MD5",
.keysize = 0,
.hashsize = 16,
.authsize = 16,
.blocksize = 0,
};
const struct auth_hash auth_hash_key_sha1 = {
.type = CRYPTO_SHA1_KPDK,
.name = "Keyed SHA1",
.keysize = 0,
.hashsize = 20,
.authsize = 20,
.blocksize = 0,
};
const struct auth_hash auth_hash_md5 = {
.type = CRYPTO_MD5,
.name = "MD5",
.keysize = 0,
.hashsize = 16,
.authsize = 16,
.blocksize = 0,
};
const struct auth_hash auth_hash_sha1 = {
.type = CRYPTO_SHA1,
.name = "SHA1",
.keysize = 0,
.hashsize = 20,
.authsize = 20,
.blocksize = 0,
};
const struct auth_hash auth_hash_hmac_sha2_256 = {
.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 = {
.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 = {
.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 = {
.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 = {
.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 = {
.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 = {
.type = CRYPTO_AES_256_GMAC,
.name = "GMAC-AES-256",
.keysize = 32 + 4,
.hashsize = 16,
.authsize = 16,
.blocksize = 16,
};
const struct comp_algo comp_algo_deflate = {
.type = CRYPTO_DEFLATE_COMP,
.name = "Deflate",
.minlen = 90,
};
const struct comp_algo comp_algo_deflate_nogrow = {
.type = CRYPTO_DEFLATE_COMP_NOGROW,
.name = "Deflate",
.minlen = 90,
};
const struct comp_algo comp_algo_gzip = {
.type = CRYPTO_GZIP_COMP,
.name = "GZIP",
.minlen = 90,
};