summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/attrs.c22
-rw-r--r--common/attrs.h9
-rw-r--r--common/constants.c350
-rw-r--r--common/constants.h8
-rw-r--r--common/tests/test-constants.c18
5 files changed, 387 insertions, 20 deletions
diff --git a/common/attrs.c b/common/attrs.c
index c1e060a..88906f4 100644
--- a/common/attrs.c
+++ b/common/attrs.c
@@ -808,10 +808,10 @@ format_some_bytes (p11_buffer *buffer,
p11_buffer_add (buffer, "\"", 1);
}
-static void
-format_attribute (p11_buffer *buffer,
- const CK_ATTRIBUTE *attr,
- CK_OBJECT_CLASS klass)
+void
+p11_attr_format (p11_buffer *buffer,
+ const CK_ATTRIBUTE *attr,
+ CK_OBJECT_CLASS klass)
{
p11_buffer_add (buffer, "{ ", -1);
format_attribute_type (buffer, attr->type);
@@ -839,10 +839,10 @@ format_attribute (p11_buffer *buffer,
p11_buffer_add (buffer, " }", -1);
}
-static void
-format_attributes (p11_buffer *buffer,
- const CK_ATTRIBUTE *attrs,
- int count)
+void
+p11_attrs_format (p11_buffer *buffer,
+ const CK_ATTRIBUTE *attrs,
+ int count)
{
CK_BBOOL first = CK_TRUE;
CK_OBJECT_CLASS klass;
@@ -861,7 +861,7 @@ format_attributes (p11_buffer *buffer,
else
p11_buffer_add (buffer, ", ", 2);
first = CK_FALSE;
- format_attribute (buffer, attrs + i, klass);
+ p11_attr_format (buffer, attrs + i, klass);
}
p11_buffer_add (buffer, " ]", -1);
}
@@ -873,7 +873,7 @@ p11_attrs_to_string (const CK_ATTRIBUTE *attrs,
p11_buffer buffer;
if (!p11_buffer_init_null (&buffer, 128))
return_val_if_reached (NULL);
- format_attributes (&buffer, attrs, count);
+ p11_attrs_format (&buffer, attrs, count);
return p11_buffer_steal (&buffer, NULL);
}
@@ -884,6 +884,6 @@ p11_attr_to_string (const CK_ATTRIBUTE *attr,
p11_buffer buffer;
if (!p11_buffer_init_null (&buffer, 32))
return_val_if_reached (NULL);
- format_attribute (&buffer, attr, klass);
+ p11_attr_format (&buffer, attr, klass);
return p11_buffer_steal (&buffer, NULL);
}
diff --git a/common/attrs.h b/common/attrs.h
index 233ac79..2780013 100644
--- a/common/attrs.h
+++ b/common/attrs.h
@@ -36,6 +36,7 @@
#ifndef P11_ATTRS_H_
#define P11_ATTRS_H_
+#include "buffer.h"
#include "compat.h"
#include "pkcs11.h"
@@ -112,9 +113,17 @@ bool p11_attrs_matchn (const CK_ATTRIBUTE *attrs,
char * p11_attrs_to_string (const CK_ATTRIBUTE *attrs,
int count);
+void p11_attrs_format (p11_buffer *buffer,
+ const CK_ATTRIBUTE *attrs,
+ int count);
+
char * p11_attr_to_string (const CK_ATTRIBUTE *attr,
CK_OBJECT_CLASS klass);
+void p11_attr_format (p11_buffer *buffer,
+ const CK_ATTRIBUTE *attr,
+ CK_OBJECT_CLASS klass);
+
bool p11_attr_equal (const void *one,
const void *two);
diff --git a/common/constants.c b/common/constants.c
index 918d3e5..ef92810 100644
--- a/common/constants.c
+++ b/common/constants.c
@@ -260,6 +260,338 @@ const p11_constant p11_constant_categories[] = {
{ CKA_INVALID },
};
+const p11_constant p11_constant_users[] = {
+ CT (CKU_SO, NULL)
+ CT (CKU_USER, NULL)
+ CT (CKU_CONTEXT_SPECIFIC, NULL)
+ { CKA_INVALID },
+};
+
+const p11_constant p11_constant_states[] = {
+ CT (CKS_RO_PUBLIC_SESSION, NULL)
+ CT (CKS_RO_USER_FUNCTIONS, NULL)
+ CT (CKS_RW_PUBLIC_SESSION, NULL)
+ CT (CKS_RW_USER_FUNCTIONS, NULL)
+ CT (CKS_RW_SO_FUNCTIONS, NULL)
+ { CKA_INVALID },
+};
+
+const p11_constant p11_constant_returns[] = {
+ CT (CKR_OK, NULL)
+ CT (CKR_CANCEL, NULL)
+ CT (CKR_HOST_MEMORY, NULL)
+ CT (CKR_SLOT_ID_INVALID, NULL)
+ CT (CKR_GENERAL_ERROR, NULL)
+ CT (CKR_FUNCTION_FAILED, NULL)
+ CT (CKR_ARGUMENTS_BAD, NULL)
+ CT (CKR_NO_EVENT, NULL)
+ CT (CKR_NEED_TO_CREATE_THREADS, NULL)
+ CT (CKR_CANT_LOCK, NULL)
+ CT (CKR_ATTRIBUTE_READ_ONLY, NULL)
+ CT (CKR_ATTRIBUTE_SENSITIVE, NULL)
+ CT (CKR_ATTRIBUTE_TYPE_INVALID, NULL)
+ CT (CKR_ATTRIBUTE_VALUE_INVALID, NULL)
+ CT (CKR_DATA_INVALID, NULL)
+ CT (CKR_DATA_LEN_RANGE, NULL)
+ CT (CKR_DEVICE_ERROR, NULL)
+ CT (CKR_DEVICE_MEMORY, NULL)
+ CT (CKR_DEVICE_REMOVED, NULL)
+ CT (CKR_ENCRYPTED_DATA_INVALID, NULL)
+ CT (CKR_ENCRYPTED_DATA_LEN_RANGE, NULL)
+ CT (CKR_FUNCTION_CANCELED, NULL)
+ CT (CKR_FUNCTION_NOT_PARALLEL, NULL)
+ CT (CKR_FUNCTION_NOT_SUPPORTED, NULL)
+ CT (CKR_KEY_HANDLE_INVALID, NULL)
+ CT (CKR_KEY_SIZE_RANGE, NULL)
+ CT (CKR_KEY_TYPE_INCONSISTENT, NULL)
+ CT (CKR_KEY_NOT_NEEDED, NULL)
+ CT (CKR_KEY_CHANGED, NULL)
+ CT (CKR_KEY_NEEDED, NULL)
+ CT (CKR_KEY_INDIGESTIBLE, NULL)
+ CT (CKR_KEY_FUNCTION_NOT_PERMITTED, NULL)
+ CT (CKR_KEY_NOT_WRAPPABLE, NULL)
+ CT (CKR_KEY_UNEXTRACTABLE, NULL)
+ CT (CKR_MECHANISM_INVALID, NULL)
+ CT (CKR_MECHANISM_PARAM_INVALID, NULL)
+ CT (CKR_OBJECT_HANDLE_INVALID, NULL)
+ CT (CKR_OPERATION_ACTIVE, NULL)
+ CT (CKR_OPERATION_NOT_INITIALIZED, NULL)
+ CT (CKR_PIN_INCORRECT, NULL)
+ CT (CKR_PIN_INVALID, NULL)
+ CT (CKR_PIN_LEN_RANGE, NULL)
+ CT (CKR_PIN_EXPIRED, NULL)
+ CT (CKR_PIN_LOCKED, NULL)
+ CT (CKR_SESSION_CLOSED, NULL)
+ CT (CKR_SESSION_COUNT, NULL)
+ CT (CKR_SESSION_HANDLE_INVALID, NULL)
+ CT (CKR_SESSION_PARALLEL_NOT_SUPPORTED, NULL)
+ CT (CKR_SESSION_READ_ONLY, NULL)
+ CT (CKR_SESSION_EXISTS, NULL)
+ CT (CKR_SESSION_READ_ONLY_EXISTS, NULL)
+ CT (CKR_SESSION_READ_WRITE_SO_EXISTS, NULL)
+ CT (CKR_SIGNATURE_INVALID, NULL)
+ CT (CKR_SIGNATURE_LEN_RANGE, NULL)
+ CT (CKR_TEMPLATE_INCOMPLETE, NULL)
+ CT (CKR_TEMPLATE_INCONSISTENT, NULL)
+ CT (CKR_TOKEN_NOT_PRESENT, NULL)
+ CT (CKR_TOKEN_NOT_RECOGNIZED, NULL)
+ CT (CKR_TOKEN_WRITE_PROTECTED, NULL)
+ CT (CKR_UNWRAPPING_KEY_HANDLE_INVALID, NULL)
+ CT (CKR_UNWRAPPING_KEY_SIZE_RANGE, NULL)
+ CT (CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT, NULL)
+ CT (CKR_USER_ALREADY_LOGGED_IN, NULL)
+ CT (CKR_USER_NOT_LOGGED_IN, NULL)
+ CT (CKR_USER_PIN_NOT_INITIALIZED, NULL)
+ CT (CKR_USER_TYPE_INVALID, NULL)
+ CT (CKR_USER_ANOTHER_ALREADY_LOGGED_IN, NULL)
+ CT (CKR_USER_TOO_MANY_TYPES, NULL)
+ CT (CKR_WRAPPED_KEY_INVALID, NULL)
+ CT (CKR_WRAPPED_KEY_LEN_RANGE, NULL)
+ CT (CKR_WRAPPING_KEY_HANDLE_INVALID, NULL)
+ CT (CKR_WRAPPING_KEY_SIZE_RANGE, NULL)
+ CT (CKR_WRAPPING_KEY_TYPE_INCONSISTENT, NULL)
+ CT (CKR_RANDOM_SEED_NOT_SUPPORTED, NULL)
+ CT (CKR_RANDOM_NO_RNG, NULL)
+ CT (CKR_DOMAIN_PARAMS_INVALID, NULL)
+ CT (CKR_BUFFER_TOO_SMALL, NULL)
+ CT (CKR_SAVED_STATE_INVALID, NULL)
+ CT (CKR_INFORMATION_SENSITIVE, NULL)
+ CT (CKR_STATE_UNSAVEABLE, NULL)
+ CT (CKR_CRYPTOKI_NOT_INITIALIZED, NULL)
+ CT (CKR_CRYPTOKI_ALREADY_INITIALIZED, NULL)
+ CT (CKR_MUTEX_BAD, NULL)
+ CT (CKR_MUTEX_NOT_LOCKED, NULL)
+ CT (CKR_FUNCTION_REJECTED, NULL)
+ { CKA_INVALID },
+};
+
+const p11_constant p11_constant_mechanisms[] = {
+ CT (CKM_RSA_PKCS_KEY_PAIR_GEN, NULL)
+ CT (CKM_RSA_PKCS, NULL)
+ CT (CKM_RSA_9796, NULL)
+ CT (CKM_RSA_X_509, NULL)
+ CT (CKM_MD2_RSA_PKCS, NULL)
+ CT (CKM_MD5_RSA_PKCS, NULL)
+ CT (CKM_SHA1_RSA_PKCS, NULL)
+ CT (CKM_RIPEMD128_RSA_PKCS, NULL)
+ CT (CKM_RIPEMD160_RSA_PKCS, NULL)
+ CT (CKM_RSA_PKCS_OAEP, NULL)
+ CT (CKM_RSA_X9_31_KEY_PAIR_GEN, NULL)
+ CT (CKM_RSA_X9_31, NULL)
+ CT (CKM_SHA1_RSA_X9_31, NULL)
+ CT (CKM_RSA_PKCS_PSS, NULL)
+ CT (CKM_SHA1_RSA_PKCS_PSS, NULL)
+ CT (CKM_DSA_KEY_PAIR_GEN, NULL)
+ CT (CKM_DSA, NULL)
+ CT (CKM_DSA_SHA1, NULL)
+ CT (CKM_DH_PKCS_KEY_PAIR_GEN, NULL)
+ CT (CKM_DH_PKCS_DERIVE, NULL)
+ CT (CKM_X9_42_DH_KEY_PAIR_GEN, NULL)
+ CT (CKM_X9_42_DH_DERIVE, NULL)
+ CT (CKM_X9_42_DH_HYBRID_DERIVE, NULL)
+ CT (CKM_X9_42_MQV_DERIVE, NULL)
+ CT (CKM_SHA256_RSA_PKCS, NULL)
+ CT (CKM_SHA384_RSA_PKCS, NULL)
+ CT (CKM_SHA512_RSA_PKCS, NULL)
+ CT (CKM_SHA256_RSA_PKCS_PSS, NULL)
+ CT (CKM_SHA384_RSA_PKCS_PSS, NULL)
+ CT (CKM_SHA512_RSA_PKCS_PSS, NULL)
+ CT (CKM_RC2_KEY_GEN, NULL)
+ CT (CKM_RC2_ECB, NULL)
+ CT (CKM_RC2_CBC, NULL)
+ CT (CKM_RC2_MAC, NULL)
+ CT (CKM_RC2_MAC_GENERAL, NULL)
+ CT (CKM_RC2_CBC_PAD, NULL)
+ CT (CKM_RC4_KEY_GEN, NULL)
+ CT (CKM_RC4, NULL)
+ CT (CKM_DES_KEY_GEN, NULL)
+ CT (CKM_DES_ECB, NULL)
+ CT (CKM_DES_CBC, NULL)
+ CT (CKM_DES_MAC, NULL)
+ CT (CKM_DES_MAC_GENERAL, NULL)
+ CT (CKM_DES_CBC_PAD, NULL)
+ CT (CKM_DES2_KEY_GEN, NULL)
+ CT (CKM_DES3_KEY_GEN, NULL)
+ CT (CKM_DES3_ECB, NULL)
+ CT (CKM_DES3_CBC, NULL)
+ CT (CKM_DES3_MAC, NULL)
+ CT (CKM_DES3_MAC_GENERAL, NULL)
+ CT (CKM_DES3_CBC_PAD, NULL)
+ CT (CKM_CDMF_KEY_GEN, NULL)
+ CT (CKM_CDMF_ECB, NULL)
+ CT (CKM_CDMF_CBC, NULL)
+ CT (CKM_CDMF_MAC, NULL)
+ CT (CKM_CDMF_MAC_GENERAL, NULL)
+ CT (CKM_CDMF_CBC_PAD, NULL)
+ CT (CKM_DES_OFB64, NULL)
+ CT (CKM_DES_OFB8, NULL)
+ CT (CKM_DES_CFB64, NULL)
+ CT (CKM_DES_CFB8, NULL)
+ CT (CKM_MD2, NULL)
+ CT (CKM_MD2_HMAC, NULL)
+ CT (CKM_MD2_HMAC_GENERAL, NULL)
+ CT (CKM_MD5, NULL)
+ CT (CKM_MD5_HMAC, NULL)
+ CT (CKM_MD5_HMAC_GENERAL, NULL)
+ CT (CKM_SHA_1, NULL)
+ CT (CKM_SHA_1_HMAC, NULL)
+ CT (CKM_SHA_1_HMAC_GENERAL, NULL)
+ CT (CKM_RIPEMD128, NULL)
+ CT (CKM_RIPEMD128_HMAC, NULL)
+ CT (CKM_RIPEMD128_HMAC_GENERAL, NULL)
+ CT (CKM_RIPEMD160, NULL)
+ CT (CKM_RIPEMD160_HMAC, NULL)
+ CT (CKM_RIPEMD160_HMAC_GENERAL, NULL)
+ CT (CKM_SHA256, NULL)
+ CT (CKM_SHA256_HMAC, NULL)
+ CT (CKM_SHA256_HMAC_GENERAL, NULL)
+ CT (CKM_SHA384, NULL)
+ CT (CKM_SHA384_HMAC, NULL)
+ CT (CKM_SHA384_HMAC_GENERAL, NULL)
+ CT (CKM_SHA512, NULL)
+ CT (CKM_SHA512_HMAC, NULL)
+ CT (CKM_SHA512_HMAC_GENERAL, NULL)
+ CT (CKM_CAST_KEY_GEN, NULL)
+ CT (CKM_CAST_ECB, NULL)
+ CT (CKM_CAST_CBC, NULL)
+ CT (CKM_CAST_MAC, NULL)
+ CT (CKM_CAST_MAC_GENERAL, NULL)
+ CT (CKM_CAST_CBC_PAD, NULL)
+ CT (CKM_CAST3_KEY_GEN, NULL)
+ CT (CKM_CAST3_ECB, NULL)
+ CT (CKM_CAST3_CBC, NULL)
+ CT (CKM_CAST3_MAC, NULL)
+ CT (CKM_CAST3_MAC_GENERAL, NULL)
+ CT (CKM_CAST3_CBC_PAD, NULL)
+ CT (CKM_CAST5_KEY_GEN, NULL)
+ /* CT (CKM_CAST128_KEY_GEN) */
+ CT (CKM_CAST5_ECB, NULL)
+ /* CT (CKM_CAST128_ECB) */
+ CT (CKM_CAST5_CBC, NULL)
+ /* CT (CKM_CAST128_CBC) */
+ CT (CKM_CAST5_MAC, NULL)
+ /* CT (CKM_CAST128_MAC) */
+ CT (CKM_CAST5_MAC_GENERAL, NULL)
+ /* CT (CKM_CAST128_MAC_GENERAL) */
+ CT (CKM_CAST5_CBC_PAD, NULL)
+ /* CT (CKM_CAST128_CBC_PAD) */
+ CT (CKM_RC5_KEY_GEN, NULL)
+ CT (CKM_RC5_ECB, NULL)
+ CT (CKM_RC5_CBC, NULL)
+ CT (CKM_RC5_MAC, NULL)
+ CT (CKM_RC5_MAC_GENERAL, NULL)
+ CT (CKM_RC5_CBC_PAD, NULL)
+ CT (CKM_IDEA_KEY_GEN, NULL)
+ CT (CKM_IDEA_ECB, NULL)
+ CT (CKM_IDEA_CBC, NULL)
+ CT (CKM_IDEA_MAC, NULL)
+ CT (CKM_IDEA_MAC_GENERAL, NULL)
+ CT (CKM_IDEA_CBC_PAD, NULL)
+ CT (CKM_GENERIC_SECRET_KEY_GEN, NULL)
+ CT (CKM_CONCATENATE_BASE_AND_KEY, NULL)
+ CT (CKM_CONCATENATE_BASE_AND_DATA, NULL)
+ CT (CKM_CONCATENATE_DATA_AND_BASE, NULL)
+ CT (CKM_XOR_BASE_AND_DATA, NULL)
+ CT (CKM_EXTRACT_KEY_FROM_KEY, NULL)
+ CT (CKM_SSL3_PRE_MASTER_KEY_GEN, NULL)
+ CT (CKM_SSL3_MASTER_KEY_DERIVE, NULL)
+ CT (CKM_SSL3_KEY_AND_MAC_DERIVE, NULL)
+ CT (CKM_SSL3_MASTER_KEY_DERIVE_DH, NULL)
+ CT (CKM_TLS_PRE_MASTER_KEY_GEN, NULL)
+ CT (CKM_TLS_MASTER_KEY_DERIVE, NULL)
+ CT (CKM_TLS_KEY_AND_MAC_DERIVE, NULL)
+ CT (CKM_TLS_MASTER_KEY_DERIVE_DH, NULL)
+ /* CT (CKM_TLS_PRF) */
+ CT (CKM_SSL3_MD5_MAC, NULL)
+ CT (CKM_SSL3_SHA1_MAC, NULL)
+ CT (CKM_MD5_KEY_DERIVATION, NULL)
+ CT (CKM_MD2_KEY_DERIVATION, NULL)
+ CT (CKM_SHA1_KEY_DERIVATION, NULL)
+ CT (CKM_SHA256_KEY_DERIVATION, NULL)
+ CT (CKM_SHA384_KEY_DERIVATION, NULL)
+ CT (CKM_SHA512_KEY_DERIVATION, NULL)
+ CT (CKM_PBE_MD2_DES_CBC, NULL)
+ CT (CKM_PBE_MD5_DES_CBC, NULL)
+ CT (CKM_PBE_MD5_CAST_CBC, NULL)
+ CT (CKM_PBE_MD5_CAST3_CBC, NULL)
+ CT (CKM_PBE_MD5_CAST5_CBC, NULL)
+ /* CT (CKM_PBE_MD5_CAST128_CBC) */
+ CT (CKM_PBE_SHA1_CAST5_CBC, NULL)
+ /* CT (CKM_PBE_SHA1_CAST128_CBC) */
+ CT (CKM_PBE_SHA1_RC4_128, NULL)
+ CT (CKM_PBE_SHA1_RC4_40, NULL)
+ CT (CKM_PBE_SHA1_DES3_EDE_CBC, NULL)
+ CT (CKM_PBE_SHA1_DES2_EDE_CBC, NULL)
+ CT (CKM_PBE_SHA1_RC2_128_CBC, NULL)
+ CT (CKM_PBE_SHA1_RC2_40_CBC, NULL)
+ CT (CKM_PKCS5_PBKD2, NULL)
+ CT (CKM_PBA_SHA1_WITH_SHA1_HMAC, NULL)
+ CT (CKM_WTLS_PRE_MASTER_KEY_GEN, NULL)
+ CT (CKM_WTLS_MASTER_KEY_DERIVE, NULL)
+ CT (CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC, NULL)
+ CT (CKM_WTLS_PRF, NULL)
+ CT (CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE, NULL)
+ CT (CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE, NULL)
+ CT (CKM_KEY_WRAP_LYNKS, NULL)
+ CT (CKM_KEY_WRAP_SET_OAEP, NULL)
+ CT (CKM_CMS_SIG, NULL)
+ CT (CKM_SKIPJACK_KEY_GEN, NULL)
+ CT (CKM_SKIPJACK_ECB64, NULL)
+ CT (CKM_SKIPJACK_CBC64, NULL)
+ CT (CKM_SKIPJACK_OFB64, NULL)
+ CT (CKM_SKIPJACK_CFB64, NULL)
+ CT (CKM_SKIPJACK_CFB32, NULL)
+ CT (CKM_SKIPJACK_CFB16, NULL)
+ CT (CKM_SKIPJACK_CFB8, NULL)
+ CT (CKM_SKIPJACK_WRAP, NULL)
+ CT (CKM_SKIPJACK_PRIVATE_WRAP, NULL)
+ CT (CKM_SKIPJACK_RELAYX, NULL)
+ CT (CKM_KEA_KEY_PAIR_GEN, NULL)
+ CT (CKM_KEA_KEY_DERIVE, NULL)
+ CT (CKM_FORTEZZA_TIMESTAMP, NULL)
+ CT (CKM_BATON_KEY_GEN, NULL)
+ CT (CKM_BATON_ECB128, NULL)
+ CT (CKM_BATON_ECB96, NULL)
+ CT (CKM_BATON_CBC128, NULL)
+ CT (CKM_BATON_COUNTER, NULL)
+ CT (CKM_BATON_SHUFFLE, NULL)
+ CT (CKM_BATON_WRAP, NULL)
+ CT (CKM_ECDSA_KEY_PAIR_GEN, NULL)
+ /* CT (CKM_EC_KEY_PAIR_GEN) */
+ CT (CKM_ECDSA, NULL)
+ CT (CKM_ECDSA_SHA1, NULL)
+ CT (CKM_ECDH1_DERIVE, NULL)
+ CT (CKM_ECDH1_COFACTOR_DERIVE, NULL)
+ CT (CKM_ECMQV_DERIVE, NULL)
+ CT (CKM_JUNIPER_KEY_GEN, NULL)
+ CT (CKM_JUNIPER_ECB128, NULL)
+ CT (CKM_JUNIPER_CBC128, NULL)
+ CT (CKM_JUNIPER_COUNTER, NULL)
+ CT (CKM_JUNIPER_SHUFFLE, NULL)
+ CT (CKM_JUNIPER_WRAP, NULL)
+ CT (CKM_FASTHASH, NULL)
+ CT (CKM_AES_KEY_GEN, NULL)
+ CT (CKM_AES_ECB, NULL)
+ CT (CKM_AES_CBC, NULL)
+ CT (CKM_AES_MAC, NULL)
+ CT (CKM_AES_MAC_GENERAL, NULL)
+ CT (CKM_AES_CBC_PAD, NULL)
+ CT (CKM_BLOWFISH_KEY_GEN, NULL)
+ CT (CKM_BLOWFISH_CBC, NULL)
+ CT (CKM_TWOFISH_KEY_GEN, NULL)
+ CT (CKM_TWOFISH_CBC, NULL)
+ CT (CKM_DES_ECB_ENCRYPT_DATA, NULL)
+ CT (CKM_DES_CBC_ENCRYPT_DATA, NULL)
+ CT (CKM_DES3_ECB_ENCRYPT_DATA, NULL)
+ CT (CKM_DES3_CBC_ENCRYPT_DATA, NULL)
+ CT (CKM_AES_ECB_ENCRYPT_DATA, NULL)
+ CT (CKM_AES_CBC_ENCRYPT_DATA, NULL)
+ CT (CKM_DSA_PARAMETER_GEN, NULL)
+ CT (CKM_DH_PKCS_PARAMETER_GEN, NULL)
+ CT (CKM_X9_42_DH_PARAMETER_GEN, NULL)
+ { CKA_INVALID },
+};
+
#undef CT
struct {
@@ -272,7 +604,11 @@ struct {
{ p11_constant_certs, ELEMS (p11_constant_certs) - 1 },
{ p11_constant_keys, ELEMS (p11_constant_keys) - 1 },
{ p11_constant_asserts, ELEMS (p11_constant_asserts) - 1 },
- { p11_constant_categories, ELEMS (p11_constant_categories) - 1 }
+ { p11_constant_categories, ELEMS (p11_constant_categories) - 1 },
+ { p11_constant_mechanisms, ELEMS (p11_constant_mechanisms) - 1 },
+ { p11_constant_states, ELEMS (p11_constant_states) - 1 },
+ { p11_constant_users, ELEMS (p11_constant_users) - 1 },
+ { p11_constant_returns, ELEMS (p11_constant_returns) - 1 },
};
static int
@@ -328,6 +664,7 @@ p11_constant_reverse (bool nick)
{
const p11_constant *table;
p11_dict *lookups;
+ void *string;
int length = -1;
int i, j;
@@ -339,9 +676,14 @@ p11_constant_reverse (bool nick)
length = tables[i].length;
for (j = 0; j < length; j++) {
- if (!p11_dict_set (lookups,
- nick ? (void *)table[j].nick : (void *)table[j].name,
- (void *)&table[j].value))
+ if (nick) {
+ if (!table[j].nick)
+ continue;
+ string = (void *)table[j].nick;
+ } else {
+ string = (void *)table[j].name;
+ }
+ if (!p11_dict_set (lookups, string, (void *)&table[j].value))
return_val_if_reached (NULL);
}
}
diff --git a/common/constants.h b/common/constants.h
index 82a0879..5b0f3a5 100644
--- a/common/constants.h
+++ b/common/constants.h
@@ -71,4 +71,12 @@ extern const p11_constant p11_constant_asserts[];
extern const p11_constant p11_constant_categories[];
+extern const p11_constant p11_constant_mechanisms[];
+
+extern const p11_constant p11_constant_states[];
+
+extern const p11_constant p11_constant_users[];
+
+extern const p11_constant p11_constant_returns[];
+
#endif /* P11_CONSTANTS_H_ */
diff --git a/common/tests/test-constants.c b/common/tests/test-constants.c
index 4cd4472..4c2f3eb 100644
--- a/common/tests/test-constants.c
+++ b/common/tests/test-constants.c
@@ -59,6 +59,10 @@ test_constants (CuTest *tc)
p11_constant_keys,
p11_constant_asserts,
p11_constant_categories,
+ p11_constant_mechanisms,
+ p11_constant_users,
+ p11_constant_states,
+ p11_constant_returns,
NULL
};
@@ -74,16 +78,20 @@ test_constants (CuTest *tc)
}
}
for (i = 0; constant[i].value != CKA_INVALID; i++) {
- CuAssertPtrNotNull (tc, constant[i].nick);
CuAssertPtrNotNull (tc, constant[i].name);
- CuAssertStrEquals (tc, constant[i].nick,
- p11_constant_nick (constant, constant[i].value));
+ if (constant[i].nick) {
+ CuAssertStrEquals (tc, constant[i].nick,
+ p11_constant_nick (constant, constant[i].value));
+ }
+
CuAssertStrEquals (tc, constant[i].name,
p11_constant_name (constant, constant[i].value));
- check = p11_constant_resolve (nicks, constant[i].nick);
- CuAssertIntEquals (tc, constant[i].value, check);
+ if (constant[i].nick) {
+ check = p11_constant_resolve (nicks, constant[i].nick);
+ CuAssertIntEquals (tc, constant[i].value, check);
+ }
check = p11_constant_resolve (names, constant[i].name);
CuAssertIntEquals (tc, constant[i].value, check);