This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/17999 ) Change subject: WIP: PIN validation ...................................................................... WIP: PIN validation Change-Id: I3d8441d6dcd94b8b11bb1fbcee56c754bca9aefe --- M utils/osmo-sim-test.c 1 file changed, 20 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/99/17999/1 diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c index ae55b83..201d22b 100644 --- a/utils/osmo-sim-test.c +++ b/utils/osmo-sim-test.c @@ -41,6 +41,7 @@ static uint8_t g_class = 0x00; /* UICC/USIM */ static const char *g_output_dir; +static const char *g_pin; /* 11.1.1 */ static struct msgb *_select_file(struct osim_chan_hdl *st, uint8_t p1, uint8_t p2, @@ -77,15 +78,14 @@ return _select_file(st, 0x00, p2, (uint8_t *)&cfid, 2); } -#if 0 /* 11.1.9 */ -static int verify_pin(struct osim_chan_hdl *st, uint8_t pin_nr, char *pin) +static struct msgb *verify_pin(struct osim_chan_hdl *st, uint8_t pin_nr, const char *pin) { struct msgb *msg; char *pindst; if (strlen(pin) > 8) - return -EINVAL; + return NULL; msg = osim_new_apdumsg(g_class, 0x20, 0x00, pin_nr, 8, 0); pindst = (char *) msgb_put(msg, 8); @@ -93,9 +93,10 @@ /* Do not copy the terminating \0 */ memcpy(pindst, pin, strlen(pin)); - return osim_transceive_apdu(st, msg); + osim_transceive_apdu(st, msg); + + return msg; } -#endif /* 11.1.5 */ static struct msgb *read_record_nr(struct osim_chan_hdl *st, uint8_t rec_nr, uint16_t rec_size) @@ -464,6 +465,7 @@ " -h --help This message\n" " -n --reader-num NR Open reader number NR\n" " -o --output-dir DIR To-be-created output directory for filesystem dump\n" + " -p --pin PIN Authenticate using the given PIN\n" ); } @@ -477,10 +479,11 @@ { "help", 0, 0, 'h' }, { "reader-num", 1, 0, 'n' }, { "output-dir", 1, 0, 'o' }, + { "pin", 1, 0, 'p' }, {0,0,0,0} }; - c = getopt_long(argc, argv, "hn:o:", + c = getopt_long(argc, argv, "hn:o:p:", long_options, &option_index); if (c == -1) break; @@ -496,6 +499,9 @@ case 'o': g_output_dir = optarg; break; + case 'p': + g_pin = optarg; + break; default: exit(2); break; @@ -645,7 +651,14 @@ if (!chan) exit(3); - //verify_pin(chan, 1, "1653"); + if (g_pin) { + struct msgb *msg; + msg = verify_pin(chan, 1, g_pin); + if (!msg /*|| FIXME*/) { + fprintf(stderr, "Error authenticating PIN: %s\n"); + exit(6); + } + } rc = osim_uicc_scan_apps(chan); if (rc >= 0) { -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17999 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I3d8441d6dcd94b8b11bb1fbcee56c754bca9aefe Gerrit-Change-Number: 17999 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200502/9c738d55/attachment.htm>