fixed a ton of compiler warnings
This commit is contained in:
parent
07818329ab
commit
d21830344f
|
@ -981,14 +981,12 @@ static int belpic_init(sc_card_t *card)
|
|||
static int belpic_select_file(sc_card_t *card,
|
||||
const sc_path_t *in_path, sc_file_t **file_out)
|
||||
{
|
||||
sc_context_t *ctx;
|
||||
sc_apdu_t apdu;
|
||||
u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
|
||||
int r, pathlen;
|
||||
sc_file_t *file = NULL;
|
||||
|
||||
assert(card != NULL && in_path != NULL);
|
||||
ctx = card->ctx;
|
||||
memcpy(path, in_path->value, in_path->len);
|
||||
pathlen = in_path->len;
|
||||
|
||||
|
|
|
@ -864,7 +864,7 @@ cardos_compute_signature(sc_card_t *card, const u8 *data, size_t datalen,
|
|||
* and www.crysys.hu/infsec/M40_Manual_E_2001_10.pdf)
|
||||
*/
|
||||
|
||||
if (card->caps & SC_CARD_CAP_ONLY_RAW_HASH_STRIPPED){
|
||||
if (card->caps & SC_CARD_CAP_ONLY_RAW_HASH_STRIPPED){
|
||||
sc_log(ctx, "Forcing RAW_HASH_STRIPPED");
|
||||
do_rsa_sig = 1;
|
||||
}
|
||||
|
@ -873,7 +873,7 @@ cardos_compute_signature(sc_card_t *card, const u8 *data, size_t datalen,
|
|||
do_rsa_sig = 1;
|
||||
}
|
||||
else {
|
||||
//check the the algorithmIDs from the AlgorithmInfo
|
||||
/* check the the algorithmIDs from the AlgorithmInfo */
|
||||
int i;
|
||||
for(i=0; i<algorithm_ids_in_tokeninfo_count;++i){
|
||||
unsigned int id = algorithm_ids_in_tokeninfo[i];
|
||||
|
@ -884,10 +884,10 @@ cardos_compute_signature(sc_card_t *card, const u8 *data, size_t datalen,
|
|||
}
|
||||
}
|
||||
|
||||
//check if any operation was selected
|
||||
/* check if any operation was selected */
|
||||
if(do_rsa_sig == 0 && do_rsa_pure_sig == 0) {
|
||||
//no operation selected. we just have to try both, for the lack of any better reasoning
|
||||
sc_log(ctx, "I was unable to determine, wether this key can be used with RSA_SIG or RSA_PURE_SIG. I will just try both.");
|
||||
/* no operation selected. we just have to try both, for the lack of any better reasoning */
|
||||
sc_log(ctx, "I was unable to determine, whether this key can be used with RSA_SIG or RSA_PURE_SIG. I will just try both.");
|
||||
do_rsa_sig = 1;
|
||||
do_rsa_pure_sig = 1;
|
||||
}
|
||||
|
@ -931,6 +931,8 @@ cardos_compute_signature(sc_card_t *card, const u8 *data, size_t datalen,
|
|||
LOG_FUNC_RETURN(ctx, r);
|
||||
return do_compute_signature(card, buf, buf_len, out, outlen);
|
||||
}
|
||||
|
||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -858,7 +858,7 @@ epass2003_sm_free_wrapped_apdu(struct sc_card *card,
|
|||
free(*sm_apdu);
|
||||
*sm_apdu = NULL;
|
||||
|
||||
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||
LOG_FUNC_RETURN(ctx, rv);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1059,14 +1059,12 @@ epass2003_hook_file(struct sc_file *file, int inc)
|
|||
static int
|
||||
epass2003_select_fid_(struct sc_card *card, sc_path_t * in_path, sc_file_t ** file_out)
|
||||
{
|
||||
sc_context_t *ctx;
|
||||
struct sc_apdu apdu;
|
||||
u8 buf[SC_MAX_APDU_BUFFER_SIZE] = { 0 };
|
||||
u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
|
||||
int r, pathlen;
|
||||
sc_file_t *file = NULL;
|
||||
|
||||
ctx = card->ctx;
|
||||
epass2003_hook_path(in_path, 1);
|
||||
memcpy(path, in_path->value, in_path->len);
|
||||
pathlen = in_path->len;
|
||||
|
|
|
@ -659,7 +659,7 @@ static int jcop_set_security_env(sc_card_t *card,
|
|||
apdu.le = 0;
|
||||
if (!env->flags & SC_SEC_ENV_ALG_REF_PRESENT)
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
if (!env->flags & SC_SEC_ENV_FILE_REF_PRESENT)
|
||||
if (!(env->flags & SC_SEC_ENV_FILE_REF_PRESENT))
|
||||
return SC_ERROR_INVALID_ARGUMENTS;
|
||||
if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT) {
|
||||
if (env->key_ref_len > 1 || env->key_ref[0] != 0)
|
||||
|
@ -797,7 +797,6 @@ static int jcop_decipher(sc_card_t *card,
|
|||
}
|
||||
|
||||
static int jcop_generate_key(sc_card_t *card, struct sc_cardctl_jcop_genkey *a) {
|
||||
int modlen;
|
||||
int r;
|
||||
sc_apdu_t apdu;
|
||||
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
|
||||
|
@ -877,7 +876,6 @@ static int jcop_generate_key(sc_card_t *card, struct sc_cardctl_jcop_genkey *a)
|
|||
if (rbuf[0] != 0x4) {
|
||||
return SC_ERROR_INVALID_DATA;
|
||||
}
|
||||
modlen=rbuf[1] * 32;
|
||||
if (a->pubkey_len < rbuf[1])
|
||||
return SC_ERROR_BUFFER_TOO_SMALL;
|
||||
a->pubkey_len=rbuf[1] * 4;
|
||||
|
|
|
@ -320,7 +320,7 @@ static int miocos_get_acl(sc_card_t *card, sc_file_t *file)
|
|||
u8 rbuf[256];
|
||||
const u8 *seq = rbuf;
|
||||
size_t left;
|
||||
int acl_types[16], r;
|
||||
int r;
|
||||
unsigned int i;
|
||||
|
||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, 0x01);
|
||||
|
@ -331,8 +331,6 @@ static int miocos_get_acl(sc_card_t *card, sc_file_t *file)
|
|||
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed");
|
||||
if (apdu.resplen == 0)
|
||||
return sc_check_sw(card, apdu.sw1, apdu.sw2);
|
||||
for (i = 0; i < 16; i++)
|
||||
acl_types[i] = SC_AC_KEY_REF_NONE;
|
||||
left = apdu.resplen;
|
||||
seq = sc_asn1_skip_tag(card->ctx, &seq, &left,
|
||||
SC_ASN1_SEQUENCE | SC_ASN1_CONS, &left);
|
||||
|
|
|
@ -1150,7 +1150,7 @@ static int myeid_get_info(struct sc_card *card, u8 *rbuf, size_t buflen)
|
|||
card->version.fw_major = rbuf[5] * 10 + rbuf[6];
|
||||
card->version.fw_minor = rbuf[7];
|
||||
/* add version to name */
|
||||
sprintf(nameBuf, "%s %d.%d.%d", card->name, rbuf[5], rbuf[6], rbuf[7]);
|
||||
sprintf((char *) nameBuf, "%s %d.%d.%d", card->name, rbuf[5], rbuf[6], rbuf[7]);
|
||||
card->name = nameBuf;
|
||||
//card->driver->name
|
||||
LOG_FUNC_RETURN(card->ctx, r);
|
||||
|
|
|
@ -549,7 +549,6 @@ pgp_set_blob(struct blob *blob, const u8 *data, size_t len)
|
|||
static void
|
||||
pgp_attach_acl(sc_card_t *card, sc_file_t *file, struct do_info *info)
|
||||
{
|
||||
sc_acl_entry_t *acl;
|
||||
unsigned int method = SC_AC_NONE;
|
||||
unsigned long key_ref = SC_AC_KEY_REF_NONE;
|
||||
|
||||
|
@ -1676,7 +1675,6 @@ static int
|
|||
pgp_parse_and_set_pubkey_output(sc_card_t *card, u8* data, size_t data_len,
|
||||
sc_cardctl_openpgp_keygen_info_t *key_info)
|
||||
{
|
||||
unsigned int blob_id;
|
||||
time_t ctime = 0;
|
||||
u8 *in = data;
|
||||
u8 *modulus = NULL;
|
||||
|
@ -1772,10 +1770,7 @@ static int pgp_update_card_algorithms(sc_card_t *card, sc_cardctl_openpgp_keygen
|
|||
**/
|
||||
static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info)
|
||||
{
|
||||
struct pgp_priv_data *priv = DRVDATA(card);
|
||||
struct blob *algo_blob;
|
||||
sc_apdu_t apdu;
|
||||
unsigned int modulus_bitlen;
|
||||
/* Temporary variables to hold APDU params */
|
||||
u8 apdu_case;
|
||||
u8 *apdu_data;
|
||||
|
@ -1784,6 +1779,8 @@ static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_in
|
|||
|
||||
LOG_FUNC_CALLED(card->ctx);
|
||||
|
||||
/* FIXME the compilers doesn't assure that the buffers set here as
|
||||
* apdu_data are present until the end of the function */
|
||||
/* Set Control Reference Template for key */
|
||||
if (key_info->keytype == SC_OPENPGP_KEY_SIGN)
|
||||
apdu_data = (unsigned char *) "\xb6";
|
||||
|
@ -1921,7 +1918,6 @@ static int
|
|||
pgp_build_extended_header_list(sc_card_t *card, sc_cardctl_openpgp_keystore_info_t *key_info,
|
||||
u8 **result, size_t *resultlen)
|
||||
{
|
||||
struct pgp_priv_data *priv = DRVDATA(card);
|
||||
sc_context_t *ctx = card->ctx;
|
||||
/* The Cardholder private key template (7F48) part */
|
||||
const size_t max_prtem_len = 7*(1 + 3); /* 7 components */
|
||||
|
@ -2078,7 +2074,6 @@ out2:
|
|||
**/
|
||||
static int pgp_store_key(sc_card_t *card, sc_cardctl_openpgp_keystore_info_t *key_info)
|
||||
{
|
||||
struct pgp_priv_data *priv = DRVDATA(card);
|
||||
sc_context_t *ctx = card->ctx;
|
||||
sc_cardctl_openpgp_keygen_info_t pubkey;
|
||||
u8 *data;
|
||||
|
|
|
@ -137,7 +137,6 @@ static int sc_hsm_match_card(struct sc_card *card)
|
|||
static int sc_hsm_pin_info(sc_card_t *card, struct sc_pin_cmd_data *data,
|
||||
int *tries_left)
|
||||
{
|
||||
sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
|
||||
sc_apdu_t apdu;
|
||||
int r;
|
||||
|
||||
|
@ -234,7 +233,6 @@ static int sc_hsm_update_binary(sc_card_t *card,
|
|||
{
|
||||
sc_context_t *ctx = card->ctx;
|
||||
sc_apdu_t apdu;
|
||||
u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE];
|
||||
u8 *cmdbuff, *p;
|
||||
size_t len;
|
||||
int r;
|
||||
|
@ -621,7 +619,7 @@ static int sc_hsm_get_serialnr(sc_card_t *card, sc_serial_number_t *serial)
|
|||
static int sc_hsm_initialize(sc_card_t *card, sc_cardctl_sc_hsm_init_param_t *params)
|
||||
{
|
||||
sc_context_t *ctx = card->ctx;
|
||||
int r, i;
|
||||
int r;
|
||||
sc_apdu_t apdu;
|
||||
u8 ibuff[50], *p;
|
||||
|
||||
|
@ -760,7 +758,6 @@ static int sc_hsm_unwrap_key(sc_card_t *card, sc_cardctl_sc_hsm_wrapped_key_t *p
|
|||
{
|
||||
sc_context_t *ctx = card->ctx;
|
||||
sc_apdu_t apdu;
|
||||
u8 status[MAX_EXT_APDU_LENGTH];
|
||||
int r;
|
||||
|
||||
LOG_FUNC_CALLED(card->ctx);
|
||||
|
@ -888,7 +885,6 @@ static int sc_hsm_init_pin(sc_card_t *card, sc_cardctl_pkcs11_init_pin_t *params
|
|||
|
||||
static int sc_hsm_generate_keypair(sc_card_t *card, sc_cardctl_sc_hsm_keygen_info_t *keyinfo)
|
||||
{
|
||||
sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
|
||||
u8 rbuf[1024];
|
||||
int r;
|
||||
sc_apdu_t apdu;
|
||||
|
|
|
@ -147,13 +147,13 @@ int sc_pkcs15emu_sc_hsm_decode_cvc(sc_pkcs15_card_t * p15card,
|
|||
|
||||
sc_format_asn1_entry(asn1_req , &asn1_authreq, NULL, 0);
|
||||
|
||||
// sc_asn1_print_tags(*buf, *buflen);
|
||||
/* sc_asn1_print_tags(*buf, *buflen); */
|
||||
|
||||
tbuf = *buf;
|
||||
r = sc_asn1_read_tag(&tbuf, *buflen, &cla, &tag, &taglen);
|
||||
LOG_TEST_RET(card->ctx, r, "Could not decode card verifiable certificate");
|
||||
|
||||
// Determine if we deal with an authenticated request, plain request or certificate
|
||||
/* Determine if we deal with an authenticated request, plain request or certificate */
|
||||
if ((cla == (SC_ASN1_TAG_APPLICATION|SC_ASN1_TAG_CONSTRUCTED)) && (tag == 7)) {
|
||||
r = sc_asn1_decode(card->ctx, asn1_req, *buf, *buflen, buf, buflen);
|
||||
} else {
|
||||
|
@ -179,8 +179,6 @@ int sc_pkcs15emu_sc_hsm_encode_cvc(sc_pkcs15_card_t * p15card,
|
|||
struct sc_asn1_entry asn1_cvcert[C_ASN1_CVCERT_SIZE];
|
||||
struct sc_asn1_entry asn1_cvc_body[C_ASN1_CVC_BODY_SIZE];
|
||||
struct sc_asn1_entry asn1_cvc_pubkey[C_ASN1_CVC_PUBKEY_SIZE];
|
||||
unsigned int cla,tag;
|
||||
size_t taglen;
|
||||
size_t lenchr;
|
||||
size_t lencar;
|
||||
int r;
|
||||
|
@ -274,7 +272,7 @@ static int sc_pkcs15emu_sc_hsm_add_pubkey(sc_pkcs15_card_t *p15card, sc_pkcs15_p
|
|||
size_t cvclen;
|
||||
int r;
|
||||
|
||||
// EF.CERT is selected
|
||||
/* EF.CERT is selected */
|
||||
r = sc_read_binary(p15card->card, 0, efbin, sizeof(efbin), 0);
|
||||
LOG_TEST_RET(card->ctx, r, "Could not read CSR from EF");
|
||||
|
||||
|
@ -286,7 +284,7 @@ static int sc_pkcs15emu_sc_hsm_add_pubkey(sc_pkcs15_card_t *p15card, sc_pkcs15_p
|
|||
LOG_TEST_RET(card->ctx, r, "Could decode certificate signing request");
|
||||
|
||||
if (cvc.publicPoint || cvc.publicPointlen) {
|
||||
// ToDo implement support for EC Public Keys
|
||||
/* ToDo implement support for EC Public Keys */
|
||||
return SC_SUCCESS;
|
||||
} else {
|
||||
pubkey.algorithm = SC_ALGORITHM_RSA;
|
||||
|
@ -330,7 +328,7 @@ static int sc_pkcs15emu_sc_hsm_add_prkd(sc_pkcs15_card_t * p15card, u8 keyid) {
|
|||
u8 efbin[512];
|
||||
u8 *ptr;
|
||||
size_t len;
|
||||
int r, i;
|
||||
int r;
|
||||
|
||||
fid[0] = PRKD_PREFIX;
|
||||
fid[1] = keyid;
|
||||
|
@ -393,9 +391,9 @@ static int sc_pkcs15emu_sc_hsm_add_prkd(sc_pkcs15_card_t * p15card, u8 keyid) {
|
|||
return SC_SUCCESS;
|
||||
}
|
||||
|
||||
if (efbin[0] == 0x67) { // Decode CSR and create public key object
|
||||
if (efbin[0] == 0x67) { /* Decode CSR and create public key object */
|
||||
sc_pkcs15emu_sc_hsm_add_pubkey(p15card, key_info, prkd.label);
|
||||
return SC_SUCCESS; // Ignore any errors
|
||||
return SC_SUCCESS; /* Ignore any errors */
|
||||
}
|
||||
|
||||
if (efbin[0] != 0x30) {
|
||||
|
@ -432,7 +430,7 @@ static int sc_pkcs15emu_sc_hsm_add_dcod(sc_pkcs15_card_t * p15card, u8 id) {
|
|||
u8 efbin[512];
|
||||
const u8 *ptr;
|
||||
size_t len;
|
||||
int r, i;
|
||||
int r;
|
||||
|
||||
fid[0] = DCOD_PREFIX;
|
||||
fid[1] = id;
|
||||
|
@ -481,7 +479,7 @@ static int sc_pkcs15emu_sc_hsm_add_cd(sc_pkcs15_card_t * p15card, u8 id) {
|
|||
u8 efbin[512];
|
||||
const u8 *ptr;
|
||||
size_t len;
|
||||
int r, i;
|
||||
int r;
|
||||
|
||||
fid[0] = CD_PREFIX;
|
||||
fid[1] = id;
|
||||
|
@ -532,7 +530,6 @@ static int sc_pkcs15emu_sc_hsm_init (sc_pkcs15_card_t * p15card)
|
|||
struct sc_app_info *appinfo;
|
||||
struct sc_pkcs15_auth_info pin_info;
|
||||
struct sc_pkcs15_object pin_obj;
|
||||
u8 fid[2];
|
||||
u8 efbin[512];
|
||||
u8 *ptr;
|
||||
size_t len;
|
||||
|
@ -558,15 +555,15 @@ static int sc_pkcs15emu_sc_hsm_init (sc_pkcs15_card_t * p15card)
|
|||
r = sc_select_file(card, &path, &file);
|
||||
LOG_TEST_RET(card->ctx, r, "Could not select SmartCard-HSM application");
|
||||
|
||||
p15card->card->version.hw_major = 24; // JCOP 2.4.1r3
|
||||
p15card->card->version.hw_major = 24; /* JCOP 2.4.1r3 */
|
||||
p15card->card->version.hw_minor = 13;
|
||||
p15card->card->version.fw_major = file->prop_attr[file->prop_attr_len - 2];
|
||||
p15card->card->version.fw_minor = file->prop_attr[file->prop_attr_len - 1];
|
||||
|
||||
sc_file_free(file);
|
||||
|
||||
// Read device certificate to determine serial number
|
||||
sc_path_set(&path, SC_PATH_TYPE_FILE_ID, "\x2F\x02", 2, 0, 0);
|
||||
/* Read device certificate to determine serial number */
|
||||
sc_path_set(&path, SC_PATH_TYPE_FILE_ID, (u8 *) "\x2F\x02", 2, 0, 0);
|
||||
r = sc_select_file(card, &path, &file);
|
||||
LOG_TEST_RET(card->ctx, r, "Could not select EF.C_DevAut");
|
||||
sc_file_free(file);
|
||||
|
@ -581,7 +578,7 @@ static int sc_pkcs15emu_sc_hsm_init (sc_pkcs15_card_t * p15card)
|
|||
r = sc_pkcs15emu_sc_hsm_decode_cvc(p15card, (const u8 **)&ptr, &len, &devcert);
|
||||
LOG_TEST_RET(card->ctx, r, "Could not decode EF.C_DevAut");
|
||||
|
||||
len = strlen(devcert.chr); // Strip last 5 digit sequence number from CHR
|
||||
len = strlen(devcert.chr); /* Strip last 5 digit sequence number from CHR */
|
||||
assert(len >= 8);
|
||||
len -= 5;
|
||||
|
||||
|
|
|
@ -324,6 +324,9 @@ iasecc_file_convert_acls(struct sc_context *ctx, struct sc_profile *profile, str
|
|||
int ii;
|
||||
|
||||
for (ii=0; ii<SC_MAX_AC_OPS;ii++) {
|
||||
/* FIXME the acl object must not be modified, it is only defined in
|
||||
* sc_file_get_acl_entry. Accessing it here means we have a race
|
||||
* condition. */
|
||||
struct sc_acl_entry *acl = sc_file_get_acl_entry(file, ii);
|
||||
|
||||
if (acl) {
|
||||
|
@ -1314,8 +1317,8 @@ iasecc_pkcs15_delete_object (struct sc_profile *profile, struct sc_pkcs15_card *
|
|||
|
||||
switch(object->type & SC_PKCS15_TYPE_CLASS_MASK) {
|
||||
case SC_PKCS15_TYPE_PUBKEY:
|
||||
sc_log(ctx, "Ignore delete of SDO-PubKey(ref:%X) '%s', path %s", key_ref, object->label, sc_print_path(path));
|
||||
key_ref = ((struct sc_pkcs15_pubkey_info *)object->data)->key_reference;
|
||||
sc_log(ctx, "Ignore delete of SDO-PubKey(ref:%X) '%s', path %s", key_ref, object->label, sc_print_path(path));
|
||||
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||
case SC_PKCS15_TYPE_PRKEY:
|
||||
sc_log(ctx, "delete PrivKey '%s', path %s", object->label, sc_print_path(path));
|
||||
|
@ -1655,12 +1658,9 @@ iasecc_store_data_object(struct sc_pkcs15_card *p15card, struct sc_profile *prof
|
|||
LOG_TEST_RET(ctx, nn_objs, "IasEcc get pkcs15 DATA objects error");
|
||||
|
||||
for(indx = 1; indx < MAX_DATA_OBJS; indx++) {
|
||||
struct sc_path fpath;
|
||||
|
||||
rv = iasecc_pkcs15_new_file(profile, card, SC_PKCS15_TYPE_DATA_OBJECT, indx, &file);
|
||||
LOG_TEST_RET(ctx, rv, "iasecc_store_data_object() pkcs15 new DATA file error");
|
||||
|
||||
fpath = file->path;
|
||||
for (ii=0; ii<nn_objs; ii++) {
|
||||
struct sc_pkcs15_data_info *info = (struct sc_pkcs15_data_info *)p15objects[ii]->data;
|
||||
int file_id = info->path.value[info->path.len - 2] * 0x100 + info->path.value[info->path.len - 1];
|
||||
|
@ -1788,14 +1788,6 @@ iasecc_emu_store_data(struct sc_pkcs15_card *p15card, struct sc_profile *profile
|
|||
}
|
||||
|
||||
|
||||
static int
|
||||
iasecc_emu_update_tokeninfo(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||
struct sc_pkcs15_tokeninfo *tinfo)
|
||||
{
|
||||
LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
static struct sc_pkcs15init_operations
|
||||
sc_pkcs15init_iasecc_operations = {
|
||||
iasecc_pkcs15_erase_card,
|
||||
|
|
|
@ -1368,9 +1368,8 @@ sc_pkcs15init_store_private_key(struct sc_pkcs15_card *p15card,
|
|||
{
|
||||
struct sc_context *ctx = p15card->card->ctx;
|
||||
struct sc_pkcs15_object *object;
|
||||
struct sc_pkcs15_prkey_info *key_info;
|
||||
struct sc_pkcs15_prkey key;
|
||||
int keybits, idx, r = 0;
|
||||
int keybits, r = 0;
|
||||
|
||||
LOG_FUNC_CALLED(ctx);
|
||||
/* Create a copy of the key first */
|
||||
|
@ -1404,13 +1403,13 @@ sc_pkcs15init_store_private_key(struct sc_pkcs15_card *p15card,
|
|||
/* Set up the PrKDF object */
|
||||
r = sc_pkcs15init_init_prkdf(p15card, profile, keyargs, &key, keybits, &object);
|
||||
LOG_TEST_RET(ctx, r, "Failed to initialize private key object");
|
||||
key_info = (struct sc_pkcs15_prkey_info *) object->data;
|
||||
/*key_info = (struct sc_pkcs15_prkey_info *) object->data;*/
|
||||
|
||||
r = sc_pkcs15init_encode_prvkey_content(p15card, &key, object);
|
||||
LOG_TEST_RET(ctx, r, "Failed to encode public key");
|
||||
|
||||
/* Get the number of private keys already on this card */
|
||||
idx = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_PRKEY, NULL, 0);
|
||||
/*idx = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_PRKEY, NULL, 0);*/
|
||||
|
||||
r = profile->ops->create_key(profile, p15card, object);
|
||||
LOG_TEST_RET(ctx, r, "Card specific 'create key' failed");
|
||||
|
|
|
@ -153,7 +153,6 @@ static int sc_hsm_update_ef(sc_pkcs15_card_t *p15card, u8 prefix, u8 id, int era
|
|||
{
|
||||
sc_card_t *card = p15card->card;
|
||||
sc_file_t *file = NULL;
|
||||
sc_file_t newfile;
|
||||
sc_path_t path;
|
||||
u8 fid[2];
|
||||
int r;
|
||||
|
@ -264,10 +263,9 @@ static int sc_hsm_get_curve(struct sc_pkcs15_card *p15card, struct ec_curve **cu
|
|||
static int sc_hsm_encode_gakp_ec(struct sc_pkcs15_card *p15card, sc_cvc_t *cvc, struct sc_pkcs15_prkey_info *key_info) {
|
||||
struct sc_object_id ecdsaWithSHA256 = { { 0,4,0,127,0,7,2,2,2,2,3,-1 } };
|
||||
struct sc_pkcs15_ec_parameters *ecparams = (struct sc_pkcs15_ec_parameters *)key_info->params.data;
|
||||
struct ec_curve *curve;
|
||||
struct ec_curve *curve = NULL;
|
||||
u8 *curveoid;
|
||||
int curveoidlen;
|
||||
int r;
|
||||
int curveoidlen, r;
|
||||
|
||||
LOG_FUNC_CALLED(p15card->card->ctx);
|
||||
|
||||
|
@ -335,10 +333,6 @@ static int sc_hsm_decode_gakp_rsa(struct sc_pkcs15_card *p15card,
|
|||
struct sc_pkcs15_prkey_info *key_info,
|
||||
struct sc_pkcs15_pubkey *pubkey)
|
||||
{
|
||||
u8 *buf;
|
||||
size_t buflen;
|
||||
int r;
|
||||
|
||||
LOG_FUNC_CALLED(p15card->card->ctx);
|
||||
|
||||
if (((key_info->modulus_length + 7) / 8) != cvc->primeOrModuluslen) {
|
||||
|
@ -367,13 +361,8 @@ static int sc_hsm_decode_gakp_ec(struct sc_pkcs15_card *p15card,
|
|||
struct sc_pkcs15_prkey_info *key_info,
|
||||
struct sc_pkcs15_pubkey *pubkey)
|
||||
{
|
||||
struct sc_asn1_entry asn1_ec_pointQ[C_ASN1_EC_POINTQ_SIZE];
|
||||
struct sc_pkcs15_ec_parameters *ecparams = (struct sc_pkcs15_ec_parameters *)(key_info->params.data);
|
||||
struct sc_ec_params *ecp;
|
||||
u8 *buf;
|
||||
size_t buflen;
|
||||
int r;
|
||||
|
||||
LOG_FUNC_CALLED(p15card->card->ctx);
|
||||
|
||||
pubkey->algorithm = SC_ALGORITHM_EC;
|
||||
|
@ -417,7 +406,6 @@ static int sc_hsm_generate_key(struct sc_profile *profile, struct sc_pkcs15_card
|
|||
struct sc_pkcs15_object *object,
|
||||
struct sc_pkcs15_pubkey *pubkey)
|
||||
{
|
||||
struct sc_context *ctx = p15card->card->ctx;
|
||||
struct sc_card *card = p15card->card;
|
||||
struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data;
|
||||
sc_cardctl_sc_hsm_keygen_info_t sc_hsm_keyinfo;
|
||||
|
@ -523,7 +511,6 @@ static int sc_hsm_emu_store_cert(struct sc_pkcs15_card *p15card, struct sc_profi
|
|||
struct sc_pkcs15_der *data)
|
||||
|
||||
{
|
||||
struct sc_context *ctx = p15card->card->ctx;
|
||||
struct sc_pkcs15_cert_info *cert_info = (struct sc_pkcs15_cert_info *) object->data;
|
||||
struct sc_pkcs15_object *prkey;
|
||||
sc_path_t path;
|
||||
|
@ -558,7 +545,6 @@ static int sc_hsm_emu_delete_cert(struct sc_pkcs15_card *p15card, struct sc_prof
|
|||
struct sc_pkcs15_object *object)
|
||||
|
||||
{
|
||||
struct sc_context *ctx = p15card->card->ctx;
|
||||
struct sc_pkcs15_cert_info *cert_info = (struct sc_pkcs15_cert_info *) object->data;
|
||||
struct sc_pkcs15_object *prkey;
|
||||
int r;
|
||||
|
@ -581,7 +567,6 @@ static int sc_hsm_emu_store_binary(struct sc_pkcs15_card *p15card, struct sc_pro
|
|||
struct sc_pkcs15_der *data)
|
||||
|
||||
{
|
||||
struct sc_context *ctx = p15card->card->ctx;
|
||||
struct sc_pkcs15_data_info *data_info = (struct sc_pkcs15_data_info *) object->data;
|
||||
sc_path_t path;
|
||||
u8 id[2];
|
||||
|
@ -671,7 +656,6 @@ static int sc_hsm_emu_delete_object(struct sc_profile *profile, struct sc_pkcs15
|
|||
static int sc_hsm_emu_update_prkd(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||
struct sc_pkcs15_object *object)
|
||||
{
|
||||
struct sc_context *ctx = p15card->card->ctx;
|
||||
struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data;
|
||||
u8 *buf;
|
||||
size_t buflen;
|
||||
|
@ -690,7 +674,6 @@ static int sc_hsm_emu_update_prkd(struct sc_profile *profile, struct sc_pkcs15_c
|
|||
static int sc_hsm_emu_update_dcod(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||
struct sc_pkcs15_object *object)
|
||||
{
|
||||
struct sc_context *ctx = p15card->card->ctx;
|
||||
struct sc_pkcs15_data_info *data_info = (struct sc_pkcs15_data_info *) object->data;
|
||||
u8 *buf;
|
||||
size_t buflen;
|
||||
|
@ -709,7 +692,6 @@ static int sc_hsm_emu_update_dcod(struct sc_profile *profile, struct sc_pkcs15_c
|
|||
static int sc_hsm_emu_update_cd(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||
struct sc_pkcs15_object *object)
|
||||
{
|
||||
struct sc_context *ctx = p15card->card->ctx;
|
||||
struct sc_pkcs15_cert_info *cert_info = (struct sc_pkcs15_cert_info *) object->data;
|
||||
u8 *buf;
|
||||
size_t buflen;
|
||||
|
@ -734,11 +716,7 @@ static int sc_hsm_emu_update_cd(struct sc_profile *profile, struct sc_pkcs15_car
|
|||
static int sc_hsm_emu_delete_cd(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||
struct sc_pkcs15_object *object)
|
||||
{
|
||||
struct sc_context *ctx = p15card->card->ctx;
|
||||
struct sc_pkcs15_cert_info *cert_info = (struct sc_pkcs15_cert_info *) object->data;
|
||||
u8 *buf;
|
||||
size_t buflen;
|
||||
int r;
|
||||
|
||||
if ((cert_info->path.len < 2) ||
|
||||
((cert_info->path.value[cert_info->path.len - 2]) != CA_CERTIFICATE_PREFIX)) {
|
||||
|
|
|
@ -238,7 +238,6 @@ sm_authentic_get_apdu_create_file(struct sc_context *ctx, struct sm_info *sm_inf
|
|||
|
||||
LOG_FUNC_RETURN(ctx, rv);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
sm_authentic_get_apdu_release(struct sc_context *ctx, struct sm_info *sm_info,
|
||||
|
@ -267,6 +266,7 @@ sm_authentic_get_apdu_release(struct sc_context *ctx, struct sm_info *sm_info,
|
|||
|
||||
LOG_FUNC_RETURN(ctx, rv);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -343,7 +343,7 @@ sm_gp_external_authentication(struct sc_context *ctx, struct sm_info *sm_info,
|
|||
unsigned char host_cryptogram[8], raw_apdu[SC_MAX_APDU_BUFFER_SIZE];
|
||||
struct sm_gp_session *gp_session = &sm_info->session.gp;
|
||||
DES_cblock mac;
|
||||
int rv, idx = 0, offs = 0;
|
||||
int rv, offs = 0;
|
||||
|
||||
LOG_FUNC_CALLED(ctx);
|
||||
if (!sm_info || !init_data || !rdata || !rdata->alloc)
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "libopensc/cards.h"
|
||||
#include "libopensc/cardctl.h"
|
||||
#include "util.h"
|
||||
#include "libopensc/log.h"
|
||||
|
||||
#define OPT_RAW 256
|
||||
#define OPT_PRETTY 257
|
||||
|
@ -346,40 +347,6 @@ static int do_userinfo(sc_card_t *card)
|
|||
}
|
||||
|
||||
|
||||
/* Select and read a transparent EF */
|
||||
static int read_transp(sc_card_t *card, const char *pathstring, unsigned char *buf, int buflen)
|
||||
{
|
||||
sc_path_t path;
|
||||
int r;
|
||||
|
||||
sc_format_path(pathstring, &path);
|
||||
r = sc_select_file(card, &path, NULL);
|
||||
if (r < 0)
|
||||
fprintf(stderr, "\nFailed to select file %s: %s\n", pathstring, sc_strerror(r));
|
||||
else {
|
||||
r = sc_read_binary(card, 0, buf, buflen, 0);
|
||||
if (r < 0)
|
||||
fprintf(stderr, "\nFailed to read %s: %s\n", pathstring, sc_strerror(r));
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/* Hex-encode the buf, 2*len+1 bytes must be reserved. E.g. {'1','2'} -> {'3','1','3','2','\0'} */
|
||||
static void bintohex(char *buf, int len)
|
||||
{
|
||||
static const char hextable[] = "0123456789ABCDEF";
|
||||
int i;
|
||||
|
||||
for (i = len - 1; i >= 0; i--) {
|
||||
unsigned char c = (unsigned char) buf[i];
|
||||
|
||||
buf[2 * i + 1] = hextable[c % 16];
|
||||
buf[2 * i] = hextable[c / 16];
|
||||
}
|
||||
}
|
||||
|
||||
int do_genkey(sc_card_t *card, u8 key_id, unsigned int key_len)
|
||||
{
|
||||
int r;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <openssl/evp.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
#include "libopensc/opensc.h"
|
||||
#include "libopensc/cardctl.h"
|
||||
|
@ -922,7 +923,7 @@ static void create_dkek_share(sc_card_t *card, const char *outf, int iter, char
|
|||
|
||||
r = sc_get_challenge(card, filebuff + 8, 8);
|
||||
if (r < 0) {
|
||||
printf("Error generating random number failed with ", sc_strerror(r));
|
||||
printf("Error generating random number failed with %s", sc_strerror(r));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -936,7 +937,7 @@ static void create_dkek_share(sc_card_t *card, const char *outf, int iter, char
|
|||
|
||||
r = sc_get_challenge(card, dkek_share, sizeof(dkek_share));
|
||||
if (r < 0) {
|
||||
printf("Error generating random number failed with ", sc_strerror(r));
|
||||
printf("Error generating random number failed with %s", sc_strerror(r));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1037,7 +1038,6 @@ static void wrap_key(sc_card_t *card, u8 keyid, const char *outf, const char *pi
|
|||
{
|
||||
sc_cardctl_sc_hsm_wrapped_key_t wrapped_key;
|
||||
struct sc_pin_cmd_data data;
|
||||
sc_file_t *file = NULL;
|
||||
sc_path_t path;
|
||||
FILE *out = NULL;
|
||||
u8 fid[2];
|
||||
|
|
Loading…
Reference in New Issue