fido2-token: open the device in {bio,credman}_delete()

while here, remove a redundant check for path == NULL. this
condition is already checked by the caller, token_delete().
This commit is contained in:
pedro martelletto
2021-03-05 11:52:28 +01:00
committed by Konstantinos Georgantas
parent 07f611a123
commit c9de052d3b
4 changed files with 10 additions and 10 deletions

View File

@@ -194,16 +194,15 @@ bio_enroll(char *path)
}
int
bio_delete(fido_dev_t *dev, char *path, char *id)
bio_delete(char *path, char *id)
{
char pin[1024];
fido_dev_t *dev = NULL;
fido_bio_template_t *t = NULL;
int r;
size_t id_blob_len = 0;
void *id_blob_ptr = NULL;
if (path == NULL)
usage();
if ((t = fido_bio_template_new()) == NULL)
errx(1, "fido_bio_template_new");
@@ -213,6 +212,7 @@ bio_delete(fido_dev_t *dev, char *path, char *id)
id_blob_len)) != FIDO_OK)
errx(1, "fido_bio_template_set_id: %s", fido_strerr(r));
dev = open_dev(path);
read_pin(path, pin, sizeof(pin));
r = fido_bio_dev_enroll_remove(dev, t, pin);
explicit_bzero(pin, sizeof(pin));

View File

@@ -199,9 +199,10 @@ out:
}
int
credman_delete_rk(fido_dev_t *dev, const char *path, char *id)
credman_delete_rk(const char *path, char *id)
{
char pin[1024];
fido_dev_t *dev = NULL;
void *id_ptr = NULL;
size_t id_len = 0;
int r;
@@ -209,6 +210,7 @@ credman_delete_rk(fido_dev_t *dev, const char *path, char *id)
if (base64_decode(id, &id_ptr, &id_len) < 0)
errx(1, "base64_decode");
dev = open_dev(path);
read_pin(path, pin, sizeof(pin));
r = fido_credman_del_dev_rk(dev, id_ptr, id_len, pin);
explicit_bzero(pin, sizeof(pin));

View File

@@ -46,7 +46,7 @@ int assert_verify(int, char **);
int base64_decode(const char *, void **, size_t *);
int base64_encode(const void *, size_t, char **);
int base64_read(FILE *, struct blob *);
int bio_delete(fido_dev_t *, char *, char *);
int bio_delete(char *, char *);
int bio_enroll(char *);
void bio_info(fido_dev_t *);
int bio_list(char *);
@@ -65,7 +65,7 @@ int config_pin_minlen(char *, const char *);
int cose_type(const char *, int *);
int cred_make(int, char **);
int cred_verify(int, char **);
int credman_delete_rk(fido_dev_t *, const char *, char *);
int credman_delete_rk(const char *, char *);
int credman_get_metadata(fido_dev_t *, const char *);
int credman_list_rk(char *, const char *);
int credman_list_rp(char *);

View File

@@ -460,7 +460,6 @@ token_delete(int argc, char **argv, char *path)
char *id = NULL;
char *key = NULL;
char *name = NULL;
fido_dev_t *dev = NULL;
int blob = 0;
int ch;
int enroll = 0;
@@ -502,10 +501,9 @@ token_delete(int argc, char **argv, char *path)
if (id) {
if (uv)
usage();
dev = open_dev(path);
if (enroll == 0)
return (credman_delete_rk(dev, path, id));
return (bio_delete(dev, path, id));
return (credman_delete_rk(path, id));
return (bio_delete(path, id));
}
if (uv == 0)