"-mMODE Set the USB operation mode of the YubiKey NEO.\n"
" Possible MODE arguments are:\n"
" 0 HID device only.\n"
-" 1 CCID device only, permanently attached.\n"
-" 2 CCID device only, with insert/removal.\n"
-" 3 HID/CCID composite device.\n"
+" 1 CCID device only.\n"
+" 2 HID/CCID composite device.\n"
+" Add 80 to set MODE_FLAG_EJECT, for example: 81\n"
"-oOPTION change configuration option. Possible OPTION arguments are:\n"
" salt=ssssssss Salt to be used when deriving key from a\n"
" password. If none is given, a unique random\n"
bool *autocommit, char *salt,
YK_STATUS *st, bool *verbose,
unsigned char *access_code, bool *use_access_code,
- bool *aesviahash, char *ndef_type, char *ndef, int *usb_mode, bool *zap,
+ bool *aesviahash, char *ndef_type, char *ndef, unsigned char *usb_mode, bool *zap,
int *exit_code)
{
int c;
*exit_code = 1;
return 0;
}
+ if(optarg[0] == '8') {
+ *usb_mode |= 0x80;
+ optarg++;
+ }
if(optarg[1] == '\0') {
int mode = optarg[0] - '0';
- if(mode >= 0 && mode < 4) {
- *usb_mode = mode;
+ if(mode >= 0 && mode < MODE_MASK) {
+ *usb_mode |= mode;
usb_mode_seen = true;
}
}
*exit_code = 1;
return 0;
}
- if (!ykp_configure_command(cfg, SLOT_USB_MODE))
+ if (!ykp_configure_command(cfg, SLOT_DEVICE_CONFIG))
return 0;
break;
bool *autocommit, char *salt,
YK_STATUS *st, bool *verbose,
unsigned char *access_code, bool *use_access_code,
- bool *aesviahash, char *ndef_type, char *ndef, int *usb_mode,
+ bool *aesviahash, char *ndef_type, char *ndef, unsigned char *usb_mode,
bool *zap, int *exit_code);
void report_yk_error(void);
}
break;
/* TODO: Make sure this is correct */
- case SLOT_USB_MODE:
+ case SLOT_DEVICE_CONFIG:
/* For testing only */
- if(!(cfg->yk_major_version == 2 && cfg->yk_minor_version == 3 && cfg->yk_build_version == 1)) {
+ if(!(cfg->yk_major_version >= 3)) {
ykp_errno = YKP_EYUBIKEYVER;
return 0;
}
char *salt = NULL;
char ndef_string[128] = {0};
char ndef_type = 0;
- int usb_mode = -1;
+ unsigned char usb_mode = 0;
bool zap = false;
bool error = false;
fprintf(stderr, "Configuration in slot 1 and 2 will be swapped\n");
} else if(ykp_command(cfg) == SLOT_NDEF || ykp_command(cfg) == SLOT_NDEF2) {
fprintf(stderr, "New NDEF will be written as:\n%s\n", ndef_string);
- } else if(ykp_command(cfg) == SLOT_USB_MODE) {
- fprintf(stderr, "The USB mode will be set to: %d\n", usb_mode);
+ } else if(ykp_command(cfg) == SLOT_DEVICE_CONFIG) {
+ fprintf(stderr, "The USB mode will be set to: 0x%x\n", usb_mode);
} else if(zap) {
fprintf(stderr, "Configuration in slot %d will be deleted\n", ykp_config_num(cfg));
} else {
goto err;
}
ykp_free_ndef(ndef);
- } else if(ykp_command(cfg) == SLOT_USB_MODE) {
- if(!yk_set_usb_mode(yk, usb_mode)) {
+ } else if(ykp_command(cfg) == SLOT_DEVICE_CONFIG) {
+ YK_DEVICE_CONFIG *device_config = ykp_alloc_device_config();
+ ykp_set_device_mode(device_config, usb_mode);
+ if(!yk_write_device_config(yk, device_config)) {
if(verbose)
printf(" failure\n");
goto err;
}
+ ykp_free_device_config(device_config);
} else {
YK_CONFIG *ycfg = NULL;
/* if we're deleting a slot we send the configuration as NULL */