pkcs15init: homegenize pin reference type in a different structures; remove unused parameters in the internal procedures;
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4088 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
26dc34c83f
commit
aff7b5523c
|
@ -573,7 +573,7 @@ static int asepcos_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
||||||
/* XXX use the pkcs15 structures for this */
|
/* XXX use the pkcs15 structures for this */
|
||||||
sc_cardctl_asepcos_akn2fileid_t st;
|
sc_cardctl_asepcos_akn2fileid_t st;
|
||||||
|
|
||||||
st.akn = sc_pkcs15init_get_pin_reference(p15card, profile, NULL,
|
st.akn = sc_pkcs15init_get_pin_reference(p15card, profile,
|
||||||
SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
|
SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
|
||||||
r = sc_card_ctl(p15card->card, SC_CARDCTL_ASEPCOS_AKN2FILEID, &st);
|
r = sc_card_ctl(p15card->card, SC_CARDCTL_ASEPCOS_AKN2FILEID, &st);
|
||||||
if (r != SC_SUCCESS) {
|
if (r != SC_SUCCESS) {
|
||||||
|
|
|
@ -119,7 +119,7 @@ tlv_len(struct tlv *tlv)
|
||||||
static int
|
static int
|
||||||
cardos_erase(struct sc_profile *profile, sc_pkcs15_card_t *p15card)
|
cardos_erase(struct sc_profile *profile, sc_pkcs15_card_t *p15card)
|
||||||
{
|
{
|
||||||
return sc_pkcs15init_erase_card_recursively(p15card, profile, -1);
|
return sc_pkcs15init_erase_card_recursively(p15card, profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -349,7 +349,7 @@ cardos_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
||||||
return SC_ERROR_NOT_SUPPORTED;
|
return SC_ERROR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
pin_id = sc_pkcs15init_get_pin_reference(p15card, profile, &key_info->path,
|
pin_id = sc_pkcs15init_get_pin_reference(p15card, profile,
|
||||||
SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
|
SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
|
||||||
if (pin_id >= 0) {
|
if (pin_id >= 0) {
|
||||||
r = sc_pkcs15init_verify_key(profile, p15card, NULL, SC_AC_CHV, pin_id);
|
r = sc_pkcs15init_verify_key(profile, p15card, NULL, SC_AC_CHV, pin_id);
|
||||||
|
@ -641,8 +641,8 @@ cardos_put_key(sc_profile_t *profile, struct sc_pkcs15_card *p15card,
|
||||||
struct sc_card *card = p15card->card;
|
struct sc_card *card = p15card->card;
|
||||||
int r, key_id, pin_id;
|
int r, key_id, pin_id;
|
||||||
|
|
||||||
pin_id = sc_pkcs15init_get_pin_reference(p15card, profile, &key_info->path,
|
pin_id = sc_pkcs15init_get_pin_reference(p15card, profile, SC_AC_SYMBOLIC,
|
||||||
SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
|
SC_PKCS15INIT_USER_PIN);
|
||||||
if (pin_id < 0)
|
if (pin_id < 0)
|
||||||
pin_id = 0;
|
pin_id = 0;
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ incrypto34_erase(struct sc_profile *profile, sc_pkcs15_card_t *p15card)
|
||||||
if ((r = sc_select_file(p15card->card, &path, &file)) < 0)
|
if ((r = sc_select_file(p15card->card, &path, &file)) < 0)
|
||||||
return r;
|
return r;
|
||||||
if ((r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_DELETE)) < 0)
|
if ((r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_DELETE)) < 0)
|
||||||
return sc_pkcs15init_erase_card_recursively(p15card, profile, -1);
|
return sc_pkcs15init_erase_card_recursively(p15card, profile);
|
||||||
else
|
else
|
||||||
return sc_card_ctl(p15card->card, SC_CARDCTL_INCRYPTO34_ERASE_FILES, NULL);
|
return sc_card_ctl(p15card->card, SC_CARDCTL_INCRYPTO34_ERASE_FILES, NULL);
|
||||||
}
|
}
|
||||||
|
@ -611,7 +611,7 @@ incrypto34_put_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
||||||
int r, key_id, pin_id;
|
int r, key_id, pin_id;
|
||||||
|
|
||||||
key_id = key_info->key_reference;
|
key_id = key_info->key_reference;
|
||||||
pin_id = sc_pkcs15init_get_pin_reference(p15card, profile, &key_info->path,
|
pin_id = sc_pkcs15init_get_pin_reference(p15card, profile,
|
||||||
SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
|
SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
|
||||||
if (pin_id < 0)
|
if (pin_id < 0)
|
||||||
pin_id = 0;
|
pin_id = 0;
|
||||||
|
|
|
@ -321,9 +321,8 @@ extern int sc_pkcs15init_authenticate(struct sc_profile *, struct sc_pkcs15_card
|
||||||
struct sc_file *, int);
|
struct sc_file *, int);
|
||||||
extern int sc_pkcs15init_fixup_file(struct sc_profile *, struct sc_pkcs15_card *,
|
extern int sc_pkcs15init_fixup_file(struct sc_profile *, struct sc_pkcs15_card *,
|
||||||
struct sc_file *);
|
struct sc_file *);
|
||||||
extern int sc_pkcs15init_get_pin_info(struct sc_profile *, unsigned int,
|
extern int sc_pkcs15init_get_pin_info(struct sc_profile *, int, struct sc_pkcs15_pin_info *);
|
||||||
struct sc_pkcs15_pin_info *);
|
extern int sc_profile_get_pin_retries(sc_profile_t *, int);
|
||||||
extern int sc_profile_get_pin_retries(sc_profile_t *, unsigned int);
|
|
||||||
extern int sc_pkcs15init_get_manufacturer(struct sc_profile *,
|
extern int sc_pkcs15init_get_manufacturer(struct sc_profile *,
|
||||||
const char **);
|
const char **);
|
||||||
extern int sc_pkcs15init_get_serial(struct sc_profile *, const char **);
|
extern int sc_pkcs15init_get_serial(struct sc_profile *, const char **);
|
||||||
|
@ -345,7 +344,7 @@ extern int sc_pkcs15init_update_any_df(sc_pkcs15_card_t *, sc_profile_t *,
|
||||||
|
|
||||||
/* Erasing the card structure via rm -rf */
|
/* Erasing the card structure via rm -rf */
|
||||||
extern int sc_pkcs15init_erase_card_recursively(struct sc_pkcs15_card *,
|
extern int sc_pkcs15init_erase_card_recursively(struct sc_pkcs15_card *,
|
||||||
struct sc_profile *, int so_ref);
|
struct sc_profile *);
|
||||||
extern int sc_pkcs15init_rmdir(struct sc_pkcs15_card *, struct sc_profile *,
|
extern int sc_pkcs15init_rmdir(struct sc_pkcs15_card *, struct sc_profile *,
|
||||||
struct sc_file *df);
|
struct sc_file *df);
|
||||||
|
|
||||||
|
@ -359,8 +358,7 @@ extern int sc_pkcs15_create_pin_domain(sc_profile_t *, struct sc_pkcs15_card *,
|
||||||
const sc_pkcs15_id_t *, sc_file_t **);
|
const sc_pkcs15_id_t *, sc_file_t **);
|
||||||
|
|
||||||
extern int sc_pkcs15init_get_pin_reference(struct sc_pkcs15_card *,
|
extern int sc_pkcs15init_get_pin_reference(struct sc_pkcs15_card *,
|
||||||
struct sc_profile *, struct sc_path *,
|
struct sc_profile *, unsigned, int);
|
||||||
unsigned, unsigned);
|
|
||||||
|
|
||||||
extern struct sc_pkcs15init_operations *sc_pkcs15init_get_gpk_ops(void);
|
extern struct sc_pkcs15init_operations *sc_pkcs15init_get_gpk_ops(void);
|
||||||
extern struct sc_pkcs15init_operations *sc_pkcs15init_get_miocos_ops(void);
|
extern struct sc_pkcs15init_operations *sc_pkcs15init_get_miocos_ops(void);
|
||||||
|
|
|
@ -86,7 +86,6 @@ typedef int (*pkcs15_encoder)(struct sc_context *,
|
||||||
|
|
||||||
static int sc_pkcs15init_store_data(struct sc_pkcs15_card *,
|
static int sc_pkcs15init_store_data(struct sc_pkcs15_card *,
|
||||||
struct sc_profile *, struct sc_pkcs15_object *,
|
struct sc_profile *, struct sc_pkcs15_object *,
|
||||||
struct sc_pkcs15_id *,
|
|
||||||
struct sc_pkcs15_der *, struct sc_path *);
|
struct sc_pkcs15_der *, struct sc_path *);
|
||||||
static size_t sc_pkcs15init_keybits(struct sc_pkcs15_bignum *);
|
static size_t sc_pkcs15init_keybits(struct sc_pkcs15_bignum *);
|
||||||
|
|
||||||
|
@ -118,7 +117,7 @@ static int select_intrinsic_id(struct sc_pkcs15_card *, struct sc_profile *,
|
||||||
int, struct sc_pkcs15_id *, void *);
|
int, struct sc_pkcs15_id *, void *);
|
||||||
static int select_id(struct sc_pkcs15_card *, int, struct sc_pkcs15_id *);
|
static int select_id(struct sc_pkcs15_card *, int, struct sc_pkcs15_id *);
|
||||||
static int select_object_path(struct sc_pkcs15_card *, struct sc_profile *,
|
static int select_object_path(struct sc_pkcs15_card *, struct sc_profile *,
|
||||||
struct sc_pkcs15_object *, struct sc_pkcs15_id *, struct sc_path *);
|
struct sc_pkcs15_object *, struct sc_path *);
|
||||||
static int sc_pkcs15init_get_pin_path(struct sc_pkcs15_card *,
|
static int sc_pkcs15init_get_pin_path(struct sc_pkcs15_card *,
|
||||||
struct sc_pkcs15_id *, struct sc_path *);
|
struct sc_pkcs15_id *, struct sc_path *);
|
||||||
static int sc_pkcs15init_qualify_pin(struct sc_card *, const char *,
|
static int sc_pkcs15init_qualify_pin(struct sc_card *, const char *,
|
||||||
|
@ -451,7 +450,7 @@ sc_pkcs15init_erase_card(struct sc_pkcs15_card *p15card, struct sc_profile *prof
|
||||||
|
|
||||||
int
|
int
|
||||||
sc_pkcs15init_erase_card_recursively(struct sc_pkcs15_card *p15card,
|
sc_pkcs15init_erase_card_recursively(struct sc_pkcs15_card *p15card,
|
||||||
struct sc_profile *profile, int so_pin_ref)
|
struct sc_profile *profile)
|
||||||
{
|
{
|
||||||
struct sc_file *df = profile->df_info->file, *dir;
|
struct sc_file *df = profile->df_info->file, *dir;
|
||||||
int r;
|
int r;
|
||||||
|
@ -1088,7 +1087,7 @@ sc_pkcs15init_init_prkdf(struct sc_pkcs15_card *p15card,
|
||||||
keyinfo_gostparams->gost28147 = keyargs->gost_params.gost28147;
|
keyinfo_gostparams->gost28147 = keyargs->gost_params.gost28147;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = select_object_path(p15card, profile, object, &key_info->id, &key_info->path);
|
r = select_object_path(p15card, profile, object, &key_info->path);
|
||||||
SC_TEST_RET(ctx, r, "Failed to select private key object path");
|
SC_TEST_RET(ctx, r, "Failed to select private key object path");
|
||||||
|
|
||||||
/* See if we need to select a key reference for this object */
|
/* See if we need to select a key reference for this object */
|
||||||
|
@ -1280,8 +1279,7 @@ sc_pkcs15init_store_private_key(struct sc_pkcs15_card *p15card,
|
||||||
der = &wrapped;
|
der = &wrapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sc_pkcs15init_store_data(p15card, profile,
|
r = sc_pkcs15init_store_data(p15card, profile, object, der, &key_info->path);
|
||||||
object, &keyargs->id, der, &key_info->path);
|
|
||||||
|
|
||||||
/* If the key is encrypted, flag the PrKDF entry as
|
/* If the key is encrypted, flag the PrKDF entry as
|
||||||
* indirect-protected */
|
* indirect-protected */
|
||||||
|
@ -1436,9 +1434,7 @@ sc_pkcs15init_store_public_key(struct sc_pkcs15_card *p15card,
|
||||||
SC_TEST_RET(ctx, r, "Encode public key error");
|
SC_TEST_RET(ctx, r, "Encode public key error");
|
||||||
|
|
||||||
/* Now create key file and store key */
|
/* Now create key file and store key */
|
||||||
r = sc_pkcs15init_store_data(p15card, profile,
|
r = sc_pkcs15init_store_data(p15card, profile, object, &der_encoded, &key_info->path);
|
||||||
object, &keyargs->id,
|
|
||||||
&der_encoded, &key_info->path);
|
|
||||||
|
|
||||||
path = &key_info->path;
|
path = &key_info->path;
|
||||||
if (path->count == 0) {
|
if (path->count == 0) {
|
||||||
|
@ -1503,8 +1499,7 @@ sc_pkcs15init_store_certificate(struct sc_pkcs15_card *p15card,
|
||||||
if (profile->pkcs15.direct_certificates)
|
if (profile->pkcs15.direct_certificates)
|
||||||
sc_der_copy(&cert_info->value, &args->der_encoded);
|
sc_der_copy(&cert_info->value, &args->der_encoded);
|
||||||
else
|
else
|
||||||
r = sc_pkcs15init_store_data(p15card, profile, object, &args->id,
|
r = sc_pkcs15init_store_data(p15card, profile, object, &args->der_encoded, &cert_info->path);
|
||||||
&args->der_encoded, &cert_info->path);
|
|
||||||
|
|
||||||
/* Now update the CDF */
|
/* Now update the CDF */
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
|
@ -1582,8 +1577,7 @@ sc_pkcs15init_store_data_object(struct sc_pkcs15_card *p15card,
|
||||||
}
|
}
|
||||||
data_object_info->app_oid = args->app_oid;
|
data_object_info->app_oid = args->app_oid;
|
||||||
|
|
||||||
r = sc_pkcs15init_store_data(p15card, profile,
|
r = sc_pkcs15init_store_data(p15card, profile, object, &args->der_encoded,
|
||||||
object, &args->id, &args->der_encoded,
|
|
||||||
&data_object_info->path);
|
&data_object_info->path);
|
||||||
|
|
||||||
/* Now update the DDF */
|
/* Now update the DDF */
|
||||||
|
@ -1602,8 +1596,7 @@ sc_pkcs15init_store_data_object(struct sc_pkcs15_card *p15card,
|
||||||
|
|
||||||
int
|
int
|
||||||
sc_pkcs15init_get_pin_reference(struct sc_pkcs15_card *p15card,
|
sc_pkcs15init_get_pin_reference(struct sc_pkcs15_card *p15card,
|
||||||
struct sc_profile *profile, struct sc_path *path,
|
struct sc_profile *profile, unsigned auth_method, int reference)
|
||||||
unsigned auth_method, unsigned reference)
|
|
||||||
{
|
{
|
||||||
struct sc_context *ctx = p15card->card->ctx;
|
struct sc_context *ctx = p15card->card->ctx;
|
||||||
struct sc_pkcs15_pin_info pinfo;
|
struct sc_pkcs15_pin_info pinfo;
|
||||||
|
@ -1680,11 +1673,8 @@ sc_pkcs15init_get_pin_reference(struct sc_pkcs15_card *p15card,
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sc_pkcs15init_store_data(struct sc_pkcs15_card *p15card,
|
sc_pkcs15init_store_data(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
||||||
struct sc_profile *profile,
|
struct sc_pkcs15_object *object, struct sc_pkcs15_der *data,
|
||||||
struct sc_pkcs15_object *object,
|
|
||||||
struct sc_pkcs15_id *id,
|
|
||||||
struct sc_pkcs15_der *data,
|
|
||||||
struct sc_path *path)
|
struct sc_path *path)
|
||||||
{
|
{
|
||||||
struct sc_context *ctx = p15card->card->ctx;
|
struct sc_context *ctx = p15card->card->ctx;
|
||||||
|
@ -1693,7 +1683,7 @@ sc_pkcs15init_store_data(struct sc_pkcs15_card *p15card,
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, 3);
|
SC_FUNC_CALLED(ctx, 3);
|
||||||
|
|
||||||
r = select_object_path(p15card, profile, object, id, path);
|
r = select_object_path(p15card, profile, object, path);
|
||||||
SC_TEST_RET(ctx, r, "Failed to select object path");
|
SC_TEST_RET(ctx, r, "Failed to select object path");
|
||||||
|
|
||||||
r = sc_profile_get_file_by_path(profile, path, &file);
|
r = sc_profile_get_file_by_path(profile, path, &file);
|
||||||
|
@ -2209,7 +2199,7 @@ select_id(struct sc_pkcs15_card *p15card, int type, struct sc_pkcs15_id *id)
|
||||||
* wish to create ("private-key", "public-key" etc).
|
* wish to create ("private-key", "public-key" etc).
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
get_template_name_from_object (struct sc_context *ctx, struct sc_pkcs15_object *obj)
|
get_template_name_from_object (struct sc_pkcs15_object *obj)
|
||||||
{
|
{
|
||||||
switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
|
switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
|
||||||
case SC_PKCS15_TYPE_PRKEY:
|
case SC_PKCS15_TYPE_PRKEY:
|
||||||
|
@ -2230,8 +2220,7 @@ get_template_name_from_object (struct sc_context *ctx, struct sc_pkcs15_object *
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_object_path_from_object (struct sc_context *ctx,
|
get_object_path_from_object (struct sc_pkcs15_object *obj,
|
||||||
struct sc_pkcs15_object *obj,
|
|
||||||
struct sc_path *ret_path)
|
struct sc_path *ret_path)
|
||||||
{
|
{
|
||||||
if (!ret_path)
|
if (!ret_path)
|
||||||
|
@ -2262,8 +2251,7 @@ get_object_path_from_object (struct sc_context *ctx,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
select_object_path(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
select_object_path(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
||||||
struct sc_pkcs15_object *obj, struct sc_pkcs15_id *obj_id,
|
struct sc_pkcs15_object *obj, struct sc_path *path)
|
||||||
struct sc_path *path)
|
|
||||||
{
|
{
|
||||||
struct sc_context *ctx = p15card->card->ctx;
|
struct sc_context *ctx = p15card->card->ctx;
|
||||||
struct sc_file *file;
|
struct sc_file *file;
|
||||||
|
@ -2294,7 +2282,7 @@ select_object_path(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
||||||
/* If the profile specifies a key directory template,
|
/* If the profile specifies a key directory template,
|
||||||
* instantiate it now and create the DF
|
* instantiate it now and create the DF
|
||||||
*/
|
*/
|
||||||
name = get_template_name_from_object (ctx, obj);
|
name = get_template_name_from_object (obj);
|
||||||
if (!name)
|
if (!name)
|
||||||
SC_FUNC_RETURN(ctx, 3, SC_SUCCESS);
|
SC_FUNC_RETURN(ctx, 3, SC_SUCCESS);
|
||||||
|
|
||||||
|
@ -2322,7 +2310,7 @@ select_object_path(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
||||||
|
|
||||||
sc_debug(ctx, "instantiated template path %s", sc_print_path(&file->path));
|
sc_debug(ctx, "instantiated template path %s", sc_print_path(&file->path));
|
||||||
for (ii=0; ii<nn_objs; ii++) {
|
for (ii=0; ii<nn_objs; ii++) {
|
||||||
r = get_object_path_from_object(ctx, objs[ii], &obj_path);
|
r = get_object_path_from_object(objs[ii], &obj_path);
|
||||||
SC_TEST_RET(ctx, r, "Failed to get object path from pkcs15 object");
|
SC_TEST_RET(ctx, r, "Failed to get object path from pkcs15 object");
|
||||||
|
|
||||||
if (obj_path.len != file->path.len)
|
if (obj_path.len != file->path.len)
|
||||||
|
@ -2962,7 +2950,7 @@ do_get_and_verify_secret(struct sc_profile *profile, struct sc_pkcs15_card *p15c
|
||||||
pin_info.auth_method = type;
|
pin_info.auth_method = type;
|
||||||
pin_info.reference = reference;
|
pin_info.reference = reference;
|
||||||
|
|
||||||
pin_id = sc_pkcs15init_get_pin_reference(p15card, profile, file ? path : NULL, type, reference);
|
pin_id = sc_pkcs15init_get_pin_reference(p15card, profile, type, reference);
|
||||||
sc_debug(ctx, "sc_pkcs15init_get_pin_reference(type:%X,reference:%X) pin_id:%i\n", type, reference, pin_id);
|
sc_debug(ctx, "sc_pkcs15init_get_pin_reference(type:%X,reference:%X) pin_id:%i\n", type, reference, pin_id);
|
||||||
if (type == SC_AC_SYMBOLIC) {
|
if (type == SC_AC_SYMBOLIC) {
|
||||||
if (pin_id == -1)
|
if (pin_id == -1)
|
||||||
|
@ -3307,20 +3295,19 @@ sc_pkcs15init_update_file(struct sc_profile *profile,
|
||||||
* PIN name with the real reference.
|
* PIN name with the real reference.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
sc_pkcs15init_fixup_acls(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
sc_pkcs15init_fixup_acls(struct sc_pkcs15_card *p15card, struct sc_file *file,
|
||||||
struct sc_file *file,
|
|
||||||
struct sc_acl_entry *so_acl, struct sc_acl_entry *user_acl)
|
struct sc_acl_entry *so_acl, struct sc_acl_entry *user_acl)
|
||||||
{
|
{
|
||||||
struct sc_context *ctx = p15card->card->ctx;
|
struct sc_context *ctx = p15card->card->ctx;
|
||||||
struct sc_acl_entry acls[16];
|
unsigned int op;
|
||||||
unsigned int op, num;
|
int r = 0;
|
||||||
int r = 0, ii;
|
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, 3);
|
SC_FUNC_CALLED(ctx, 3);
|
||||||
for (op = 0; r == 0 && op < SC_MAX_AC_OPS; op++) {
|
for (op = 0; r == 0 && op < SC_MAX_AC_OPS; op++) {
|
||||||
|
struct sc_acl_entry acls[16];
|
||||||
const struct sc_acl_entry *acl;
|
const struct sc_acl_entry *acl;
|
||||||
const char *what;
|
const char *what;
|
||||||
int added = 0;
|
int added = 0, num, ii;
|
||||||
|
|
||||||
/* First, get original ACLs */
|
/* First, get original ACLs */
|
||||||
acl = sc_file_get_acl_entry(file, op);
|
acl = sc_file_get_acl_entry(file, op);
|
||||||
|
@ -3395,7 +3382,7 @@ sc_pkcs15init_fixup_file(struct sc_profile *profile,
|
||||||
if (!needfix)
|
if (!needfix)
|
||||||
SC_FUNC_RETURN(ctx, 3, SC_SUCCESS);
|
SC_FUNC_RETURN(ctx, 3, SC_SUCCESS);
|
||||||
|
|
||||||
pin_ref = sc_pkcs15init_get_pin_reference(p15card, profile, NULL, SC_AC_SYMBOLIC, SC_PKCS15INIT_SO_PIN);
|
pin_ref = sc_pkcs15init_get_pin_reference(p15card, profile, SC_AC_SYMBOLIC, SC_PKCS15INIT_SO_PIN);
|
||||||
if (pin_ref < 0) {
|
if (pin_ref < 0) {
|
||||||
so_acl.method = SC_AC_NONE;
|
so_acl.method = SC_AC_NONE;
|
||||||
so_acl.key_ref = 0;
|
so_acl.key_ref = 0;
|
||||||
|
@ -3405,7 +3392,7 @@ sc_pkcs15init_fixup_file(struct sc_profile *profile,
|
||||||
so_acl.key_ref = pin_ref;
|
so_acl.key_ref = pin_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
pin_ref = sc_pkcs15init_get_pin_reference(p15card, profile, NULL, SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
|
pin_ref = sc_pkcs15init_get_pin_reference(p15card, profile, SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
|
||||||
if (pin_ref < 0) {
|
if (pin_ref < 0) {
|
||||||
user_acl.method = SC_AC_NONE;
|
user_acl.method = SC_AC_NONE;
|
||||||
user_acl.key_ref = 0;
|
user_acl.key_ref = 0;
|
||||||
|
@ -3417,7 +3404,7 @@ sc_pkcs15init_fixup_file(struct sc_profile *profile,
|
||||||
sc_debug(ctx, "so_acl(method:%X,ref:%X), user_acl(method:%X,ref:%X)\n",
|
sc_debug(ctx, "so_acl(method:%X,ref:%X), user_acl(method:%X,ref:%X)\n",
|
||||||
so_acl.method, so_acl.key_ref, user_acl.method, user_acl.key_ref);
|
so_acl.method, so_acl.key_ref, user_acl.method, user_acl.key_ref);
|
||||||
|
|
||||||
rv = sc_pkcs15init_fixup_acls(profile, p15card, file, &so_acl, &user_acl);
|
rv = sc_pkcs15init_fixup_acls(p15card, file, &so_acl, &user_acl);
|
||||||
|
|
||||||
SC_FUNC_RETURN(ctx, 3, rv);
|
SC_FUNC_RETURN(ctx, 3, rv);
|
||||||
}
|
}
|
||||||
|
@ -3440,7 +3427,7 @@ sc_pkcs15init_get_pin_path(struct sc_pkcs15_card *p15card,
|
||||||
|
|
||||||
int
|
int
|
||||||
sc_pkcs15init_get_pin_info(struct sc_profile *profile,
|
sc_pkcs15init_get_pin_info(struct sc_profile *profile,
|
||||||
unsigned int id, struct sc_pkcs15_pin_info *pin)
|
int id, struct sc_pkcs15_pin_info *pin)
|
||||||
{
|
{
|
||||||
sc_profile_get_pin_info(profile, id, pin);
|
sc_profile_get_pin_info(profile, id, pin);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -740,8 +740,8 @@ static int starcos_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
||||||
tkey.key_header[1] = (STARCOS_MAX_PR_KEYSIZE >> 8) & 0xff;
|
tkey.key_header[1] = (STARCOS_MAX_PR_KEYSIZE >> 8) & 0xff;
|
||||||
tkey.key_header[2] = STARCOS_MAX_PR_KEYSIZE & 0xff;
|
tkey.key_header[2] = STARCOS_MAX_PR_KEYSIZE & 0xff;
|
||||||
|
|
||||||
pin_id = sc_pkcs15init_get_pin_reference(p15card, profile, &kinfo->path,
|
pin_id = sc_pkcs15init_get_pin_reference(p15card, profile, SC_AC_SYMBOLIC,
|
||||||
SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
|
SC_PKCS15INIT_USER_PIN);
|
||||||
if (pin_id < 0)
|
if (pin_id < 0)
|
||||||
state = STARCOS_AC_ALWAYS;
|
state = STARCOS_AC_ALWAYS;
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -229,7 +229,7 @@ static file_info * sc_profile_find_file_by_path(
|
||||||
struct sc_profile *,
|
struct sc_profile *,
|
||||||
const sc_path_t *);
|
const sc_path_t *);
|
||||||
|
|
||||||
static pin_info * new_pin(struct sc_profile *, unsigned int);
|
static pin_info * new_pin(struct sc_profile *, int);
|
||||||
static file_info * new_file(struct state *, const char *,
|
static file_info * new_file(struct state *, const char *,
|
||||||
unsigned int);
|
unsigned int);
|
||||||
static file_info * add_file(sc_profile_t *, const char *,
|
static file_info * add_file(sc_profile_t *, const char *,
|
||||||
|
@ -442,7 +442,7 @@ sc_profile_free(struct sc_profile *profile)
|
||||||
|
|
||||||
void
|
void
|
||||||
sc_profile_get_pin_info(struct sc_profile *profile,
|
sc_profile_get_pin_info(struct sc_profile *profile,
|
||||||
unsigned int id, struct sc_pkcs15_pin_info *info)
|
int id, struct sc_pkcs15_pin_info *info)
|
||||||
{
|
{
|
||||||
struct pin_info *pi;
|
struct pin_info *pi;
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ sc_profile_get_pin_info(struct sc_profile *profile,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sc_profile_get_pin_retries(sc_profile_t *profile, unsigned int id)
|
sc_profile_get_pin_retries(sc_profile_t *profile, int id)
|
||||||
{
|
{
|
||||||
struct pin_info *pi;
|
struct pin_info *pi;
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ sc_profile_get_pin_retries(sc_profile_t *profile, unsigned int id)
|
||||||
|
|
||||||
int
|
int
|
||||||
sc_profile_get_pin_id(struct sc_profile *profile,
|
sc_profile_get_pin_id(struct sc_profile *profile,
|
||||||
unsigned int reference, unsigned int *id)
|
unsigned int reference, int *id)
|
||||||
{
|
{
|
||||||
struct pin_info *pi;
|
struct pin_info *pi;
|
||||||
|
|
||||||
|
@ -715,7 +715,7 @@ sc_profile_instantiate_file(sc_profile_t *profile, file_info *ft,
|
||||||
|
|
||||||
int
|
int
|
||||||
sc_profile_get_pin_id_by_reference(struct sc_profile *profile,
|
sc_profile_get_pin_id_by_reference(struct sc_profile *profile,
|
||||||
unsigned auth_method, unsigned reference,
|
unsigned auth_method, int reference,
|
||||||
struct sc_pkcs15_pin_info *pin_info)
|
struct sc_pkcs15_pin_info *pin_info)
|
||||||
{
|
{
|
||||||
struct pin_info *pinfo;
|
struct pin_info *pinfo;
|
||||||
|
@ -1354,13 +1354,13 @@ process_pin(struct state *cur, struct block *info,
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
init_state(cur, &state);
|
init_state(cur, &state);
|
||||||
state.pin = new_pin(cur->profile, id);
|
state.pin = new_pin(cur->profile, (int)id);
|
||||||
|
|
||||||
return process_block(&state, info, name, blk);
|
return process_block(&state, info, name, blk);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pin_info *
|
static struct pin_info *
|
||||||
new_pin(struct sc_profile *profile, unsigned int id)
|
new_pin(struct sc_profile *profile, int id)
|
||||||
{
|
{
|
||||||
struct pin_info *pi, **tail;
|
struct pin_info *pi, **tail;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ struct file_info {
|
||||||
* in the same file as the PIN
|
* in the same file as the PIN
|
||||||
*/
|
*/
|
||||||
struct pin_info {
|
struct pin_info {
|
||||||
unsigned int id;
|
int id;
|
||||||
struct pin_info * next;
|
struct pin_info * next;
|
||||||
char * file_name; /* obsolete */
|
char * file_name; /* obsolete */
|
||||||
unsigned int file_offset; /* obsolete */
|
unsigned int file_offset; /* obsolete */
|
||||||
|
@ -127,9 +127,9 @@ int sc_profile_finish(struct sc_profile *);
|
||||||
void sc_profile_free(struct sc_profile *);
|
void sc_profile_free(struct sc_profile *);
|
||||||
int sc_profile_build_pkcs15(struct sc_profile *);
|
int sc_profile_build_pkcs15(struct sc_profile *);
|
||||||
void sc_profile_get_pin_info(struct sc_profile *,
|
void sc_profile_get_pin_info(struct sc_profile *,
|
||||||
unsigned int, struct sc_pkcs15_pin_info *);
|
int, struct sc_pkcs15_pin_info *);
|
||||||
int sc_profile_get_pin_id(struct sc_profile *,
|
int sc_profile_get_pin_id(struct sc_profile *,
|
||||||
unsigned int, unsigned int *);
|
unsigned int, int *);
|
||||||
int sc_profile_get_file(struct sc_profile *, const char *,
|
int sc_profile_get_file(struct sc_profile *, const char *,
|
||||||
struct sc_file **);
|
struct sc_file **);
|
||||||
int sc_profile_get_file_by_path(struct sc_profile *,
|
int sc_profile_get_file_by_path(struct sc_profile *,
|
||||||
|
@ -147,7 +147,7 @@ int sc_profile_add_file(struct sc_profile *,
|
||||||
int sc_profile_get_file_instance(struct sc_profile *, const char *,
|
int sc_profile_get_file_instance(struct sc_profile *, const char *,
|
||||||
int, sc_file_t **);
|
int, sc_file_t **);
|
||||||
int sc_profile_get_pin_id_by_reference(struct sc_profile *,
|
int sc_profile_get_pin_id_by_reference(struct sc_profile *,
|
||||||
unsigned, unsigned, struct sc_pkcs15_pin_info *);
|
unsigned, int, struct sc_pkcs15_pin_info *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue