diff options
-rw-r--r-- | ssh-keygen.1 | 39 | ||||
-rw-r--r-- | ssh-keygen.c | 45 |
2 files changed, 46 insertions, 38 deletions
diff --git a/ssh-keygen.1 b/ssh-keygen.1 index 9afb92943..1f4edace5 100644 --- a/ssh-keygen.1 +++ b/ssh-keygen.1 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: ssh-keygen.1,v 1.184 2019/12/30 03:30:09 djm Exp $ | 1 | .\" $OpenBSD: ssh-keygen.1,v 1.185 2019/12/30 09:49:52 djm Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | .\" Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | .\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | .\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -48,10 +48,10 @@ | |||
48 | .Op Fl C Ar comment | 48 | .Op Fl C Ar comment |
49 | .Op Fl f Ar output_keyfile | 49 | .Op Fl f Ar output_keyfile |
50 | .Op Fl m Ar format | 50 | .Op Fl m Ar format |
51 | .Op Fl O Ar option | ||
51 | .Op Fl t Cm dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa | 52 | .Op Fl t Cm dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa |
52 | .Op Fl N Ar new_passphrase | 53 | .Op Fl N Ar new_passphrase |
53 | .Op Fl w Ar provider | 54 | .Op Fl w Ar provider |
54 | .Op Fl x Ar flags | ||
55 | .Nm ssh-keygen | 55 | .Nm ssh-keygen |
56 | .Fl p | 56 | .Fl p |
57 | .Op Fl f Ar keyfile | 57 | .Op Fl f Ar keyfile |
@@ -453,7 +453,28 @@ listed in the | |||
453 | .Sx MODULI GENERATION | 453 | .Sx MODULI GENERATION |
454 | section may be specified. | 454 | section may be specified. |
455 | .Pp | 455 | .Pp |
456 | This option may be specified multiple times. | 456 | When generating a key that will be hosted on a FIDO authenticator, this |
457 | flag may be used to specify key-specific options. | ||
458 | Two FIDO authenticator options are supported at present: | ||
459 | .Pp | ||
460 | .Cm no-touch-required | ||
461 | indicates that the generated private key should not require touch | ||
462 | events (user presence) when making signatures. | ||
463 | Note that | ||
464 | .Xr sshd 8 | ||
465 | will refuse such signatures by default, unless overridden via | ||
466 | an authorized_keys option. | ||
467 | .Pp | ||
468 | .Cm resident | ||
469 | indicates that the key should be stored on the FIDO authenticator itself. | ||
470 | Resident keys may be supported on FIDO2 tokens and typically require that | ||
471 | a PIN be set on the token prior to generation. | ||
472 | Resident keys may be loaded off the token using | ||
473 | .Xr ssh-add 1 . | ||
474 | .Pp | ||
475 | The | ||
476 | .Fl O | ||
477 | option may be specified multiple times. | ||
457 | .It Fl P Ar passphrase | 478 | .It Fl P Ar passphrase |
458 | Provides the (old) passphrase. | 479 | Provides the (old) passphrase. |
459 | .It Fl p | 480 | .It Fl p |
@@ -573,18 +594,6 @@ The maximum is 3. | |||
573 | Specifies a path to a library that will be used when creating | 594 | Specifies a path to a library that will be used when creating |
574 | FIDO authenticator-hosted keys, overriding the default of using | 595 | FIDO authenticator-hosted keys, overriding the default of using |
575 | the internal USB HID support. | 596 | the internal USB HID support. |
576 | .It Fl x Ar flags | ||
577 | Specifies the authenticator flags to use when enrolling an authenticator-hosted | ||
578 | key. | ||
579 | Flags may be specified by name or directly as a hexadecimal value. | ||
580 | Only one named flag is supported at present: | ||
581 | .Cm no-touch-required , | ||
582 | which indicates that the generated private key should not require touch | ||
583 | events (user presence) when making signatures. | ||
584 | Note that | ||
585 | .Xr sshd 8 | ||
586 | will refuse such signatures by default, unless overridden via | ||
587 | an authorized_keys option. | ||
588 | .It Fl Y Cm check-novalidate | 597 | .It Fl Y Cm check-novalidate |
589 | Checks that a signature generated using | 598 | Checks that a signature generated using |
590 | .Nm | 599 | .Nm |
diff --git a/ssh-keygen.c b/ssh-keygen.c index 696891e0e..3640a3c37 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-keygen.c,v 1.379 2019/12/30 09:24:45 djm Exp $ */ | 1 | /* $OpenBSD: ssh-keygen.c,v 1.380 2019/12/30 09:49:52 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -2932,7 +2932,7 @@ main(int argc, char **argv) | |||
2932 | int prefer_agent = 0, convert_to = 0, convert_from = 0; | 2932 | int prefer_agent = 0, convert_to = 0, convert_from = 0; |
2933 | int print_public = 0, print_generic = 0, cert_serial_autoinc = 0; | 2933 | int print_public = 0, print_generic = 0, cert_serial_autoinc = 0; |
2934 | int do_gen_candidates = 0, do_screen_candidates = 0; | 2934 | int do_gen_candidates = 0, do_screen_candidates = 0; |
2935 | unsigned long long ull, cert_serial = 0; | 2935 | unsigned long long cert_serial = 0; |
2936 | char *identity_comment = NULL, *ca_key_path = NULL, **opts = NULL; | 2936 | char *identity_comment = NULL, *ca_key_path = NULL, **opts = NULL; |
2937 | size_t i, nopts = 0; | 2937 | size_t i, nopts = 0; |
2938 | u_int32_t bits = 0; | 2938 | u_int32_t bits = 0; |
@@ -2965,10 +2965,10 @@ main(int argc, char **argv) | |||
2965 | 2965 | ||
2966 | sk_provider = getenv("SSH_SK_PROVIDER"); | 2966 | sk_provider = getenv("SSH_SK_PROVIDER"); |
2967 | 2967 | ||
2968 | /* Remaining characters: dGjJKSTW */ | 2968 | /* Remaining characters: dGjJKSTWx */ |
2969 | while ((opt = getopt(argc, argv, "ABHLQUXceghiklopquvy" | 2969 | while ((opt = getopt(argc, argv, "ABHLQUXceghiklopquvy" |
2970 | "C:D:E:F:I:M:N:O:P:R:V:Y:Z:" | 2970 | "C:D:E:F:I:M:N:O:P:R:V:Y:Z:" |
2971 | "a:b:f:g:m:n:r:s:t:w:x:z:")) != -1) { | 2971 | "a:b:f:g:m:n:r:s:t:w:z:")) != -1) { |
2972 | switch (opt) { | 2972 | switch (opt) { |
2973 | case 'A': | 2973 | case 'A': |
2974 | gen_all_hostkeys = 1; | 2974 | gen_all_hostkeys = 1; |
@@ -3130,25 +3130,6 @@ main(int argc, char **argv) | |||
3130 | case 'w': | 3130 | case 'w': |
3131 | sk_provider = optarg; | 3131 | sk_provider = optarg; |
3132 | break; | 3132 | break; |
3133 | case 'x': | ||
3134 | if (*optarg == '\0') | ||
3135 | fatal("Missing security key flags"); | ||
3136 | if (strcasecmp(optarg, "no-touch-required") == 0) | ||
3137 | sk_flags &= ~SSH_SK_USER_PRESENCE_REQD; | ||
3138 | else if (strcasecmp(optarg, "resident") == 0) | ||
3139 | sk_flags |= SSH_SK_RESIDENT_KEY; | ||
3140 | else { | ||
3141 | ull = strtoull(optarg, &ep, 0); | ||
3142 | if (*ep != '\0') | ||
3143 | fatal("Security key flags \"%s\" is " | ||
3144 | "not a number", optarg); | ||
3145 | if (ull > 0xff) { | ||
3146 | fatal("Invalid security key " | ||
3147 | "flags 0x%llx", ull); | ||
3148 | } | ||
3149 | sk_flags = (uint8_t)ull; | ||
3150 | } | ||
3151 | break; | ||
3152 | case 'z': | 3133 | case 'z': |
3153 | errno = 0; | 3134 | errno = 0; |
3154 | if (*optarg == '+') { | 3135 | if (*optarg == '+') { |
@@ -3361,6 +3342,20 @@ main(int argc, char **argv) | |||
3361 | switch (type) { | 3342 | switch (type) { |
3362 | case KEY_ECDSA_SK: | 3343 | case KEY_ECDSA_SK: |
3363 | case KEY_ED25519_SK: | 3344 | case KEY_ED25519_SK: |
3345 | for (i = 0; i < nopts; i++) { | ||
3346 | if (strcasecmp(opts[i], "no-touch-required") == 0) { | ||
3347 | sk_flags &= ~SSH_SK_USER_PRESENCE_REQD; | ||
3348 | } else if (strcasecmp(opts[i], "resident") == 0) { | ||
3349 | sk_flags |= SSH_SK_RESIDENT_KEY; | ||
3350 | } else { | ||
3351 | fatal("Option \"%s\" is unsupported for " | ||
3352 | "FIDO authenticator enrollment", opts[i]); | ||
3353 | } | ||
3354 | } | ||
3355 | if (!quiet) { | ||
3356 | printf("You may need to touch your security key " | ||
3357 | "to authorize key generation.\n"); | ||
3358 | } | ||
3364 | passphrase1 = NULL; | 3359 | passphrase1 = NULL; |
3365 | for (i = 0 ; i < 3; i++) { | 3360 | for (i = 0 ; i < 3; i++) { |
3366 | if (!quiet) { | 3361 | if (!quiet) { |
@@ -3375,9 +3370,13 @@ main(int argc, char **argv) | |||
3375 | break; | 3370 | break; |
3376 | if (r != SSH_ERR_KEY_WRONG_PASSPHRASE) | 3371 | if (r != SSH_ERR_KEY_WRONG_PASSPHRASE) |
3377 | exit(1); /* error message already printed */ | 3372 | exit(1); /* error message already printed */ |
3373 | if (passphrase1 != NULL) | ||
3374 | freezero(passphrase1, strlen(passphrase1)); | ||
3378 | passphrase1 = read_passphrase("Enter PIN for security " | 3375 | passphrase1 = read_passphrase("Enter PIN for security " |
3379 | "key: ", RP_ALLOW_STDIN); | 3376 | "key: ", RP_ALLOW_STDIN); |
3380 | } | 3377 | } |
3378 | if (passphrase1 != NULL) | ||
3379 | freezero(passphrase1, strlen(passphrase1)); | ||
3381 | if (i > 3) | 3380 | if (i > 3) |
3382 | fatal("Too many incorrect PINs"); | 3381 | fatal("Too many incorrect PINs"); |
3383 | break; | 3382 | break; |