diff options
Diffstat (limited to 'module/p11-constants.c')
-rw-r--r-- | module/p11-constants.c | 493 |
1 files changed, 493 insertions, 0 deletions
diff --git a/module/p11-constants.c b/module/p11-constants.c new file mode 100644 index 0000000..d13488f --- /dev/null +++ b/module/p11-constants.c @@ -0,0 +1,493 @@ +/* + * Copyright (c) 2007, Stefan Walter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the + * above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * * The names of contributors to this software may not be + * used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * + * CONTRIBUTORS + * Stef Walter <stef@memberwebs.com> + * + */ + +#define CT(x) case x: cklog("%s", #x); break; + +static void +log_CKA(CK_ATTRIBUTE_TYPE v) +{ + switch(v) { + CT(CKA_CLASS) + CT(CKA_TOKEN) + CT(CKA_PRIVATE) + CT(CKA_LABEL) + CT(CKA_APPLICATION) + CT(CKA_VALUE) + CT(CKA_OBJECT_ID) + CT(CKA_CERTIFICATE_TYPE) + CT(CKA_ISSUER) + CT(CKA_SERIAL_NUMBER) + CT(CKA_AC_ISSUER) + CT(CKA_OWNER) + CT(CKA_ATTR_TYPES) + CT(CKA_TRUSTED) + CT(CKA_CERTIFICATE_CATEGORY) + CT(CKA_JAVA_MIDP_SECURITY_DOMAIN) + CT(CKA_URL) + CT(CKA_HASH_OF_SUBJECT_PUBLIC_KEY) + CT(CKA_HASH_OF_ISSUER_PUBLIC_KEY) + CT(CKA_CHECK_VALUE) + CT(CKA_KEY_TYPE) + CT(CKA_SUBJECT) + CT(CKA_ID) + CT(CKA_SENSITIVE) + CT(CKA_ENCRYPT) + CT(CKA_DECRYPT) + CT(CKA_WRAP) + CT(CKA_UNWRAP) + CT(CKA_SIGN) + CT(CKA_SIGN_RECOVER) + CT(CKA_VERIFY) + CT(CKA_VERIFY_RECOVER) + CT(CKA_DERIVE) + CT(CKA_START_DATE) + CT(CKA_END_DATE) + CT(CKA_MODULUS) + CT(CKA_MODULUS_BITS) + CT(CKA_PUBLIC_EXPONENT) + CT(CKA_PRIVATE_EXPONENT) + CT(CKA_PRIME_1) + CT(CKA_PRIME_2) + CT(CKA_EXPONENT_1) + CT(CKA_EXPONENT_2) + CT(CKA_COEFFICIENT) + CT(CKA_PRIME) + CT(CKA_SUBPRIME) + CT(CKA_BASE) + CT(CKA_PRIME_BITS) + CT(CKA_SUBPRIME_BITS) + /* CT(CKA_SUB_PRIME_BITS) */ + CT(CKA_VALUE_BITS) + CT(CKA_VALUE_LEN) + CT(CKA_EXTRACTABLE) + CT(CKA_LOCAL) + CT(CKA_NEVER_EXTRACTABLE) + CT(CKA_ALWAYS_SENSITIVE) + CT(CKA_KEY_GEN_MECHANISM) + CT(CKA_MODIFIABLE) + CT(CKA_ECDSA_PARAMS) + /* CT(CKA_EC_PARAMS) */ + CT(CKA_EC_POINT) + CT(CKA_SECONDARY_AUTH) + CT(CKA_AUTH_PIN_FLAGS) + CT(CKA_ALWAYS_AUTHENTICATE) + CT(CKA_WRAP_WITH_TRUSTED) + CT(CKA_WRAP_TEMPLATE) + CT(CKA_UNWRAP_TEMPLATE) + CT(CKA_HW_FEATURE_TYPE) + CT(CKA_RESET_ON_INIT) + CT(CKA_HAS_RESET) + CT(CKA_PIXEL_X) + CT(CKA_PIXEL_Y) + CT(CKA_RESOLUTION) + CT(CKA_CHAR_ROWS) + CT(CKA_CHAR_COLUMNS) + CT(CKA_COLOR) + CT(CKA_BITS_PER_PIXEL) + CT(CKA_CHAR_SETS) + CT(CKA_ENCODING_METHODS) + CT(CKA_MIME_TYPES) + CT(CKA_MECHANISM_TYPE) + CT(CKA_REQUIRED_CMS_ATTRIBUTES) + CT(CKA_DEFAULT_CMS_ATTRIBUTES) + CT(CKA_SUPPORTED_CMS_ATTRIBUTES) + CT(CKA_ALLOWED_MECHANISMS) + CT(CKA_VENDOR_DEFINED) + default: + cklog("CKA_0x%08X", v); + break; + } +} + +static void +log_CKM(CK_MECHANISM_TYPE v) +{ + switch(v) { + CT(CKM_RSA_PKCS_KEY_PAIR_GEN) + CT(CKM_RSA_PKCS) + CT(CKM_RSA_9796) + CT(CKM_RSA_X_509) + CT(CKM_MD2_RSA_PKCS) + CT(CKM_MD5_RSA_PKCS) + CT(CKM_SHA1_RSA_PKCS) + CT(CKM_RIPEMD128_RSA_PKCS) + CT(CKM_RIPEMD160_RSA_PKCS) + CT(CKM_RSA_PKCS_OAEP) + CT(CKM_RSA_X9_31_KEY_PAIR_GEN) + CT(CKM_RSA_X9_31) + CT(CKM_SHA1_RSA_X9_31) + CT(CKM_RSA_PKCS_PSS) + CT(CKM_SHA1_RSA_PKCS_PSS) + CT(CKM_DSA_KEY_PAIR_GEN) + CT(CKM_DSA) + CT(CKM_DSA_SHA1) + CT(CKM_DH_PKCS_KEY_PAIR_GEN) + CT(CKM_DH_PKCS_DERIVE) + CT(CKM_X9_42_DH_KEY_PAIR_GEN) + CT(CKM_X9_42_DH_DERIVE) + CT(CKM_X9_42_DH_HYBRID_DERIVE) + CT(CKM_X9_42_MQV_DERIVE) + CT(CKM_SHA256_RSA_PKCS) + CT(CKM_SHA384_RSA_PKCS) + CT(CKM_SHA512_RSA_PKCS) + CT(CKM_SHA256_RSA_PKCS_PSS) + CT(CKM_SHA384_RSA_PKCS_PSS) + CT(CKM_SHA512_RSA_PKCS_PSS) + CT(CKM_RC2_KEY_GEN) + CT(CKM_RC2_ECB) + CT(CKM_RC2_CBC) + CT(CKM_RC2_MAC) + CT(CKM_RC2_MAC_GENERAL) + CT(CKM_RC2_CBC_PAD) + CT(CKM_RC4_KEY_GEN) + CT(CKM_RC4) + CT(CKM_DES_KEY_GEN) + CT(CKM_DES_ECB) + CT(CKM_DES_CBC) + CT(CKM_DES_MAC) + CT(CKM_DES_MAC_GENERAL) + CT(CKM_DES_CBC_PAD) + CT(CKM_DES2_KEY_GEN) + CT(CKM_DES3_KEY_GEN) + CT(CKM_DES3_ECB) + CT(CKM_DES3_CBC) + CT(CKM_DES3_MAC) + CT(CKM_DES3_MAC_GENERAL) + CT(CKM_DES3_CBC_PAD) + CT(CKM_CDMF_KEY_GEN) + CT(CKM_CDMF_ECB) + CT(CKM_CDMF_CBC) + CT(CKM_CDMF_MAC) + CT(CKM_CDMF_MAC_GENERAL) + CT(CKM_CDMF_CBC_PAD) + CT(CKM_DES_OFB64) + CT(CKM_DES_OFB8) + CT(CKM_DES_CFB64) + CT(CKM_DES_CFB8) + CT(CKM_MD2) + CT(CKM_MD2_HMAC) + CT(CKM_MD2_HMAC_GENERAL) + CT(CKM_MD5) + CT(CKM_MD5_HMAC) + CT(CKM_MD5_HMAC_GENERAL) + CT(CKM_SHA_1) + CT(CKM_SHA_1_HMAC) + CT(CKM_SHA_1_HMAC_GENERAL) + CT(CKM_RIPEMD128) + CT(CKM_RIPEMD128_HMAC) + CT(CKM_RIPEMD128_HMAC_GENERAL) + CT(CKM_RIPEMD160) + CT(CKM_RIPEMD160_HMAC) + CT(CKM_RIPEMD160_HMAC_GENERAL) + CT(CKM_SHA256) + CT(CKM_SHA256_HMAC) + CT(CKM_SHA256_HMAC_GENERAL) + CT(CKM_SHA384) + CT(CKM_SHA384_HMAC) + CT(CKM_SHA384_HMAC_GENERAL) + CT(CKM_SHA512) + CT(CKM_SHA512_HMAC) + CT(CKM_SHA512_HMAC_GENERAL) + CT(CKM_CAST_KEY_GEN) + CT(CKM_CAST_ECB) + CT(CKM_CAST_CBC) + CT(CKM_CAST_MAC) + CT(CKM_CAST_MAC_GENERAL) + CT(CKM_CAST_CBC_PAD) + CT(CKM_CAST3_KEY_GEN) + CT(CKM_CAST3_ECB) + CT(CKM_CAST3_CBC) + CT(CKM_CAST3_MAC) + CT(CKM_CAST3_MAC_GENERAL) + CT(CKM_CAST3_CBC_PAD) + CT(CKM_CAST5_KEY_GEN) + /* CT(CKM_CAST128_KEY_GEN) */ + CT(CKM_CAST5_ECB) + /* CT(CKM_CAST128_ECB) */ + CT(CKM_CAST5_CBC) + /* CT(CKM_CAST128_CBC) */ + CT(CKM_CAST5_MAC) + /* CT(CKM_CAST128_MAC) */ + CT(CKM_CAST5_MAC_GENERAL) + /* CT(CKM_CAST128_MAC_GENERAL) */ + CT(CKM_CAST5_CBC_PAD) + /* CT(CKM_CAST128_CBC_PAD) */ + CT(CKM_RC5_KEY_GEN) + CT(CKM_RC5_ECB) + CT(CKM_RC5_CBC) + CT(CKM_RC5_MAC) + CT(CKM_RC5_MAC_GENERAL) + CT(CKM_RC5_CBC_PAD) + CT(CKM_IDEA_KEY_GEN) + CT(CKM_IDEA_ECB) + CT(CKM_IDEA_CBC) + CT(CKM_IDEA_MAC) + CT(CKM_IDEA_MAC_GENERAL) + CT(CKM_IDEA_CBC_PAD) + CT(CKM_GENERIC_SECRET_KEY_GEN) + CT(CKM_CONCATENATE_BASE_AND_KEY) + CT(CKM_CONCATENATE_BASE_AND_DATA) + CT(CKM_CONCATENATE_DATA_AND_BASE) + CT(CKM_XOR_BASE_AND_DATA) + CT(CKM_EXTRACT_KEY_FROM_KEY) + CT(CKM_SSL3_PRE_MASTER_KEY_GEN) + CT(CKM_SSL3_MASTER_KEY_DERIVE) + CT(CKM_SSL3_KEY_AND_MAC_DERIVE) + CT(CKM_SSL3_MASTER_KEY_DERIVE_DH) + CT(CKM_TLS_PRE_MASTER_KEY_GEN) + CT(CKM_TLS_MASTER_KEY_DERIVE) + CT(CKM_TLS_KEY_AND_MAC_DERIVE) + CT(CKM_TLS_MASTER_KEY_DERIVE_DH) + CT(CKM_TLS_PRF) + CT(CKM_SSL3_MD5_MAC) + CT(CKM_SSL3_SHA1_MAC) + CT(CKM_MD5_KEY_DERIVATION) + CT(CKM_MD2_KEY_DERIVATION) + CT(CKM_SHA1_KEY_DERIVATION) + CT(CKM_SHA256_KEY_DERIVATION) + CT(CKM_SHA384_KEY_DERIVATION) + CT(CKM_SHA512_KEY_DERIVATION) + CT(CKM_PBE_MD2_DES_CBC) + CT(CKM_PBE_MD5_DES_CBC) + CT(CKM_PBE_MD5_CAST_CBC) + CT(CKM_PBE_MD5_CAST3_CBC) + CT(CKM_PBE_MD5_CAST5_CBC) + /* CT(CKM_PBE_MD5_CAST128_CBC) */ + CT(CKM_PBE_SHA1_CAST5_CBC) + /* CT(CKM_PBE_SHA1_CAST128_CBC) */ + CT(CKM_PBE_SHA1_RC4_128) + CT(CKM_PBE_SHA1_RC4_40) + CT(CKM_PBE_SHA1_DES3_EDE_CBC) + CT(CKM_PBE_SHA1_DES2_EDE_CBC) + CT(CKM_PBE_SHA1_RC2_128_CBC) + CT(CKM_PBE_SHA1_RC2_40_CBC) + CT(CKM_PKCS5_PBKD2) + CT(CKM_PBA_SHA1_WITH_SHA1_HMAC) + CT(CKM_WTLS_PRE_MASTER_KEY_GEN) + CT(CKM_WTLS_MASTER_KEY_DERIVE) + CT(CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC) + CT(CKM_WTLS_PRF) + CT(CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE) + CT(CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE) + CT(CKM_KEY_WRAP_LYNKS) + CT(CKM_KEY_WRAP_SET_OAEP) + CT(CKM_CMS_SIG) + CT(CKM_SKIPJACK_KEY_GEN) + CT(CKM_SKIPJACK_ECB64) + CT(CKM_SKIPJACK_CBC64) + CT(CKM_SKIPJACK_OFB64) + CT(CKM_SKIPJACK_CFB64) + CT(CKM_SKIPJACK_CFB32) + CT(CKM_SKIPJACK_CFB16) + CT(CKM_SKIPJACK_CFB8) + CT(CKM_SKIPJACK_WRAP) + CT(CKM_SKIPJACK_PRIVATE_WRAP) + CT(CKM_SKIPJACK_RELAYX) + CT(CKM_KEA_KEY_PAIR_GEN) + CT(CKM_KEA_KEY_DERIVE) + CT(CKM_FORTEZZA_TIMESTAMP) + CT(CKM_BATON_KEY_GEN) + CT(CKM_BATON_ECB128) + CT(CKM_BATON_ECB96) + CT(CKM_BATON_CBC128) + CT(CKM_BATON_COUNTER) + CT(CKM_BATON_SHUFFLE) + CT(CKM_BATON_WRAP) + CT(CKM_ECDSA_KEY_PAIR_GEN) + /* CT(CKM_EC_KEY_PAIR_GEN) */ + CT(CKM_ECDSA) + CT(CKM_ECDSA_SHA1) + CT(CKM_ECDH1_DERIVE) + CT(CKM_ECDH1_COFACTOR_DERIVE) + CT(CKM_ECMQV_DERIVE) + CT(CKM_JUNIPER_KEY_GEN) + CT(CKM_JUNIPER_ECB128) + CT(CKM_JUNIPER_CBC128) + CT(CKM_JUNIPER_COUNTER) + CT(CKM_JUNIPER_SHUFFLE) + CT(CKM_JUNIPER_WRAP) + CT(CKM_FASTHASH) + CT(CKM_AES_KEY_GEN) + CT(CKM_AES_ECB) + CT(CKM_AES_CBC) + CT(CKM_AES_MAC) + CT(CKM_AES_MAC_GENERAL) + CT(CKM_AES_CBC_PAD) + CT(CKM_BLOWFISH_KEY_GEN) + CT(CKM_BLOWFISH_CBC) + CT(CKM_TWOFISH_KEY_GEN) + CT(CKM_TWOFISH_CBC) + CT(CKM_DES_ECB_ENCRYPT_DATA) + CT(CKM_DES_CBC_ENCRYPT_DATA) + CT(CKM_DES3_ECB_ENCRYPT_DATA) + CT(CKM_DES3_CBC_ENCRYPT_DATA) + CT(CKM_AES_ECB_ENCRYPT_DATA) + CT(CKM_AES_CBC_ENCRYPT_DATA) + CT(CKM_DSA_PARAMETER_GEN) + CT(CKM_DH_PKCS_PARAMETER_GEN) + CT(CKM_X9_42_DH_PARAMETER_GEN) + CT(CKM_VENDOR_DEFINED) + default: + cklog("CKM_0x%08X", v); + break; + } +} + +static void +log_CKS(CK_STATE v) +{ + switch(v) { + CT(CKS_RO_PUBLIC_SESSION) + CT(CKS_RO_USER_FUNCTIONS) + CT(CKS_RW_PUBLIC_SESSION) + CT(CKS_RW_USER_FUNCTIONS) + CT(CKS_RW_SO_FUNCTIONS) + default: + cklog("CKS_0x%08X", v); + break; + } +} + +static void +log_CKU(CK_USER_TYPE v) +{ + switch(v) { + CT(CKU_SO) + CT(CKU_USER) + CT(CKU_CONTEXT_SPECIFIC) + default: + cklog("CKA_0x%08X", v); + break; + } +} + +static void +log_CKR(CK_RV v) +{ + switch(v) { + CT(CKR_OK) + CT(CKR_CANCEL) + CT(CKR_HOST_MEMORY) + CT(CKR_SLOT_ID_INVALID) + CT(CKR_GENERAL_ERROR) + CT(CKR_FUNCTION_FAILED) + CT(CKR_ARGUMENTS_BAD) + CT(CKR_NO_EVENT) + CT(CKR_NEED_TO_CREATE_THREADS) + CT(CKR_CANT_LOCK) + CT(CKR_ATTRIBUTE_READ_ONLY) + CT(CKR_ATTRIBUTE_SENSITIVE) + CT(CKR_ATTRIBUTE_TYPE_INVALID) + CT(CKR_ATTRIBUTE_VALUE_INVALID) + CT(CKR_DATA_INVALID) + CT(CKR_DATA_LEN_RANGE) + CT(CKR_DEVICE_ERROR) + CT(CKR_DEVICE_MEMORY) + CT(CKR_DEVICE_REMOVED) + CT(CKR_ENCRYPTED_DATA_INVALID) + CT(CKR_ENCRYPTED_DATA_LEN_RANGE) + CT(CKR_FUNCTION_CANCELED) + CT(CKR_FUNCTION_NOT_PARALLEL) + CT(CKR_FUNCTION_NOT_SUPPORTED) + CT(CKR_KEY_HANDLE_INVALID) + CT(CKR_KEY_SIZE_RANGE) + CT(CKR_KEY_TYPE_INCONSISTENT) + CT(CKR_KEY_NOT_NEEDED) + CT(CKR_KEY_CHANGED) + CT(CKR_KEY_NEEDED) + CT(CKR_KEY_INDIGESTIBLE) + CT(CKR_KEY_FUNCTION_NOT_PERMITTED) + CT(CKR_KEY_NOT_WRAPPABLE) + CT(CKR_KEY_UNEXTRACTABLE) + CT(CKR_MECHANISM_INVALID) + CT(CKR_MECHANISM_PARAM_INVALID) + CT(CKR_OBJECT_HANDLE_INVALID) + CT(CKR_OPERATION_ACTIVE) + CT(CKR_OPERATION_NOT_INITIALIZED) + CT(CKR_PIN_INCORRECT) + CT(CKR_PIN_INVALID) + CT(CKR_PIN_LEN_RANGE) + CT(CKR_PIN_EXPIRED) + CT(CKR_PIN_LOCKED) + CT(CKR_SESSION_CLOSED) + CT(CKR_SESSION_COUNT) + CT(CKR_SESSION_HANDLE_INVALID) + CT(CKR_SESSION_PARALLEL_NOT_SUPPORTED) + CT(CKR_SESSION_READ_ONLY) + CT(CKR_SESSION_EXISTS) + CT(CKR_SESSION_READ_ONLY_EXISTS) + CT(CKR_SESSION_READ_WRITE_SO_EXISTS) + CT(CKR_SIGNATURE_INVALID) + CT(CKR_SIGNATURE_LEN_RANGE) + CT(CKR_TEMPLATE_INCOMPLETE) + CT(CKR_TEMPLATE_INCONSISTENT) + CT(CKR_TOKEN_NOT_PRESENT) + CT(CKR_TOKEN_NOT_RECOGNIZED) + CT(CKR_TOKEN_WRITE_PROTECTED) + CT(CKR_UNWRAPPING_KEY_HANDLE_INVALID) + CT(CKR_UNWRAPPING_KEY_SIZE_RANGE) + CT(CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT) + CT(CKR_USER_ALREADY_LOGGED_IN) + CT(CKR_USER_NOT_LOGGED_IN) + CT(CKR_USER_PIN_NOT_INITIALIZED) + CT(CKR_USER_TYPE_INVALID) + CT(CKR_USER_ANOTHER_ALREADY_LOGGED_IN) + CT(CKR_USER_TOO_MANY_TYPES) + CT(CKR_WRAPPED_KEY_INVALID) + CT(CKR_WRAPPED_KEY_LEN_RANGE) + CT(CKR_WRAPPING_KEY_HANDLE_INVALID) + CT(CKR_WRAPPING_KEY_SIZE_RANGE) + CT(CKR_WRAPPING_KEY_TYPE_INCONSISTENT) + CT(CKR_RANDOM_SEED_NOT_SUPPORTED) + CT(CKR_RANDOM_NO_RNG) + CT(CKR_DOMAIN_PARAMS_INVALID) + CT(CKR_BUFFER_TOO_SMALL) + CT(CKR_SAVED_STATE_INVALID) + CT(CKR_INFORMATION_SENSITIVE) + CT(CKR_STATE_UNSAVEABLE) + CT(CKR_CRYPTOKI_NOT_INITIALIZED) + CT(CKR_CRYPTOKI_ALREADY_INITIALIZED) + CT(CKR_MUTEX_BAD) + CT(CKR_MUTEX_NOT_LOCKED) + CT(CKR_FUNCTION_REJECTED) + CT(CKR_VENDOR_DEFINED) + default: + cklog("CKR_0x%08X", v); + break; + } +} |