diff options
author | Stef Walter <stef@memberwebs.com> | 2008-12-09 18:57:59 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2008-12-09 18:57:59 +0000 |
commit | 128d6627d8a03544137ada01934bf62934982172 (patch) | |
tree | 97e3a2302a50759b630b043d4fc0b4e7f27d4a90 | |
parent | f22ca594d066f305c5c289dc522b2a13917234d0 (diff) |
Better handling of attribute data types. Remove concept of a date type.
-rw-r--r-- | ckcapi-builtin.c | 1 | ||||
-rw-r--r-- | ckcapi-cert.c | 46 | ||||
-rw-r--r-- | ckcapi-key.c | 60 | ||||
-rw-r--r-- | ckcapi-object.c | 14 | ||||
-rw-r--r-- | ckcapi-object.h | 1 | ||||
-rw-r--r-- | ckcapi-trust.c | 7 |
6 files changed, 13 insertions, 116 deletions
diff --git a/ckcapi-builtin.c b/ckcapi-builtin.c index 7bfc0a0..7d92f81 100644 --- a/ckcapi-builtin.c +++ b/ckcapi-builtin.c @@ -120,7 +120,6 @@ static const CkCapiObjectDataVtable builtin_objdata_vtable = { builtin_attribute, builtin_attribute, builtin_attribute, - builtin_attribute, builtin_data_release, }; diff --git a/ckcapi-cert.c b/ckcapi-cert.c index e7edde7..5225286 100644 --- a/ckcapi-cert.c +++ b/ckcapi-cert.c @@ -233,39 +233,6 @@ cert_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr) return ckcapi_cert_certificate_get_bytes(cdata->cert, attr); } -static CK_RV -cert_date_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr) -{ - CertObjectData* cdata = (CertObjectData*)objdata; - FILETIME* ftime; - - ASSERT(cdata); - ASSERT(cdata->cert); - ASSERT(attr); - - switch(attr->type) - { - /* - * Start date for the certificate. - */ - case CKA_START_DATE: - ftime = &cdata->cert->pCertInfo->NotBefore; - break; - - /* - * End date for the certificate. - */ - case CKA_END_DATE: - ftime = &cdata->cert->pCertInfo->NotAfter; - break; - - default: - return CKR_ATTRIBUTE_TYPE_INVALID; - }; - - return ckcapi_return_filetime(attr, ftime); -} - static void cert_data_release(void* data) { @@ -279,7 +246,6 @@ static const CkCapiObjectDataVtable cert_objdata_vtable = { cert_bool_attribute, cert_ulong_attribute, cert_bytes_attribute, - cert_date_attribute, cert_data_release, }; @@ -560,7 +526,17 @@ ckcapi_cert_certificate_get_bytes(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr) case CKA_HASH_OF_ISSUER_PUBLIC_KEY: return ckcapi_return_data(attr, "", 0); - /* Not supported */ + /* + * Start date for the certificate. + */ + case CKA_START_DATE: + return ckcapi_return_filetime(attr, &cert->pCertInfo->NotBefore); + + /* + * End date for the certificate. + */ + case CKA_END_DATE: + return ckcapi_return_filetime(attr, &cert->pCertInfo->NotAfter); default: return CKR_ATTRIBUTE_TYPE_INVALID; diff --git a/ckcapi-key.c b/ckcapi-key.c index abf37de..69c845d 100644 --- a/ckcapi-key.c +++ b/ckcapi-key.c @@ -25,55 +25,6 @@ #include "ckcapi-token.h" #include "x509-usages.h" -/* - * These are the attributes expected by NSS on a - * private key object: - * - * CKA_ALWAYS_AUTHENTICATE - * CKA_ALWAYS_SENSITIVE - * CKA_CLASS - * CKA_DECRYPT - * CKA_DERIVE - * CKA_END_DATE - * CKA_EXTRACTABLE - * CKA_ID - * CKA_LABEL - * CKA_LOCAL - * CKA_KEY_TYPE - * CKA_KEY_GEN_MECHANISM - * CKA_MODIFIABLE - * CKA_NEVER_EXTRACTABLE - * CKA_PRIVATE - * CKA_SENSITIVE - * CKA_SIGN - * CKA_SIGN_RECOVER - * CKA_START_DATE - * CKA_SUBJECT - * CKA_TOKEN - * CKA_UNWRAP - * CKA_UNWRAP_TEMPLATE - * CKA_ALLOWED_MECHANISMS - * CKA_WRAP_WITH_TRUSTED - * - * Additional attributes for RSA keys: - * - * CKA_COEFFICIENT - * CKA_EXPONENT_1 - * CKA_EXPONENT_2 - * CKA_MODULUS - * CKA_PRIME_1 - * CKA_PRIME_2 - * CKA_PRIVATE_EXPONENT - * CKA_PUBLIC_EXPONENT - * - * Additional attributes for DSA keys: - * - * CKA_BASE - * CKA_PRIME - * CKA_SUBPRIME - * CKA_VALUE - */ - typedef struct _KeyObject { CkCapiObject obj; @@ -517,16 +468,6 @@ key_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr) else return CKR_ATTRIBUTE_TYPE_INVALID; - default: - return CKR_ATTRIBUTE_TYPE_INVALID; - }; -} - -static CK_RV -key_date_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr) -{ - switch(attr->type) - { /* * Last date this key can be used. * TODO: Does CAPI support this ability? @@ -559,7 +500,6 @@ static const CkCapiObjectDataVtable key_objdata_vtable = { key_bool_attribute, key_ulong_attribute, key_bytes_attribute, - key_date_attribute, key_release, }; diff --git a/ckcapi-object.c b/ckcapi-object.c index 7755d25..3143700 100644 --- a/ckcapi-object.c +++ b/ckcapi-object.c @@ -29,7 +29,6 @@ enum DATA_UNKNOWN = 0, DATA_BOOL, DATA_ULONG, - DATA_DATE, DATA_BYTES }; @@ -134,16 +133,13 @@ attribute_data_type(CK_ATTRIBUTE_TYPE type) case CKA_SUPPORTED_CMS_ATTRIBUTES: case CKA_CERT_SHA1_HASH: case CKA_CERT_MD5_HASH: - return DATA_BYTES; - - // CK_DATE data + case CKA_ALLOWED_MECHANISMS: case CKA_START_DATE: case CKA_END_DATE: - return DATA_DATE; + return DATA_BYTES; // Arrays are nasty case CKA_WRAP_TEMPLATE: - case CKA_ALLOWED_MECHANISMS: case CKA_UNWRAP_TEMPLATE: default: DBG(("unknown attribute type: %x", type)); @@ -187,9 +183,6 @@ ckcapi_object_data_match_attr(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR match) case DATA_BYTES: rv = (objdata->data_funcs->get_bytes)(objdata, &attr); break; - case DATA_DATE: - rv = (objdata->data_funcs->get_date)(objdata, &attr); - break; default: ASSERT(0 && "unrecognized type"); break; @@ -250,9 +243,6 @@ ckcapi_object_data_get_attrs(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attrs, case DATA_BYTES: rv = (objdata->data_funcs->get_bytes)(objdata, &attrs[i]); break; - case DATA_DATE: - rv = (objdata->data_funcs->get_date)(objdata, &attrs[i]); - break; case DATA_UNKNOWN: rv = CKR_ATTRIBUTE_TYPE_INVALID; break; diff --git a/ckcapi-object.h b/ckcapi-object.h index 4ba5d09..2b07c30 100644 --- a/ckcapi-object.h +++ b/ckcapi-object.h @@ -67,7 +67,6 @@ typedef struct _CkCapiObjectDataVtable CkCapiGetAttribute get_bool; CkCapiGetAttribute get_ulong; CkCapiGetAttribute get_bytes; - CkCapiGetAttribute get_date; CkCapiRelease release; } CkCapiObjectDataVtable; diff --git a/ckcapi-trust.c b/ckcapi-trust.c index b048b9c..0449fc6 100644 --- a/ckcapi-trust.c +++ b/ckcapi-trust.c @@ -257,12 +257,6 @@ trust_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr) return CKR_ATTRIBUTE_TYPE_INVALID; } -static CK_RV -trust_date_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr) -{ - return CKR_ATTRIBUTE_TYPE_INVALID; -} - static unsigned int trust_hash_func(CkCapiObject* obj) { @@ -294,7 +288,6 @@ static const CkCapiObjectDataVtable trust_objdata_vtable = { trust_bool_attribute, trust_ulong_attribute, trust_bytes_attribute, - trust_date_attribute, trust_release, }; |