summaryrefslogtreecommitdiff
path: root/ckcapi-trust.c
diff options
context:
space:
mode:
Diffstat (limited to 'ckcapi-trust.c')
-rw-r--r--ckcapi-trust.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/ckcapi-trust.c b/ckcapi-trust.c
index 9acbfed..db543a7 100644
--- a/ckcapi-trust.c
+++ b/ckcapi-trust.c
@@ -191,12 +191,15 @@ trust_bytes_attribute(void* obj, CK_ATTRIBUTE_TYPE type,
type, data, len);
/*
- * TODO: These should probably be implemented
+ * The hash of the DER encoded certificate.
*/
case CKA_CERT_MD5_HASH:
case CKA_CERT_SHA1_HASH:
- return CKR_ATTRIBUTE_TYPE_INVALID;
-
+ if(!CryptHashCertificate(0, type == CKA_CERT_MD5_HASH ? CALG_MD5 : CALG_SHA1,
+ 0, trust_data->cert->pbCertEncoded,
+ trust_data->cert->cbCertEncoded, data, (DWORD*)len))
+ return ckcapi_winerr_to_ckr(GetLastError());
+ return CKR_OK;
};
return CKR_ATTRIBUTE_TYPE_INVALID;
@@ -319,7 +322,7 @@ trust_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData* objdat
trust_data->cert = CertDuplicateCertificateContext((PCCERT_CONTEXT)(certdata->data));
objdata->data = trust_data;
- objdata->data_funcs = trust_objdata_vtable;
+ objdata->data_funcs = &trust_objdata_vtable;
return CKR_OK;
}
@@ -352,7 +355,7 @@ register_trust_object(CkCapiSession* sess, CkCapiObject* cert, CkCapiObject** ob
tobj->cert_obj = cert->id;
tobj->obj.id = 0;
- tobj->obj.obj_funcs = trust_object_vtable;
+ tobj->obj.obj_funcs = &trust_object_vtable;
tobj->obj.unique_key = UNIQUE_KEY_AT(tobj, otype);
tobj->obj.unique_len = UNIQUE_KEY_LEN(tobj, otype, cert_obj);