- erase card fixes: forget cached secrets, and use sc_free_apps

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1123 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
okir 2003-05-15 13:33:04 +00:00
parent b68cb1e0b3
commit 8c7e571c89
3 changed files with 22 additions and 0 deletions

View File

@ -254,6 +254,8 @@ sc_pkcs15init_erase_card_recursively(struct sc_card *card,
/* Unfrob the SO pin reference, and return */
out: sc_profile_set_pin_info(profile, SC_PKCS15INIT_SO_PIN, &sopin);
sc_profile_forget_secrets(profile, SC_AC_CHV, -1);
sc_free_apps(card);
if (profile->p15_card != p15orig) {
sc_pkcs15_unbind(profile->p15_card);
profile->p15_card = p15orig;

View File

@ -1244,6 +1244,24 @@ sc_profile_get_secret(struct sc_profile *profile,
return SC_ERROR_OBJECT_NOT_FOUND;
}
void
sc_profile_forget_secrets(struct sc_profile *profile,
unsigned int type, int ref)
{
struct auth_info *ai, **aip;
aip = &profile->auth_list;
while ((ai = *aip) != NULL) {
if (ai->type == type
&& (ref < 0 || ai->ref == (unsigned int) ref)) {
*aip = ai->next;
free(ai);
} else {
aip = &ai->next;
}
}
}
void
sc_profile_set_so_pin(struct sc_profile *profile, const char *value)
{

View File

@ -86,6 +86,8 @@ void sc_profile_set_secret(struct sc_profile *,
unsigned int, unsigned int, const u8 *, size_t);
int sc_profile_get_secret(struct sc_profile *,
unsigned int, unsigned int, u8 *, size_t *);
void sc_profile_forget_secrets(struct sc_profile *,
unsigned int, int);
void sc_profile_get_pin_info(struct sc_profile *,
unsigned int, struct sc_pkcs15_pin_info *);
int sc_profile_get_pin_id(struct sc_profile *,