xref: /titanic_51/usr/src/lib/libcryptoutil/common/mechkeygen.c (revision 33f5ff17089e3a43e6e730bf80384c233123dbd9)
126ff1ce9Sdinak /*
226ff1ce9Sdinak  * CDDL HEADER START
326ff1ce9Sdinak  *
426ff1ce9Sdinak  * The contents of this file are subject to the terms of the
526ff1ce9Sdinak  * Common Development and Distribution License (the "License").
626ff1ce9Sdinak  * You may not use this file except in compliance with the License.
726ff1ce9Sdinak  *
826ff1ce9Sdinak  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
926ff1ce9Sdinak  * or http://www.opensolaris.org/os/licensing.
1026ff1ce9Sdinak  * See the License for the specific language governing permissions
1126ff1ce9Sdinak  * and limitations under the License.
1226ff1ce9Sdinak  *
1326ff1ce9Sdinak  * When distributing Covered Code, include this CDDL HEADER in each
1426ff1ce9Sdinak  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1526ff1ce9Sdinak  * If applicable, add the following below this CDDL HEADER, with the
1626ff1ce9Sdinak  * fields enclosed by brackets "[]" replaced with your own identifying
1726ff1ce9Sdinak  * information: Portions Copyright [yyyy] [name of copyright owner]
1826ff1ce9Sdinak  *
1926ff1ce9Sdinak  * CDDL HEADER END
2026ff1ce9Sdinak  */
2126ff1ce9Sdinak /*
2226ff1ce9Sdinak  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
2326ff1ce9Sdinak  * Use is subject to license terms.
24*33f5ff17SMilan Jurik  * Copyright 2012 Milan Jurik. All rights reserved.
2526ff1ce9Sdinak  */
2626ff1ce9Sdinak 
2726ff1ce9Sdinak #include <cryptoutil.h>
2826ff1ce9Sdinak 
2926ff1ce9Sdinak /*
3026ff1ce9Sdinak  * Get the key generation mechanism for the given mechanism.
3126ff1ce9Sdinak  *
3226ff1ce9Sdinak  * All mechanisms in PKCS #11 v2.20 are listed here.
3326ff1ce9Sdinak  */
3426ff1ce9Sdinak CK_RV
3526ff1ce9Sdinak pkcs11_mech2keygen(CK_MECHANISM_TYPE mech_type, CK_MECHANISM_TYPE *gen_mech)
3626ff1ce9Sdinak {
3726ff1ce9Sdinak 	switch (mech_type) {
3826ff1ce9Sdinak 
3926ff1ce9Sdinak 	case CKM_RSA_PKCS_KEY_PAIR_GEN:
4026ff1ce9Sdinak 	case CKM_RSA_PKCS:
4126ff1ce9Sdinak 	case CKM_RSA_9796:
4226ff1ce9Sdinak 	case CKM_RSA_X_509:
4326ff1ce9Sdinak 	case CKM_MD2_RSA_PKCS:
4426ff1ce9Sdinak 	case CKM_MD5_RSA_PKCS:
4526ff1ce9Sdinak 	case CKM_SHA1_RSA_PKCS:
4626ff1ce9Sdinak 	case CKM_SHA256_RSA_PKCS:
4726ff1ce9Sdinak 	case CKM_SHA384_RSA_PKCS:
4826ff1ce9Sdinak 	case CKM_SHA512_RSA_PKCS:
4926ff1ce9Sdinak 	case CKM_SHA256_RSA_PKCS_PSS:
5026ff1ce9Sdinak 	case CKM_SHA384_RSA_PKCS_PSS:
5126ff1ce9Sdinak 	case CKM_SHA512_RSA_PKCS_PSS:
5226ff1ce9Sdinak 	case CKM_RIPEMD128_RSA_PKCS:
5326ff1ce9Sdinak 	case CKM_RIPEMD160_RSA_PKCS:
5426ff1ce9Sdinak 	case CKM_RSA_PKCS_OAEP:
5526ff1ce9Sdinak 		*gen_mech = CKM_RSA_PKCS_KEY_PAIR_GEN;
5626ff1ce9Sdinak 		break;
5726ff1ce9Sdinak 
5826ff1ce9Sdinak 	case CKM_RSA_X9_31_KEY_PAIR_GEN:
5926ff1ce9Sdinak 	case CKM_RSA_X9_31:
6026ff1ce9Sdinak 	case CKM_SHA1_RSA_X9_31:
6126ff1ce9Sdinak 		*gen_mech = CKM_RSA_X9_31_KEY_PAIR_GEN;
6226ff1ce9Sdinak 		break;
6326ff1ce9Sdinak 
6426ff1ce9Sdinak 	case CKM_RSA_PKCS_PSS:
6526ff1ce9Sdinak 	case CKM_SHA1_RSA_PKCS_PSS:
6626ff1ce9Sdinak 		*gen_mech = CKM_RSA_PKCS_KEY_PAIR_GEN;
6726ff1ce9Sdinak 		break;
6826ff1ce9Sdinak 
6926ff1ce9Sdinak 	case CKM_DH_PKCS_PARAMETER_GEN:
7026ff1ce9Sdinak 		*gen_mech = CKM_DH_PKCS_PARAMETER_GEN;
7126ff1ce9Sdinak 		break;
7226ff1ce9Sdinak 
7326ff1ce9Sdinak 	case CKM_DSA_KEY_PAIR_GEN:
7426ff1ce9Sdinak 	case CKM_DSA:
7526ff1ce9Sdinak 	case CKM_DSA_SHA1:
7626ff1ce9Sdinak 		*gen_mech = CKM_DSA_KEY_PAIR_GEN;
7726ff1ce9Sdinak 		break;
7826ff1ce9Sdinak 
7926ff1ce9Sdinak 	case CKM_DSA_PARAMETER_GEN:
8026ff1ce9Sdinak 		*gen_mech = CKM_DSA_PARAMETER_GEN;
8126ff1ce9Sdinak 		break;
8226ff1ce9Sdinak 
8326ff1ce9Sdinak 	case CKM_FORTEZZA_TIMESTAMP:
8426ff1ce9Sdinak 		*gen_mech = CKM_DSA_KEY_PAIR_GEN;
8526ff1ce9Sdinak 		break;
8626ff1ce9Sdinak 
8726ff1ce9Sdinak 	case CKM_DH_PKCS_KEY_PAIR_GEN:
8826ff1ce9Sdinak 	case CKM_DH_PKCS_DERIVE:
8926ff1ce9Sdinak 		*gen_mech = CKM_DH_PKCS_KEY_PAIR_GEN;
9026ff1ce9Sdinak 		break;
9126ff1ce9Sdinak 
9226ff1ce9Sdinak 	case CKM_ECDSA:
9326ff1ce9Sdinak 	case CKM_ECDSA_SHA1:
9426ff1ce9Sdinak 	case CKM_EC_KEY_PAIR_GEN:
9526ff1ce9Sdinak 	case CKM_ECDH1_DERIVE:
9626ff1ce9Sdinak 	case CKM_ECDH1_COFACTOR_DERIVE:
9726ff1ce9Sdinak 	case CKM_ECMQV_DERIVE:
9826ff1ce9Sdinak 		*gen_mech = CKM_EC_KEY_PAIR_GEN;
9926ff1ce9Sdinak 		break;
10026ff1ce9Sdinak 
10126ff1ce9Sdinak 	case CKM_X9_42_DH_KEY_PAIR_GEN:
10226ff1ce9Sdinak 	case CKM_X9_42_DH_DERIVE:
10326ff1ce9Sdinak 	case CKM_X9_42_DH_HYBRID_DERIVE:
10426ff1ce9Sdinak 	case CKM_X9_42_MQV_DERIVE:
10526ff1ce9Sdinak 		*gen_mech = CKM_X9_42_DH_KEY_PAIR_GEN;
10626ff1ce9Sdinak 		break;
10726ff1ce9Sdinak 
10826ff1ce9Sdinak 	case CKM_X9_42_DH_PARAMETER_GEN:
10926ff1ce9Sdinak 		*gen_mech = CKM_X9_42_DH_PARAMETER_GEN;
11026ff1ce9Sdinak 		break;
11126ff1ce9Sdinak 
11226ff1ce9Sdinak 	case CKM_KEA_KEY_PAIR_GEN:
11326ff1ce9Sdinak 	case CKM_KEA_KEY_DERIVE:
11426ff1ce9Sdinak 		*gen_mech = CKM_KEA_KEY_PAIR_GEN;
11526ff1ce9Sdinak 		break;
11626ff1ce9Sdinak 
11726ff1ce9Sdinak 	case CKM_MD2:
11826ff1ce9Sdinak 	case CKM_MD2_HMAC:
11926ff1ce9Sdinak 	case CKM_MD2_HMAC_GENERAL:
12026ff1ce9Sdinak 	case CKM_MD5:
12126ff1ce9Sdinak 	case CKM_MD5_HMAC:
12226ff1ce9Sdinak 	case CKM_MD5_HMAC_GENERAL:
12326ff1ce9Sdinak 	case CKM_SHA_1:
12426ff1ce9Sdinak 	case CKM_SHA_1_HMAC:
12526ff1ce9Sdinak 	case CKM_SHA_1_HMAC_GENERAL:
12626ff1ce9Sdinak 	case CKM_SHA256:
12726ff1ce9Sdinak 	case CKM_SHA256_HMAC:
12826ff1ce9Sdinak 	case CKM_SHA256_HMAC_GENERAL:
12926ff1ce9Sdinak 	case CKM_SHA384:
13026ff1ce9Sdinak 	case CKM_SHA384_HMAC:
13126ff1ce9Sdinak 	case CKM_SHA384_HMAC_GENERAL:
13226ff1ce9Sdinak 	case CKM_SHA512:
13326ff1ce9Sdinak 	case CKM_SHA512_HMAC:
13426ff1ce9Sdinak 	case CKM_SHA512_HMAC_GENERAL:
13526ff1ce9Sdinak 	case CKM_GENERIC_SECRET_KEY_GEN:
13626ff1ce9Sdinak 	case CKM_FASTHASH:
13726ff1ce9Sdinak 	case CKM_PKCS5_PBKD2:
13826ff1ce9Sdinak 	case CKM_PBA_SHA1_WITH_SHA1_HMAC:
13926ff1ce9Sdinak 		*gen_mech = CKM_GENERIC_SECRET_KEY_GEN;
14026ff1ce9Sdinak 		break;
14126ff1ce9Sdinak 
14226ff1ce9Sdinak 	case CKM_SSL3_MD5_MAC:
14326ff1ce9Sdinak 	case CKM_SSL3_SHA1_MAC:
14426ff1ce9Sdinak 	case CKM_SSL3_PRE_MASTER_KEY_GEN:
14526ff1ce9Sdinak 	case CKM_SSL3_MASTER_KEY_DERIVE:
14626ff1ce9Sdinak 	case CKM_SSL3_KEY_AND_MAC_DERIVE:
14726ff1ce9Sdinak 	case CKM_SSL3_MASTER_KEY_DERIVE_DH:
14826ff1ce9Sdinak 		*gen_mech = CKM_SSL3_PRE_MASTER_KEY_GEN;
14926ff1ce9Sdinak 		break;
15026ff1ce9Sdinak 
15126ff1ce9Sdinak 	case CKM_TLS_PRE_MASTER_KEY_GEN:
15226ff1ce9Sdinak 	case CKM_TLS_MASTER_KEY_DERIVE:
15326ff1ce9Sdinak 	case CKM_TLS_KEY_AND_MAC_DERIVE:
15426ff1ce9Sdinak 	case CKM_TLS_MASTER_KEY_DERIVE_DH:
15526ff1ce9Sdinak 	case CKM_TLS_PRF:
15626ff1ce9Sdinak 		*gen_mech = CKM_TLS_PRE_MASTER_KEY_GEN;
15726ff1ce9Sdinak 		break;
15826ff1ce9Sdinak 
15926ff1ce9Sdinak 	case CKM_WTLS_PRE_MASTER_KEY_GEN:
16026ff1ce9Sdinak 	case CKM_WTLS_MASTER_KEY_DERIVE:
16126ff1ce9Sdinak 	case CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC:
16226ff1ce9Sdinak 	case CKM_WTLS_PRF:
16326ff1ce9Sdinak 	case CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE:
16426ff1ce9Sdinak 	case CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE:
16526ff1ce9Sdinak 		*gen_mech = CKM_WTLS_PRE_MASTER_KEY_GEN;
16626ff1ce9Sdinak 		break;
16726ff1ce9Sdinak 
16826ff1ce9Sdinak 	case CKM_CONCATENATE_BASE_AND_KEY:
16926ff1ce9Sdinak 	case CKM_CONCATENATE_BASE_AND_DATA:
17026ff1ce9Sdinak 	case CKM_CONCATENATE_DATA_AND_BASE:
17126ff1ce9Sdinak 	case CKM_XOR_BASE_AND_DATA:
17226ff1ce9Sdinak 	case CKM_EXTRACT_KEY_FROM_KEY:
17326ff1ce9Sdinak 	case CKM_RIPEMD128:
17426ff1ce9Sdinak 	case CKM_RIPEMD128_HMAC:
17526ff1ce9Sdinak 	case CKM_RIPEMD128_HMAC_GENERAL:
17626ff1ce9Sdinak 	case CKM_RIPEMD160:
17726ff1ce9Sdinak 	case CKM_RIPEMD160_HMAC:
17826ff1ce9Sdinak 	case CKM_RIPEMD160_HMAC_GENERAL:
17926ff1ce9Sdinak 	case CKM_SHA1_KEY_DERIVATION:
18026ff1ce9Sdinak 	case CKM_SHA256_KEY_DERIVATION:
18126ff1ce9Sdinak 	case CKM_SHA384_KEY_DERIVATION:
18226ff1ce9Sdinak 	case CKM_SHA512_KEY_DERIVATION:
18326ff1ce9Sdinak 	case CKM_MD5_KEY_DERIVATION:
18426ff1ce9Sdinak 	case CKM_MD2_KEY_DERIVATION:
18526ff1ce9Sdinak 	/* not sure the following 2 should be CKK_DES or not */
18626ff1ce9Sdinak 	case CKM_KEY_WRAP_LYNKS: /* wrap/unwrap secret key w/ DES key */
18726ff1ce9Sdinak 	case CKM_KEY_WRAP_SET_OAEP:  /* wrap/unwarp DES key w/ RSA key */
18826ff1ce9Sdinak 		*gen_mech = CKM_GENERIC_SECRET_KEY_GEN;
18926ff1ce9Sdinak 		break;
19026ff1ce9Sdinak 
19126ff1ce9Sdinak 	case CKM_RC2_KEY_GEN:
19226ff1ce9Sdinak 	case CKM_RC2_ECB:
19326ff1ce9Sdinak 	case CKM_RC2_CBC:
19426ff1ce9Sdinak 	case CKM_RC2_MAC:
19526ff1ce9Sdinak 	case CKM_RC2_MAC_GENERAL:
19626ff1ce9Sdinak 	case CKM_RC2_CBC_PAD:
19726ff1ce9Sdinak 	case CKM_PBE_SHA1_RC2_128_CBC:
19826ff1ce9Sdinak 	case CKM_PBE_SHA1_RC2_40_CBC:
19926ff1ce9Sdinak 		*gen_mech = CKM_RC2_KEY_GEN;
20026ff1ce9Sdinak 		break;
20126ff1ce9Sdinak 
20226ff1ce9Sdinak 	case CKM_RC4_KEY_GEN:
20326ff1ce9Sdinak 	case CKM_RC4:
20426ff1ce9Sdinak 	case CKM_PBE_SHA1_RC4_128:
20526ff1ce9Sdinak 	case CKM_PBE_SHA1_RC4_40:
20626ff1ce9Sdinak 		*gen_mech = CKM_RC4_KEY_GEN;
20726ff1ce9Sdinak 		break;
20826ff1ce9Sdinak 
20926ff1ce9Sdinak 	case CKM_DES_KEY_GEN:
21026ff1ce9Sdinak 	case CKM_DES_ECB:
21126ff1ce9Sdinak 	case CKM_DES_CBC:
21226ff1ce9Sdinak 	case CKM_DES_MAC:
21326ff1ce9Sdinak 	case CKM_DES_MAC_GENERAL:
21426ff1ce9Sdinak 	case CKM_DES_CBC_PAD:
21526ff1ce9Sdinak 	case CKM_PBE_MD2_DES_CBC:
21626ff1ce9Sdinak 	case CKM_PBE_MD5_DES_CBC:
21726ff1ce9Sdinak 	case CKM_DES_OFB64:
21826ff1ce9Sdinak 	case CKM_DES_OFB8:
21926ff1ce9Sdinak 	case CKM_DES_CFB64:
22026ff1ce9Sdinak 	case CKM_DES_CFB8:
22126ff1ce9Sdinak 	case CKM_DES_ECB_ENCRYPT_DATA:
22226ff1ce9Sdinak 	case CKM_DES_CBC_ENCRYPT_DATA:
22326ff1ce9Sdinak 		*gen_mech = CKM_DES_KEY_GEN;
22426ff1ce9Sdinak 		break;
22526ff1ce9Sdinak 
22626ff1ce9Sdinak 	case CKM_DES2_KEY_GEN:
22726ff1ce9Sdinak 	case CKM_PBE_SHA1_DES2_EDE_CBC:
22826ff1ce9Sdinak 		*gen_mech = CKM_DES2_KEY_GEN;
22926ff1ce9Sdinak 		break;
23026ff1ce9Sdinak 
23126ff1ce9Sdinak 	case CKM_DES3_KEY_GEN:
23226ff1ce9Sdinak 	case CKM_DES3_ECB:
23326ff1ce9Sdinak 	case CKM_DES3_CBC:
23426ff1ce9Sdinak 	case CKM_DES3_MAC:
23526ff1ce9Sdinak 	case CKM_DES3_MAC_GENERAL:
23626ff1ce9Sdinak 	case CKM_DES3_CBC_PAD:
23726ff1ce9Sdinak 	case CKM_PBE_SHA1_DES3_EDE_CBC:
23826ff1ce9Sdinak 	case CKM_DES3_ECB_ENCRYPT_DATA:
23926ff1ce9Sdinak 	case CKM_DES3_CBC_ENCRYPT_DATA:
24026ff1ce9Sdinak 		*gen_mech = CKM_DES3_KEY_GEN;
24126ff1ce9Sdinak 		break;
24226ff1ce9Sdinak 
24326ff1ce9Sdinak 	case CKM_CAST_KEY_GEN:
24426ff1ce9Sdinak 	case CKM_CAST_ECB:
24526ff1ce9Sdinak 	case CKM_CAST_CBC:
24626ff1ce9Sdinak 	case CKM_CAST_MAC:
24726ff1ce9Sdinak 	case CKM_CAST_MAC_GENERAL:
24826ff1ce9Sdinak 	case CKM_CAST_CBC_PAD:
24926ff1ce9Sdinak 	case CKM_PBE_MD5_CAST_CBC:
25026ff1ce9Sdinak 		*gen_mech = CKM_CAST_KEY_GEN;
25126ff1ce9Sdinak 		break;
25226ff1ce9Sdinak 
25326ff1ce9Sdinak 	case CKM_CAST3_KEY_GEN:
25426ff1ce9Sdinak 	case CKM_CAST3_ECB:
25526ff1ce9Sdinak 	case CKM_CAST3_CBC:
25626ff1ce9Sdinak 	case CKM_CAST3_MAC:
25726ff1ce9Sdinak 	case CKM_CAST3_MAC_GENERAL:
25826ff1ce9Sdinak 	case CKM_CAST3_CBC_PAD:
25926ff1ce9Sdinak 	case CKM_PBE_MD5_CAST3_CBC:
26026ff1ce9Sdinak 		*gen_mech = CKM_CAST3_KEY_GEN;
26126ff1ce9Sdinak 		break;
26226ff1ce9Sdinak 
26326ff1ce9Sdinak 	case CKM_CAST128_KEY_GEN:
26426ff1ce9Sdinak 	case CKM_CAST128_ECB:
26526ff1ce9Sdinak 	case CKM_CAST128_CBC:
26626ff1ce9Sdinak 	case CKM_CAST128_MAC:
26726ff1ce9Sdinak 	case CKM_CAST128_MAC_GENERAL:
26826ff1ce9Sdinak 	case CKM_CAST128_CBC_PAD:
26926ff1ce9Sdinak 	case CKM_PBE_MD5_CAST128_CBC:
27026ff1ce9Sdinak 	case CKM_PBE_SHA1_CAST128_CBC:
27126ff1ce9Sdinak 		*gen_mech = CKM_CAST128_KEY_GEN;
27226ff1ce9Sdinak 		break;
27326ff1ce9Sdinak 
27426ff1ce9Sdinak 	case CKM_RC5_KEY_GEN:
27526ff1ce9Sdinak 	case CKM_RC5_ECB:
27626ff1ce9Sdinak 	case CKM_RC5_CBC:
27726ff1ce9Sdinak 	case CKM_RC5_MAC:
27826ff1ce9Sdinak 	case CKM_RC5_MAC_GENERAL:
27926ff1ce9Sdinak 	case CKM_RC5_CBC_PAD:
28026ff1ce9Sdinak 		*gen_mech = CKM_RC5_KEY_GEN;
28126ff1ce9Sdinak 		break;
28226ff1ce9Sdinak 
28326ff1ce9Sdinak 	case CKM_IDEA_KEY_GEN:
28426ff1ce9Sdinak 	case CKM_IDEA_ECB:
28526ff1ce9Sdinak 	case CKM_IDEA_CBC:
28626ff1ce9Sdinak 	case CKM_IDEA_MAC:
28726ff1ce9Sdinak 	case CKM_IDEA_MAC_GENERAL:
28826ff1ce9Sdinak 	case CKM_IDEA_CBC_PAD:
28926ff1ce9Sdinak 		*gen_mech = CKM_IDEA_KEY_GEN;
29026ff1ce9Sdinak 		break;
29126ff1ce9Sdinak 
29226ff1ce9Sdinak 	case CKM_SKIPJACK_KEY_GEN:
29326ff1ce9Sdinak 	case CKM_SKIPJACK_ECB64:
29426ff1ce9Sdinak 	case CKM_SKIPJACK_CBC64:
29526ff1ce9Sdinak 	case CKM_SKIPJACK_OFB64:
29626ff1ce9Sdinak 	case CKM_SKIPJACK_CFB64:
29726ff1ce9Sdinak 	case CKM_SKIPJACK_CFB32:
29826ff1ce9Sdinak 	case CKM_SKIPJACK_CFB16:
29926ff1ce9Sdinak 	case CKM_SKIPJACK_CFB8:
30026ff1ce9Sdinak 	case CKM_SKIPJACK_WRAP:
30126ff1ce9Sdinak 	case CKM_SKIPJACK_PRIVATE_WRAP:
30226ff1ce9Sdinak 	case CKM_SKIPJACK_RELAYX:
30326ff1ce9Sdinak 		*gen_mech = CKM_SKIPJACK_KEY_GEN;
30426ff1ce9Sdinak 		break;
30526ff1ce9Sdinak 
30626ff1ce9Sdinak 	case CKM_BATON_KEY_GEN:
30726ff1ce9Sdinak 	case CKM_BATON_ECB128:
30826ff1ce9Sdinak 	case CKM_BATON_ECB96:
30926ff1ce9Sdinak 	case CKM_BATON_CBC128:
31026ff1ce9Sdinak 	case CKM_BATON_COUNTER:
31126ff1ce9Sdinak 	case CKM_BATON_SHUFFLE:
31226ff1ce9Sdinak 	case CKM_BATON_WRAP:
31326ff1ce9Sdinak 		*gen_mech = CKM_BATON_KEY_GEN;
31426ff1ce9Sdinak 		break;
31526ff1ce9Sdinak 
31626ff1ce9Sdinak 	case CKM_JUNIPER_KEY_GEN:
31726ff1ce9Sdinak 	case CKM_JUNIPER_ECB128:
31826ff1ce9Sdinak 	case CKM_JUNIPER_CBC128:
31926ff1ce9Sdinak 	case CKM_JUNIPER_COUNTER:
32026ff1ce9Sdinak 	case CKM_JUNIPER_SHUFFLE:
32126ff1ce9Sdinak 	case CKM_JUNIPER_WRAP:
32226ff1ce9Sdinak 		*gen_mech = CKM_JUNIPER_KEY_GEN;
32326ff1ce9Sdinak 		break;
32426ff1ce9Sdinak 
32526ff1ce9Sdinak 	case CKM_CDMF_KEY_GEN:
32626ff1ce9Sdinak 	case CKM_CDMF_ECB:
32726ff1ce9Sdinak 	case CKM_CDMF_CBC:
32826ff1ce9Sdinak 	case CKM_CDMF_MAC:
32926ff1ce9Sdinak 	case CKM_CDMF_MAC_GENERAL:
33026ff1ce9Sdinak 	case CKM_CDMF_CBC_PAD:
33126ff1ce9Sdinak 		*gen_mech = CKM_CDMF_KEY_GEN;
33226ff1ce9Sdinak 		break;
33326ff1ce9Sdinak 
33426ff1ce9Sdinak 	case CKM_AES_KEY_GEN:
33526ff1ce9Sdinak 	case CKM_AES_ECB:
33626ff1ce9Sdinak 	case CKM_AES_CBC:
33726ff1ce9Sdinak 	case CKM_AES_MAC:
33826ff1ce9Sdinak 	case CKM_AES_MAC_GENERAL:
33926ff1ce9Sdinak 	case CKM_AES_CBC_PAD:
34026ff1ce9Sdinak 	case CKM_AES_ECB_ENCRYPT_DATA:
34126ff1ce9Sdinak 	case CKM_AES_CBC_ENCRYPT_DATA:
34226ff1ce9Sdinak 		*gen_mech = CKM_AES_KEY_GEN;
34326ff1ce9Sdinak 		break;
34426ff1ce9Sdinak 
34526ff1ce9Sdinak 	case CKM_BLOWFISH_KEY_GEN:
34626ff1ce9Sdinak 	case CKM_BLOWFISH_CBC:
34726ff1ce9Sdinak 		*gen_mech = CKM_BLOWFISH_KEY_GEN;
34826ff1ce9Sdinak 		break;
34926ff1ce9Sdinak 
35026ff1ce9Sdinak 	case CKM_TWOFISH_KEY_GEN:
35126ff1ce9Sdinak 	case CKM_TWOFISH_CBC:
35226ff1ce9Sdinak 		*gen_mech = CKM_TWOFISH_KEY_GEN;
35326ff1ce9Sdinak 		break;
35426ff1ce9Sdinak 
35526ff1ce9Sdinak 	default:
35626ff1ce9Sdinak 		return (CKR_MECHANISM_INVALID);
35726ff1ce9Sdinak 	}
35826ff1ce9Sdinak 
35926ff1ce9Sdinak 	return (CKR_OK);
36026ff1ce9Sdinak }
361