const char *infname = NULL;
const char *outfname = NULL;
bool verbose = false;
+ bool dry_run = false;
bool aesviahash = false;
bool use_access_code = false;
unsigned char access_code[256];
&infname, &outfname,
&data_format,
&autocommit, salt,
- st, &verbose,
+ st, &verbose, &dry_run,
access_code, &use_access_code,
&aesviahash, &ndef_type, ndef, &usb_mode, &zap,
scan_map, &exit_code);
const char *infname = NULL;
const char *outfname = NULL;
bool verbose = false;
+ bool dry_run = false;
bool aesviahash = false;
bool use_access_code = false;
unsigned char access_code[256];
&infname, &outfname,
&data_format,
&autocommit, salt,
- st, &verbose,
+ st, &verbose, &dry_run,
access_code, &use_access_code,
&aesviahash, &ndef_type, ndef, &usb_mode, &zap,
scan_map, &exit_code);
"\n"
"-y always commit (do not prompt)\n"
"\n"
+"-d dry-run (don't write anything to key)\n"
+"\n"
"-v verbose\n"
"-h help (this text)\n"
;
-const char *optstring = "u12xza:c:n:t:hi:o:s:f:vym:S::";
+const char *optstring = "u12xza:c:n:t:hi:o:s:f:dvym:S::";
static int _set_fixed(char *opt, YKP_CONFIG *cfg);
static int _format_decimal_as_hex(uint8_t *dst, size_t dst_len, uint8_t *src);
const char **infname, const char **outfname,
int *data_format,
bool *autocommit, char *salt,
- YK_STATUS *st, bool *verbose,
+ YK_STATUS *st, bool *verbose, bool *dry_run,
unsigned char *access_code, bool *use_access_code,
bool *aesviahash, char *ndef_type, char *ndef,
unsigned char *usb_mode, bool *zap,
return 0;
}
break;
+ case 'd':
+ *dry_run = true;
+ break;
case 'v':
*verbose = true;
break;
const char **infname, const char **outfname,
int *data_format,
bool *autocommit, char *salt,
- YK_STATUS *st, bool *verbose,
+ YK_STATUS *st, bool *verbose, bool *dry_run,
unsigned char *access_code, bool *use_access_code,
bool *aesviahash, char *ndef_type, char *ndef, unsigned char *usb_mode,
bool *zap, unsigned char *scan_bin, int *exit_code);
.SH SYNOPSIS
.B ykpersonalize
[\fI-1\fR | \fI-2\fR] [\fI-sfile\fR] [\fI-ifile\fR] [\fI-fformat\fR] [\fI-axxx\fR] [\fI-cxxx\fR]
-[\fI-ooption\fR] [\fI-y\fR] [\fI-v\fR] [\fI-h\fR] [\fI-n\fR] [\fI-t\fR] [\fI-u\fR] [\fI-x\fR]
+[\fI-ooption\fR] [\fI-y\fR] [\fI-v\fR] [\fI-d\fR] [\fI-h\fR] [\fI-n\fR] [\fI-t\fR] [\fI-u\fR] [\fI-x\fR]
[\fI-z\fR] [\fI-m\fR] [\fI-S\fR]
.\".SH DESCRIPTION
.\" Add any additional description here
\fB-y\fR
always commit without prompting
.TP
+\fB-d\fR
+dry-run, run without writing a YubiKey
+.TP
\fB-v\fR
Be more verbose
.TP
YK_STATUS *st = ykds_alloc();
bool autocommit = false;
char data[1024];
+ bool dry_run = false;
/* Options */
char *salt = NULL;
&infname, &outfname,
&data_format,
&autocommit, salt,
- st, &verbose,
+ st, &verbose, &dry_run,
access_code, &use_access_code,
&aesviahash, &ndef_type, ndef_string,
&usb_mode, &zap, scan_codes, &exit_code)) {
if (verbose)
printf("Attempting to write configuration to the yubikey...");
- if(ykp_command(cfg) == SLOT_NDEF || ykp_command(cfg) == SLOT_NDEF2) {
+ if (dry_run) {
+ printf("Not writing anything to key due to dry_run requested.\n");
+ }
+ else if(ykp_command(cfg) == SLOT_NDEF || ykp_command(cfg) == SLOT_NDEF2) {
YK_NDEF *ndef = ykp_alloc_ndef();
int confnum = 1;
if(ndef_type == 'U') {
}
}
- if (verbose)
+ if (verbose && !dry_run)
printf(" success\n");
}
}