pkcs15: export 'sc_pkcs15_serialize_guid' ...
change name of exported 'sc_pkcs15_get_guid' to 'sc_pkcs15_get_object_guid' ; add more 'CALLED' and 'RETURN' macros ;
This commit is contained in:
parent
d7285843f6
commit
98325ab7f2
|
@ -197,11 +197,12 @@ sc_pkcs15_free_prkey_info
|
||||||
sc_pkcs15_free_pubkey
|
sc_pkcs15_free_pubkey
|
||||||
sc_pkcs15_free_pubkey_info
|
sc_pkcs15_free_pubkey_info
|
||||||
sc_pkcs15_get_application_by_type
|
sc_pkcs15_get_application_by_type
|
||||||
sc_pkcs15_get_guid
|
sc_pkcs15_get_object_guid
|
||||||
sc_pkcs15_get_object_id
|
sc_pkcs15_get_object_id
|
||||||
sc_pkcs15_get_objects
|
sc_pkcs15_get_objects
|
||||||
sc_pkcs15_get_objects_cond
|
sc_pkcs15_get_objects_cond
|
||||||
sc_pkcs15_get_lastupdate
|
sc_pkcs15_get_lastupdate
|
||||||
|
sc_pkcs15_serialize_guid
|
||||||
sc_pkcs15_hex_string_to_id
|
sc_pkcs15_hex_string_to_id
|
||||||
sc_pkcs15_is_emulation_only
|
sc_pkcs15_is_emulation_only
|
||||||
sc_pkcs15_make_absolute_path
|
sc_pkcs15_make_absolute_path
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "cardctl.h"
|
#include "cardctl.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
@ -2516,7 +2517,7 @@ sc_pkcs15_get_object_id(const struct sc_pkcs15_object *obj, struct sc_pkcs15_id
|
||||||
* There is no variant, version number and other special meaning fields
|
* There is no variant, version number and other special meaning fields
|
||||||
* that are described in RFC-4122 .
|
* that are described in RFC-4122 .
|
||||||
*/
|
*/
|
||||||
static int
|
int
|
||||||
sc_pkcs15_serialize_guid(unsigned char *in, size_t in_size, unsigned flags,
|
sc_pkcs15_serialize_guid(unsigned char *in, size_t in_size, unsigned flags,
|
||||||
char *out, size_t out_size)
|
char *out, size_t out_size)
|
||||||
{
|
{
|
||||||
|
@ -2546,38 +2547,40 @@ sc_pkcs15_serialize_guid(unsigned char *in, size_t in_size, unsigned flags,
|
||||||
return SC_SUCCESS;
|
return SC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
sc_pkcs15_get_guid(struct sc_pkcs15_card *p15card, const struct sc_pkcs15_object *obj,
|
sc_pkcs15_get_object_guid(struct sc_pkcs15_card *p15card, const struct sc_pkcs15_object *obj,
|
||||||
unsigned flags, char *out, size_t out_size)
|
unsigned flags, char *out, size_t out_size)
|
||||||
{
|
{
|
||||||
|
struct sc_context *ctx = p15card->card->ctx;
|
||||||
struct sc_serial_number serialnr;
|
struct sc_serial_number serialnr;
|
||||||
struct sc_pkcs15_id id;
|
struct sc_pkcs15_id id;
|
||||||
unsigned char guid_bin[SC_PKCS15_MAX_ID_SIZE + SC_MAX_SERIALNR];
|
unsigned char guid_bin[SC_PKCS15_MAX_ID_SIZE + SC_MAX_SERIALNR];
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if (p15card->ops.get_guid)
|
LOG_FUNC_CALLED(ctx);
|
||||||
return p15card->ops.get_guid(p15card, obj, out, out_size);
|
if (p15card->ops.get_guid) {
|
||||||
|
rv = p15card->ops.get_guid(p15card, obj, out, out_size);
|
||||||
|
LOG_FUNC_RETURN(ctx, rv);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(out, 0, out_size);
|
||||||
if ((obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY) {
|
if ((obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY) {
|
||||||
struct sc_pkcs15_prkey_info *info = (struct sc_pkcs15_prkey_info *)obj->data;
|
struct sc_pkcs15_prkey_info *info = (struct sc_pkcs15_prkey_info *)obj->data;
|
||||||
|
|
||||||
if (info->cmap_record.guid && strlen(info->cmap_record.guid)) {
|
if (info->cmap_record.guid && strlen(info->cmap_record.guid)) {
|
||||||
if (out_size < strlen(info->cmap_record.guid) + 1)
|
if (out_size < strlen(info->cmap_record.guid) + 1)
|
||||||
return SC_ERROR_BUFFER_TOO_SMALL;
|
return SC_ERROR_BUFFER_TOO_SMALL;
|
||||||
memset(out, 0, out_size);
|
|
||||||
memcpy(out, info->cmap_record.guid, strlen(info->cmap_record.guid));
|
memcpy(out, info->cmap_record.guid, strlen(info->cmap_record.guid));
|
||||||
|
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||||
return SC_SUCCESS;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = sc_pkcs15_get_object_id(obj, &id);
|
rv = sc_pkcs15_get_object_id(obj, &id);
|
||||||
if (rv)
|
LOG_TEST_RET(ctx, rv, "Cannot get object's ID");
|
||||||
return rv;
|
|
||||||
|
|
||||||
rv = sc_card_ctl(p15card->card, SC_CARDCTL_GET_SERIALNR, &serialnr);
|
rv = sc_card_ctl(p15card->card, SC_CARDCTL_GET_SERIALNR, &serialnr);
|
||||||
if (rv)
|
LOG_TEST_RET(ctx, rv, "'GET_SERIALNR' failed");
|
||||||
return rv;
|
|
||||||
|
|
||||||
memset(guid_bin, 0, sizeof(guid_bin));
|
memset(guid_bin, 0, sizeof(guid_bin));
|
||||||
memcpy(guid_bin, id.value, id.len);
|
memcpy(guid_bin, id.value, id.len);
|
||||||
|
@ -2591,7 +2594,8 @@ sc_pkcs15_get_guid(struct sc_pkcs15_card *p15card, const struct sc_pkcs15_object
|
||||||
serialnr.len = 0;
|
serialnr.len = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return sc_pkcs15_serialize_guid(guid_bin, id.len + serialnr.len, flags, out, out_size);
|
rv = sc_pkcs15_serialize_guid(guid_bin, id.len + serialnr.len, flags, out, out_size);
|
||||||
|
LOG_FUNC_RETURN(ctx, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sc_pkcs15_free_key_params(struct sc_pkcs15_key_params *params)
|
void sc_pkcs15_free_key_params(struct sc_pkcs15_key_params *params)
|
||||||
|
|
|
@ -934,8 +934,9 @@ void sc_pkcs15_format_id(const char *id_in, struct sc_pkcs15_id *id_out);
|
||||||
int sc_pkcs15_hex_string_to_id(const char *in, struct sc_pkcs15_id *out);
|
int sc_pkcs15_hex_string_to_id(const char *in, struct sc_pkcs15_id *out);
|
||||||
int sc_der_copy(struct sc_pkcs15_der *, const struct sc_pkcs15_der *);
|
int sc_der_copy(struct sc_pkcs15_der *, const struct sc_pkcs15_der *);
|
||||||
int sc_pkcs15_get_object_id(const struct sc_pkcs15_object *, struct sc_pkcs15_id *);
|
int sc_pkcs15_get_object_id(const struct sc_pkcs15_object *, struct sc_pkcs15_id *);
|
||||||
int sc_pkcs15_get_guid(struct sc_pkcs15_card *, const struct sc_pkcs15_object *, unsigned,
|
int sc_pkcs15_get_object_guid(struct sc_pkcs15_card *, const struct sc_pkcs15_object *, unsigned,
|
||||||
char *, size_t);
|
char *, size_t);
|
||||||
|
int sc_pkcs15_serialize_guid(unsigned char *, size_t, unsigned, char *, size_t);
|
||||||
int sc_encode_oid (struct sc_context *, struct sc_object_id *,
|
int sc_encode_oid (struct sc_context *, struct sc_object_id *,
|
||||||
unsigned char **, size_t *);
|
unsigned char **, size_t *);
|
||||||
|
|
||||||
|
|
|
@ -1321,9 +1321,9 @@ md_set_cmapfile(PCARD_DATA pCardData, struct md_file *file)
|
||||||
found_default = 1;
|
found_default = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rv = sc_pkcs15_get_guid(vs->p15card, key_obj, 0, cont->guid, sizeof(cont->guid));
|
rv = sc_pkcs15_get_object_guid(vs->p15card, key_obj, 0, cont->guid, sizeof(cont->guid));
|
||||||
if (rv) {
|
if (rv) {
|
||||||
logprintf(pCardData, 2, "sc_pkcs15_get_guid() error %d\n", rv);
|
logprintf(pCardData, 2, "sc_pkcs15_get_object_guid() error %d\n", rv);
|
||||||
return SCARD_F_INTERNAL_ERROR;
|
return SCARD_F_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1381,7 +1381,7 @@ iasecc_md_gemalto_set_default(struct sc_pkcs15_card *p15card, struct sc_profile
|
||||||
if (rv != SC_ERROR_OBJECT_NOT_FOUND)
|
if (rv != SC_ERROR_OBJECT_NOT_FOUND)
|
||||||
LOG_TEST_RET(ctx, rv, "Find 'Default Key Container' data object error");
|
LOG_TEST_RET(ctx, rv, "Find 'Default Key Container' data object error");
|
||||||
|
|
||||||
rv = sc_pkcs15_get_guid(p15card, key_obj, 1, guid, sizeof(guid));
|
rv = sc_pkcs15_get_object_guid(p15card, key_obj, 1, guid, sizeof(guid));
|
||||||
LOG_TEST_RET(ctx, rv, "Cannot get private key GUID");
|
LOG_TEST_RET(ctx, rv, "Cannot get private key GUID");
|
||||||
|
|
||||||
if (!data_obj) {
|
if (!data_obj) {
|
||||||
|
@ -1426,7 +1426,7 @@ iasecc_md_gemalto_unset_default(struct sc_pkcs15_card *p15card, struct sc_profil
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
rv = sc_pkcs15_get_guid(p15card, key_obj, 1, guid, sizeof(guid));
|
rv = sc_pkcs15_get_object_guid(p15card, key_obj, 1, guid, sizeof(guid));
|
||||||
LOG_TEST_RET(ctx, rv, "Cannot get private key GUID");
|
LOG_TEST_RET(ctx, rv, "Cannot get private key GUID");
|
||||||
|
|
||||||
rv = sc_pkcs15_find_data_object_by_name(p15card, "CSP", "Default Key Container", &data_obj);
|
rv = sc_pkcs15_find_data_object_by_name(p15card, "CSP", "Default Key Container", &data_obj);
|
||||||
|
@ -1481,7 +1481,7 @@ iasecc_md_gemalto_new_prvkey(struct sc_pkcs15_card *p15card, struct sc_profile *
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
memset(guid, 0, sizeof(guid));
|
memset(guid, 0, sizeof(guid));
|
||||||
rv = sc_pkcs15_get_guid(p15card, key_obj, 1, guid, sizeof(guid) - 1);
|
rv = sc_pkcs15_get_object_guid(p15card, key_obj, 1, guid, sizeof(guid) - 1);
|
||||||
LOG_TEST_RET(ctx, rv, "Cannot get private key GUID");
|
LOG_TEST_RET(ctx, rv, "Cannot get private key GUID");
|
||||||
sc_log(ctx, "New key GUID: '%s'", guid);
|
sc_log(ctx, "New key GUID: '%s'", guid);
|
||||||
|
|
||||||
|
@ -1526,7 +1526,7 @@ iasecc_md_gemalto_delete_prvkey(struct sc_pkcs15_card *p15card, struct sc_profil
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
rv = sc_pkcs15_get_guid(p15card, key_obj, 1, guid, sizeof(guid));
|
rv = sc_pkcs15_get_object_guid(p15card, key_obj, 1, guid, sizeof(guid));
|
||||||
LOG_TEST_RET(ctx, rv, "Cannot get private key GUID");
|
LOG_TEST_RET(ctx, rv, "Cannot get private key GUID");
|
||||||
|
|
||||||
rv = sc_pkcs15_find_data_object_by_name(p15card, "CSP", guid, &data_obj);
|
rv = sc_pkcs15_find_data_object_by_name(p15card, "CSP", guid, &data_obj);
|
||||||
|
|
|
@ -533,11 +533,11 @@ static void print_prkey_info(const struct sc_pkcs15_object *obj)
|
||||||
printf("\tAuth ID : %s\n", sc_pkcs15_print_id(&obj->auth_id));
|
printf("\tAuth ID : %s\n", sc_pkcs15_print_id(&obj->auth_id));
|
||||||
printf("\tID : %s\n", sc_pkcs15_print_id(&prkey->id));
|
printf("\tID : %s\n", sc_pkcs15_print_id(&prkey->id));
|
||||||
|
|
||||||
if (!sc_pkcs15_get_guid(p15card, obj, 0, guid, sizeof(guid))) {
|
if (!sc_pkcs15_get_object_guid(p15card, obj, 0, guid, sizeof(guid))) {
|
||||||
printf("\tGUID : %s\n", guid);
|
printf("\tMD guid : %s\n", guid);
|
||||||
printf("\tMD cmap flags : 0x%X\n", prkey->cmap_record.flags);
|
printf("\t cmap-flags : 0x%X\n", prkey->cmap_record.flags);
|
||||||
printf("\tsign key size : 0x%X\n", prkey->cmap_record.keysize_sign);
|
printf("\t sign key : %i\n", prkey->cmap_record.keysize_sign);
|
||||||
printf("\tkey-exchange : 0x%X\n", prkey->cmap_record.keysize_keyexchange);
|
printf("\t key-exchange: %i\n", prkey->cmap_record.keysize_keyexchange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,7 +744,7 @@ static void print_skey_info(const struct sc_pkcs15_object *obj)
|
||||||
|
|
||||||
if (skey->path.len || skey->path.aid.len)
|
if (skey->path.len || skey->path.aid.len)
|
||||||
printf("\tPath : %s\n", sc_print_path(&skey->path));
|
printf("\tPath : %s\n", sc_print_path(&skey->path));
|
||||||
if (!sc_pkcs15_get_guid(p15card, obj, 0, guid, sizeof(guid)))
|
if (!sc_pkcs15_get_object_guid(p15card, obj, 0, guid, sizeof(guid)))
|
||||||
printf("\tGUID : %s\n", guid);
|
printf("\tGUID : %s\n", guid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue