From 15468e6ecc10f158a0f690c38ca4e21af6f39e5e Mon Sep 17 00:00:00 2001 From: Ludvig Michaelsson Date: Wed, 21 Aug 2024 13:37:35 +0200 Subject: [PATCH] examples: consistent style; range syntax --- examples/README.adoc | 2 +- examples/cred.c | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/README.adoc b/examples/README.adoc index 6151b70b..4c43e4d3 100644 --- a/examples/README.adoc +++ b/examples/README.adoc @@ -48,7 +48,7 @@ The following examples are provided: the device's PIN is changed from [oldpin] to . - cred [-t es256|es384|rs256|eddsa] [-k pubkey] [-ei cred_id] [-P pin] - [-T seconds] [-b blobkey] [-hruv] [-c cred_protect] + [-T seconds] [-b blobkey] [-hruv] [-c prot] Creates a new credential on and verify that the credential was signed by the authenticator. The device's attestation certificate diff --git a/examples/cred.c b/examples/cred.c index 5a2a27fd..2dc607ec 100644 --- a/examples/cred.c +++ b/examples/cred.c @@ -36,7 +36,7 @@ static void usage(void) { fprintf(stderr, "usage: cred [-t es256|es384|rs256|eddsa] [-k pubkey] " - "[-ei cred_id] [-P pin] [-T seconds] [-b blobkey] [-c cred_protect] [-hruv] " + "[-ei cred_id] [-P pin] [-T seconds] [-b blobkey] [-c prot] [-hruv] " "\n"); exit(EXIT_FAILURE); } @@ -44,7 +44,7 @@ usage(void) static void verify_cred(int type, const char *fmt, const unsigned char *authdata_ptr, size_t authdata_len, const unsigned char *attstmt_ptr, size_t attstmt_len, - bool rk, bool uv, int ext, int cred_protect, const char *key_out, + bool rk, bool uv, int ext, int prot, const char *key_out, const char *id_out) { fido_cred_t *cred; @@ -87,8 +87,7 @@ verify_cred(int type, const char *fmt, const unsigned char *authdata_ptr, errx(1, "fido_cred_set_uv: %s (0x%x)", fido_strerr(r), r); /* credProt */ - if (cred_protect != 0 && (r = fido_cred_set_prot(cred, - cred_protect)) != FIDO_OK) + if (prot != 0 && (r = fido_cred_set_prot(cred, prot)) != FIDO_OK) errx(1, "fido_cred_set_prot: %s (0x%x)", fido_strerr(r), r); /* fmt */ @@ -165,7 +164,7 @@ main(int argc, char **argv) int ext = 0; int ch; int r; - long long cred_protect = 0; + long long prot = 0; if ((cred = fido_cred_new()) == NULL) errx(1, "fido_cred_new"); @@ -200,10 +199,10 @@ main(int argc, char **argv) ext |= FIDO_EXT_HMAC_SECRET; break; case 'c': - if (base10(optarg, &cred_protect) < 0) + if (base10(optarg, &prot) < 0) errx(1, "base10: %s", optarg); - if (cred_protect <= 0 || cred_protect > 3) - errx(1, "-c: %s must be in (1,3)", optarg); + if (prot <= 0 || prot > 3) + errx(1, "-c: %s must be in (0,3]", optarg); ext |= FIDO_EXT_CRED_PROTECT; break; case 'i': @@ -290,8 +289,7 @@ main(int argc, char **argv) errx(1, "fido_cred_set_uv: %s (0x%x)", fido_strerr(r), r); /* credProt */ - if (cred_protect != 0 && (r = fido_cred_set_prot(cred, - (int)cred_protect)) != FIDO_OK) + if (prot != 0 && (r = fido_cred_set_prot(cred, (int)prot)) != FIDO_OK) errx(1, "fido_cred_set_prot: %s (0x%x)", fido_strerr(r), r); /* timeout */