module: icp: remove unused (and mostly faked) cm_{{min,max}_key_length,mech_flags}

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901
This commit is contained in:
наб 2021-12-27 02:39:55 +01:00 committed by Brian Behlendorf
parent 11320b4cdf
commit cf497e18df
10 changed files with 21 additions and 83 deletions

View File

@ -33,9 +33,6 @@
extern "C" { extern "C" {
#endif #endif
#define SHA2_HMAC_MIN_KEY_LEN 1 /* SHA2-HMAC min key length in bytes */
#define SHA2_HMAC_MAX_KEY_LEN INT_MAX /* SHA2-HMAC max key length in bytes */
#define SHA256_DIGEST_LENGTH 32 /* SHA256 digest length in bytes */ #define SHA256_DIGEST_LENGTH 32 /* SHA256 digest length in bytes */
#define SHA384_DIGEST_LENGTH 48 /* SHA384 digest length in bytes */ #define SHA384_DIGEST_LENGTH 48 /* SHA384 digest length in bytes */
#define SHA512_DIGEST_LENGTH 64 /* SHA512 digest length in bytes */ #define SHA512_DIGEST_LENGTH 64 /* SHA512 digest length in bytes */

View File

@ -33,9 +33,6 @@
extern "C" { extern "C" {
#endif #endif
#define SHA2_HMAC_MIN_KEY_LEN 1 /* SHA2-HMAC min key length in bytes */
#define SHA2_HMAC_MAX_KEY_LEN INT_MAX /* SHA2-HMAC max key length in bytes */
#define SHA256_DIGEST_LENGTH 32 /* SHA256 digest length in bytes */ #define SHA256_DIGEST_LENGTH 32 /* SHA256 digest length in bytes */
#define SHA384_DIGEST_LENGTH 48 /* SHA384 digest length in bytes */ #define SHA384_DIGEST_LENGTH 48 /* SHA384 digest length in bytes */
#define SHA512_DIGEST_LENGTH 64 /* SHA512 digest length in bytes */ #define SHA512_DIGEST_LENGTH 64 /* SHA512 digest length in bytes */

View File

@ -90,13 +90,6 @@ typedef struct CK_AES_GMAC_PARAMS {
*/ */
typedef uint32_t crypto_keysize_unit_t; typedef uint32_t crypto_keysize_unit_t;
/*
* The following bit flags are valid in cm_mech_flags field in
* the crypto_mech_info_t structure of the SPI.
*/
#define CRYPTO_KEYSIZE_UNIT_IN_BITS 0x00000001
#define CRYPTO_KEYSIZE_UNIT_IN_BYTES 0x00000002
/* Mechanisms supported out-of-the-box */ /* Mechanisms supported out-of-the-box */
#define SUN_CKM_SHA256 "CKM_SHA256" #define SUN_CKM_SHA256 "CKM_SHA256"

View File

@ -33,9 +33,6 @@
extern "C" { extern "C" {
#endif #endif
#define SHA2_HMAC_MIN_KEY_LEN 1 /* SHA2-HMAC min key length in bytes */
#define SHA2_HMAC_MAX_KEY_LEN INT_MAX /* SHA2-HMAC max key length in bytes */
#define SHA256_DIGEST_LENGTH 32 /* SHA256 digest length in bytes */ #define SHA256_DIGEST_LENGTH 32 /* SHA256 digest length in bytes */
#define SHA384_DIGEST_LENGTH 48 /* SHA384 digest length in bytes */ #define SHA384_DIGEST_LENGTH 48 /* SHA384 digest length in bytes */
#define SHA512_DIGEST_LENGTH 64 /* SHA512 digest length in bytes */ #define SHA512_DIGEST_LENGTH 64 /* SHA512 digest length in bytes */

View File

@ -83,14 +83,7 @@ extern "C" {
/* AES key size definitions */ /* AES key size definitions */
#define AES_MINBITS 128 #define AES_MINBITS 128
#define AES_MINBYTES ((AES_MINBITS) >> 3)
#define AES_MAXBITS 256 #define AES_MAXBITS 256
#define AES_MAXBYTES ((AES_MAXBITS) >> 3)
#define AES_MIN_KEY_BYTES ((AES_MINBITS) >> 3)
#define AES_MAX_KEY_BYTES ((AES_MAXBITS) >> 3)
#define AES_192_KEY_BYTES 24
#define AES_IV_LEN 16
/* AES key schedule may be implemented with 32- or 64-bit elements: */ /* AES key schedule may be implemented with 32- or 64-bit elements: */
#define AES_32BIT_KS 32 #define AES_32BIT_KS 32

View File

@ -203,11 +203,7 @@ typedef struct crypto_mech_info {
crypto_mech_name_t cm_mech_name; crypto_mech_name_t cm_mech_name;
crypto_mech_type_t cm_mech_number; crypto_mech_type_t cm_mech_number;
crypto_func_group_t cm_func_group_mask; crypto_func_group_t cm_func_group_mask;
ssize_t cm_min_key_length;
ssize_t cm_max_key_length;
uint32_t cm_mech_flags;
} crypto_mech_info_t; } crypto_mech_info_t;
#define cm_max_input_length cm_max_key_length
/* /*
* crypto_kcf_provider_handle_t is a handle allocated by the kernel. * crypto_kcf_provider_handle_t is a handle allocated by the kernel.

View File

@ -43,34 +43,28 @@ static const crypto_mech_info_t aes_mech_info_tab[] = {
/* AES_ECB */ /* AES_ECB */
{SUN_CKM_AES_ECB, AES_ECB_MECH_INFO_TYPE, {SUN_CKM_AES_ECB, AES_ECB_MECH_INFO_TYPE,
CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC, CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC},
AES_MIN_KEY_BYTES, AES_MAX_KEY_BYTES, CRYPTO_KEYSIZE_UNIT_IN_BYTES},
/* AES_CBC */ /* AES_CBC */
{SUN_CKM_AES_CBC, AES_CBC_MECH_INFO_TYPE, {SUN_CKM_AES_CBC, AES_CBC_MECH_INFO_TYPE,
CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC, CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC},
AES_MIN_KEY_BYTES, AES_MAX_KEY_BYTES, CRYPTO_KEYSIZE_UNIT_IN_BYTES},
/* AES_CTR */ /* AES_CTR */
{SUN_CKM_AES_CTR, AES_CTR_MECH_INFO_TYPE, {SUN_CKM_AES_CTR, AES_CTR_MECH_INFO_TYPE,
CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC, CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC},
AES_MIN_KEY_BYTES, AES_MAX_KEY_BYTES, CRYPTO_KEYSIZE_UNIT_IN_BYTES},
/* AES_CCM */ /* AES_CCM */
{SUN_CKM_AES_CCM, AES_CCM_MECH_INFO_TYPE, {SUN_CKM_AES_CCM, AES_CCM_MECH_INFO_TYPE,
CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC, CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC},
AES_MIN_KEY_BYTES, AES_MAX_KEY_BYTES, CRYPTO_KEYSIZE_UNIT_IN_BYTES},
/* AES_GCM */ /* AES_GCM */
{SUN_CKM_AES_GCM, AES_GCM_MECH_INFO_TYPE, {SUN_CKM_AES_GCM, AES_GCM_MECH_INFO_TYPE,
CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC, CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC},
AES_MIN_KEY_BYTES, AES_MAX_KEY_BYTES, CRYPTO_KEYSIZE_UNIT_IN_BYTES},
/* AES_GMAC */ /* AES_GMAC */
{SUN_CKM_AES_GMAC, AES_GMAC_MECH_INFO_TYPE, {SUN_CKM_AES_GMAC, AES_GMAC_MECH_INFO_TYPE,
CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC | CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC |
CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC},
AES_MIN_KEY_BYTES, AES_MAX_KEY_BYTES, CRYPTO_KEYSIZE_UNIT_IN_BYTES}
}; };
static int aes_encrypt_init(crypto_ctx_t *, crypto_mechanism_t *, static int aes_encrypt_init(crypto_ctx_t *, crypto_mechanism_t *,

View File

@ -63,46 +63,31 @@
static const crypto_mech_info_t sha2_mech_info_tab[] = { static const crypto_mech_info_t sha2_mech_info_tab[] = {
/* SHA256 */ /* SHA256 */
{SUN_CKM_SHA256, SHA256_MECH_INFO_TYPE, {SUN_CKM_SHA256, SHA256_MECH_INFO_TYPE,
CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC, CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC},
0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
/* SHA256-HMAC */ /* SHA256-HMAC */
{SUN_CKM_SHA256_HMAC, SHA256_HMAC_MECH_INFO_TYPE, {SUN_CKM_SHA256_HMAC, SHA256_HMAC_MECH_INFO_TYPE,
CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC},
SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
CRYPTO_KEYSIZE_UNIT_IN_BYTES},
/* SHA256-HMAC GENERAL */ /* SHA256-HMAC GENERAL */
{SUN_CKM_SHA256_HMAC_GENERAL, SHA256_HMAC_GEN_MECH_INFO_TYPE, {SUN_CKM_SHA256_HMAC_GENERAL, SHA256_HMAC_GEN_MECH_INFO_TYPE,
CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC},
SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
CRYPTO_KEYSIZE_UNIT_IN_BYTES},
/* SHA384 */ /* SHA384 */
{SUN_CKM_SHA384, SHA384_MECH_INFO_TYPE, {SUN_CKM_SHA384, SHA384_MECH_INFO_TYPE,
CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC, CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC},
0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
/* SHA384-HMAC */ /* SHA384-HMAC */
{SUN_CKM_SHA384_HMAC, SHA384_HMAC_MECH_INFO_TYPE, {SUN_CKM_SHA384_HMAC, SHA384_HMAC_MECH_INFO_TYPE,
CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC},
SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
CRYPTO_KEYSIZE_UNIT_IN_BYTES},
/* SHA384-HMAC GENERAL */ /* SHA384-HMAC GENERAL */
{SUN_CKM_SHA384_HMAC_GENERAL, SHA384_HMAC_GEN_MECH_INFO_TYPE, {SUN_CKM_SHA384_HMAC_GENERAL, SHA384_HMAC_GEN_MECH_INFO_TYPE,
CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC},
SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
CRYPTO_KEYSIZE_UNIT_IN_BYTES},
/* SHA512 */ /* SHA512 */
{SUN_CKM_SHA512, SHA512_MECH_INFO_TYPE, {SUN_CKM_SHA512, SHA512_MECH_INFO_TYPE,
CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC, CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC},
0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
/* SHA512-HMAC */ /* SHA512-HMAC */
{SUN_CKM_SHA512_HMAC, SHA512_HMAC_MECH_INFO_TYPE, {SUN_CKM_SHA512_HMAC, SHA512_HMAC_MECH_INFO_TYPE,
CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC},
SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
CRYPTO_KEYSIZE_UNIT_IN_BYTES},
/* SHA512-HMAC GENERAL */ /* SHA512-HMAC GENERAL */
{SUN_CKM_SHA512_HMAC_GENERAL, SHA512_HMAC_GEN_MECH_INFO_TYPE, {SUN_CKM_SHA512_HMAC_GENERAL, SHA512_HMAC_GEN_MECH_INFO_TYPE,
CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC},
SHA2_HMAC_MIN_KEY_LEN, SHA2_HMAC_MAX_KEY_LEN,
CRYPTO_KEYSIZE_UNIT_IN_BYTES}
}; };
static int sha2_digest_init(crypto_ctx_t *, crypto_mechanism_t *); static int sha2_digest_init(crypto_ctx_t *, crypto_mechanism_t *);

View File

@ -32,23 +32,17 @@
static const crypto_mech_info_t skein_mech_info_tab[] = { static const crypto_mech_info_t skein_mech_info_tab[] = {
{CKM_SKEIN_256, SKEIN_256_MECH_INFO_TYPE, {CKM_SKEIN_256, SKEIN_256_MECH_INFO_TYPE,
CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC, CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC},
0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
{CKM_SKEIN_256_MAC, SKEIN_256_MAC_MECH_INFO_TYPE, {CKM_SKEIN_256_MAC, SKEIN_256_MAC_MECH_INFO_TYPE,
CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, 1, INT_MAX, CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC},
CRYPTO_KEYSIZE_UNIT_IN_BYTES},
{CKM_SKEIN_512, SKEIN_512_MECH_INFO_TYPE, {CKM_SKEIN_512, SKEIN_512_MECH_INFO_TYPE,
CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC, CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC},
0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
{CKM_SKEIN_512_MAC, SKEIN_512_MAC_MECH_INFO_TYPE, {CKM_SKEIN_512_MAC, SKEIN_512_MAC_MECH_INFO_TYPE,
CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, 1, INT_MAX, CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC},
CRYPTO_KEYSIZE_UNIT_IN_BYTES},
{CKM_SKEIN1024, SKEIN1024_MECH_INFO_TYPE, {CKM_SKEIN1024, SKEIN1024_MECH_INFO_TYPE,
CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC, CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC},
0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
{CKM_SKEIN1024_MAC, SKEIN1024_MAC_MECH_INFO_TYPE, {CKM_SKEIN1024_MAC, SKEIN1024_MAC_MECH_INFO_TYPE,
CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, 1, INT_MAX, CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC},
CRYPTO_KEYSIZE_UNIT_IN_BYTES}
}; };
static int skein_digest_init(crypto_ctx_t *, crypto_mechanism_t *); static int skein_digest_init(crypto_ctx_t *, crypto_mechanism_t *);

View File

@ -252,14 +252,6 @@ init_prov_mechs(const crypto_provider_info_t *info, kcf_provider_desc_t *desc)
* to the corresponding KCF mechanism mech_entry chain. * to the corresponding KCF mechanism mech_entry chain.
*/ */
for (mech_idx = 0; mech_idx < desc->pd_mech_list_count; mech_idx++) { for (mech_idx = 0; mech_idx < desc->pd_mech_list_count; mech_idx++) {
const crypto_mech_info_t *mi = &desc->pd_mechanisms[mech_idx];
if ((mi->cm_mech_flags & CRYPTO_KEYSIZE_UNIT_IN_BITS) &&
(mi->cm_mech_flags & CRYPTO_KEYSIZE_UNIT_IN_BYTES)) {
err = CRYPTO_ARGUMENTS_BAD;
break;
}
if ((err = kcf_add_mech_provider(mech_idx, desc, &pmd)) != if ((err = kcf_add_mech_provider(mech_idx, desc, &pmd)) !=
KCF_SUCCESS) KCF_SUCCESS)
break; break;