some missing refactoring changes

This commit is contained in:
Andreas Steffen
2009-10-11 20:14:18 +02:00
parent d4acf1dd3c
commit 1c75e3404d
+17 -15
View File
@@ -31,6 +31,7 @@
#include <asn1/asn1.h> #include <asn1/asn1.h>
#include <credentials/keys/public_key.h> #include <credentials/keys/public_key.h>
#include <credentials/certificates/x509.h>
#include "constants.h" #include "constants.h"
@@ -502,18 +503,22 @@ static bool scx_find_cert_object(CK_SESSION_HANDLE session,
x509cert = malloc_thing(x509cert_t); x509cert = malloc_thing(x509cert_t);
*x509cert = empty_x509cert; *x509cert = empty_x509cert;
x509cert->smartcard = TRUE; x509cert->smartcard = TRUE;
x509cert->cert = lib->creds->create(lib->creds,
if (!parse_x509cert(blob, 0, x509cert)) CRED_CERTIFICATE, CERT_X509,
BUILD_BLOB_ASN1_DER, blob,
BUILD_END);
if (x509cert->cert)
{ {
plog("failed to load cert from smartcard, error in X.509 certificate");
free_x509cert(x509cert);
return FALSE;
}
cert->type = CERT_X509_SIGNATURE; cert->type = CERT_X509_SIGNATURE;
cert->u.x509 = x509cert; cert->u.x509 = x509cert;
return TRUE; return TRUE;
}
plog("failed to load cert from smartcard, error in X.509 certificate");
free_x509cert(x509cert);
return FALSE;
} }
/* /*
* search a given slot for PKCS#11 certificate objects * search a given slot for PKCS#11 certificate objects
*/ */
@@ -535,10 +540,10 @@ static void scx_find_cert_objects(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
{ {
CK_OBJECT_HANDLE object; CK_OBJECT_HANDLE object;
CK_ULONG obj_count = 0; CK_ULONG obj_count = 0;
err_t ugh;
time_t valid_until; time_t valid_until;
smartcard_t *sc; smartcard_t *sc;
x509cert_t *cert; x509cert_t *cert;
x509_t *x509;
rv = pkcs11_functions->C_FindObjects(session, &object, 1, &obj_count); rv = pkcs11_functions->C_FindObjects(session, &object, 1, &obj_count);
if (rv != CKR_OK) if (rv != CKR_OK)
@@ -570,7 +575,7 @@ static void scx_find_cert_objects(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
/* check validity of certificate */ /* check validity of certificate */
cert = sc->last_cert.u.x509; cert = sc->last_cert.u.x509;
if (!cert->cert->get_validity(cert->cert, NULL, NULL, &valid_until) if (!cert->cert->get_validity(cert->cert, NULL, NULL, &valid_until))
{ {
free_x509cert(cert); free_x509cert(cert);
scx_free(sc); scx_free(sc);
@@ -581,11 +586,12 @@ static void scx_find_cert_objects(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
) )
sc = scx_add(sc); sc = scx_add(sc);
x509 = (x509_t*)cert->cert;
/* put end entity and ca certificates into different chains */ /* put end entity and ca certificates into different chains */
if (cert->isCA) if (x509->get_flags(x509) & X509_CA)
{ {
sc->last_cert.u.x509 = add_authcert(cert, AUTH_CA); sc->last_cert.u.x509 = add_authcert(cert, X509_CA);
} }
else else
{ {
@@ -1907,15 +1913,11 @@ void scx_list(bool utc)
{ {
whack_log(RC_COMMENT, " "); whack_log(RC_COMMENT, " ");
whack_log(RC_COMMENT, "List of Smartcard Objects:"); whack_log(RC_COMMENT, "List of Smartcard Objects:");
whack_log(RC_COMMENT, " ");
} }
while (sc != NULL) while (sc != NULL)
{ {
whack_log(RC_COMMENT, "%T, #%d, count: %d" whack_log(RC_COMMENT, " ");
, &sc->last_load, utc
, sc->number
, sc->count);
whack_log(RC_COMMENT, " %s, session %s, logged %s, has %s" whack_log(RC_COMMENT, " %s, session %s, logged %s, has %s"
, scx_print_slot(sc, " ") , scx_print_slot(sc, " ")
, sc->session_opened? "opened" : "closed" , sc->session_opened? "opened" : "closed"