Commit Graph

152 Commits

Author SHA1 Message Date
djm@openbsd.org 25c8a2bbcc
upstream: put sshkey_check_rsa_length() back in sshkey.c to unbreak
OPENSSL=no builds

OpenBSD-Commit-ID: 99eec58abe382ecd14b14043b195ee1babb9cf6e
2022-10-28 13:49:01 +11:00
Damien Miller 64af420930
fix merge botch 2022-10-28 12:54:35 +11:00
djm@openbsd.org 2726764269
upstream: refactor sshkey_private_deserialize
feedback/ok markus@

OpenBSD-Commit-ID: f5ca6932fdaf840a5e8250becb38315a29b5fc9f
2022-10-28 12:47:01 +11:00
djm@openbsd.org 2519a7077a
upstream: refactor sshkey_private_serialize_opt()
feedback/ok markus@

OpenBSD-Commit-ID: 61e0fe989897901294efe7c3b6d670cefaf44cbd
2022-10-28 12:47:01 +11:00
djm@openbsd.org 11a768adf9
upstream: refactor certify
feedback/ok markus@

OpenBSD-Commit-ID: 35d742992e223eaca3537e6fb3d3002c08eed4f6
2022-10-28 12:47:00 +11:00
djm@openbsd.org 3fbc58bb24
upstream: refactor sshkey_sign() and sshkey_verify()
feedback/ok markus@

OpenBSD-Commit-ID: 368e662c128c99d05cc043b1308d2b6c71a4d3cc
2022-10-28 12:47:00 +11:00
djm@openbsd.org a1deb6cdbb
upstream: refactor sshkey_from_blob_internal()
feedback/ok markus@

OpenBSD-Commit-ID: 1f46c0cbb8060ee9666a02749594ad6658c8e283
2022-10-28 12:46:59 +11:00
djm@openbsd.org 7d00799c93
upstream: refactor sshkey_from_private()
feedback/ok markus@

OpenBSD-Commit-ID: e5dbe7a3545930c50f70ee75c867a1e08b382b53
2022-10-28 12:46:59 +11:00
djm@openbsd.org 262647c2e9
upstream: factor out key generation
feedback/ok markus@

OpenBSD-Commit-ID: 5b4211bff4de8d9adb84bc72857a8c42c44e7ceb
2022-10-28 12:46:58 +11:00
djm@openbsd.org 401c74e7dc
upstream: refactor and simplify sshkey_read()
feedback/ok markus@

OpenBSD-Commit-ID: 0d93b7a56e31cd06a8bb0d2191d084ce254b0971
2022-10-28 12:46:57 +11:00
djm@openbsd.org 591fed94e6
upstream: factor out public key serialization
feedback/ok markus@

OpenBSD-Commit-ID: a3570c4b97290c5662890aea7328d87f55939033
2022-10-28 12:46:57 +11:00
djm@openbsd.org 1e78844ae2
upstream: factor out sshkey_equal_public()
feedback/ok markus@

OpenBSD-Commit-ID: 1368ba114cb37732fe6ec3d89c7e6d27ea6fdc94
2022-10-28 12:46:56 +11:00
djm@openbsd.org 25de1c01a8
upstream: begin big refactor of sshkey
Move keytype data and some of the type-specific code (allocation,
cleanup, etc) out into each key type's implementation. Subsequent
commits will move more, with the goal of having each key-*.c file
owning as much of its keytype's implementation as possible.

lots of feedback + ok markus@

OpenBSD-Commit-ID: 0f2b4334f73914344e9e5b3d33522d41762a57ec
2022-10-28 12:46:56 +11:00
djm@openbsd.org 07d8771bac
upstream: Add a sshkey_check_rsa_length() call for checking the
length of an RSA key; ok markus@

OpenBSD-Commit-ID: de77cd5b11594297eda82edc594b0d32b8535134
2022-09-17 20:38:40 +10:00
djm@openbsd.org 457dce2cfe upstream: sshkey_unshield_private() contains a exact duplicate of
the code in private2_check_padding(). Pull private2_check_padding() up so the
code can be reused. From Martin Vahlensieck, ok deraadt@

OpenBSD-Commit-ID: 876884c3f0e62e8fd8d1594bab06900f971c9c85
2022-05-05 11:34:52 +10:00
djm@openbsd.org fdb1d58d0d upstream: add a helper function to match a key type to a list of
signature algorithms. RSA keys can make signatures with multiple algorithms,
so some special handling is required. ok markus@

OpenBSD-Commit-ID: 03b41b2bda06fa4cd9c84cef6095033b9e49b6ff
2022-01-07 09:21:38 +11:00
Darren Tucker ef5916b8ac Only enable sk-* key types if ENABLE_SK is defined 2021-10-07 14:28:02 +11:00
djm@openbsd.org d0bb1ce731 upstream: Let allowed signers files used by ssh-keygen(1)
signatures support key lifetimes, and allow the verification mode to specify
a signature time to check at. This is intended for use by git to support
signing objects using ssh keys. ok dtucker@

OpenBSD-Commit-ID: 3e2c67b7dcd94f0610194d1e8e4907829a40cf31
2021-07-23 14:07:19 +10:00
dtucker@openbsd.org 6c29b387cd upstream: Use existing format_absolute_time() function when
printing cert validity instead of doing it inline.  Part of bz#3329.

OpenBSD-Commit-ID: a13d4e3c4f59644c23745eb02a09b2a4e717c00c
2021-07-12 17:38:47 +10:00
dtucker@openbsd.org b5d23150b4 upstream: Fix a couple of whitespace things. Portable already has
these so this removes two diffs between the two.

OpenBSD-Commit-ID: 769f017ebafd8e741e337b3e9e89eb5ac73c9c56
2021-07-08 14:57:17 +10:00
Damien Miller 57ed647ee0 polish whitespace for portable files 2021-04-03 17:47:37 +11:00
djm@openbsd.org 31d8d231eb upstream: highly polished whitespace, mostly fixing spaces-for-tab
and bad indentation on continuation lines. Prompted by GHPR#185

OpenBSD-Commit-ID: e5c81f0cbdcc6144df1ce468ec1bac366d8ad6e9
2021-04-03 17:23:02 +11:00
djm@openbsd.org f71219a01d upstream: fix memleaks in private key deserialisation; enforce more
consistency between redundant fields in private key certificate and private
key body; ok markus@

OpenBSD-Commit-ID: dec344e414d47f0a7adc13aecf3760fe58101240
2021-02-05 13:38:57 +11:00
djm@openbsd.org 3b44f2513c upstream: move check_host_cert() from sshconnect,c to sshkey.c and
refactor it to make it more generally usable and testable.

ok markus@

OpenBSD-Commit-ID: 536f489f5ff38808c1fa711ba58d4579b636f9e4
2021-01-26 12:21:48 +11:00
dtucker@openbsd.org 9bde1a4206 upstream: Make output buffer larger to prevent potential truncation
warnings from compilers not smart enough to know the strftime calls won't
ever fully fill "to" and "from".  ok djm@

OpenBSD-Commit-ID: 83733f1b01b82da88b9dd1769475952aff10bdd7
2021-01-18 18:43:43 +11:00
dtucker@openbsd.org eab2888cfc upstream: Adapt XMSS to new logging infrastructure. With markus@, ok
djm@.

OpenBSD-Commit-ID: 9c35ec3aa0f710e4e3325187ceff4fa3791686de
2020-10-20 10:15:02 +11:00
djm@openbsd.org 9b8ad93824 upstream: support for user-verified FIDO keys
FIDO2 supports a notion of "user verification" where the user is
required to demonstrate their identity to the token before particular
operations (e.g. signing). Typically this is done by authenticating
themselves using a PIN that has been set on the token.

This adds support for generating and using user verified keys where
the verification happens via PIN (other options might be added in the
future, but none are in common use now). Practically, this adds
another key generation option "verify-required" that yields a key that
requires a PIN before each authentication.

feedback markus@ and Pedro Martelletto; ok markus@

OpenBSD-Commit-ID: 57fd461e4366f87c47502c5614ec08573e6d6a15
2020-08-27 11:28:36 +10:00
markus@openbsd.org e3fa6249e6 upstream: only call sshkey_xmss_init() once for KEY_XMSS_CERT; ok
djm

OpenBSD-Commit-ID: d0002ffb7f20f538b014d1d0735facd5a81ff096
2020-06-26 15:18:07 +10:00
djm@openbsd.org bb52e70fa5 upstream: Add support for FIDO webauthn (verification only).
webauthn is a standard for using FIDO keys in web browsers. webauthn
signatures are a slightly different format to plain FIDO signatures - this
support allows verification of these. Feedback and ok markus@

OpenBSD-Commit-ID: ab7e3a9fb5782d99d574f408614d833379e564ad
2020-06-22 16:27:27 +10:00
djm@openbsd.org 3779b50ee9 upstream: Refactor private key parsing. Eliminates a fair bit of
duplicated code and fixes oss-fuzz#20074 (NULL deref) caused by a missing key
type check in the ECDSA_CERT parsing path.

feedback and ok markus@

OpenBSD-Commit-ID: 4711981d88afb7196d228f7baad9be1d3b20f9c9
2020-04-11 20:20:58 +10:00
djm@openbsd.org f290ab0833 upstream: add sshkey_parse_pubkey_from_private_fileblob_type()
Extracts a public key from the unencrypted envelope of a new-style
OpenSSH private key.

ok markus@

OpenBSD-Commit-ID: 44d7ab446e5e8c686aee96d5897b26b3939939aa
2020-04-08 10:14:21 +10:00
djm@openbsd.org 8d514eea4a upstream: simplify sshkey_parse_private_fileblob_type()
Try new format parser for all key types first, fall back to PEM
parser only for invalid format errors.

ok markus@

OpenBSD-Commit-ID: 0173bbb3a5cface77b0679d4dca0e15eb5600b77
2020-04-08 10:14:21 +10:00
djm@openbsd.org 421169d0e7 upstream: check private key type against requested key type in
new-style private decoding; ok markus@

OpenBSD-Commit-ID: 04d44b3a34ce12ce5187fb6f6e441a88c8c51662
2020-04-08 10:14:21 +10:00
djm@openbsd.org 6aabfb6d22 upstream: check that pubkey in private key envelope matches actual
private key

(this public key is currently unusued)

ok markus@

OpenBSD-Commit-ID: 634a60b5e135d75f48249ccdf042f3555112049c
2020-04-08 10:14:21 +10:00
djm@openbsd.org c0f5b22947 upstream: refactor private key parsing a little
Split out the base64 decoding and private section decryption steps in
to separate functions. This will make the decryption step easier to fuzz
as well as making it easier to write a "load public key from new-format
private key" function.

ok markus@

OpenBSD-Commit-ID: 7de31d80fb9062aa01901ddf040c286b64ff904e
2020-04-08 10:14:21 +10:00
markus@openbsd.org 7b4f70ddeb upstream: sshkey_cert_check_authority requires reason to be set;
ok djm

OpenBSD-Commit-ID: 6f7a6f19540ed5749763c2f9530c0897c94aa552
2020-03-13 13:18:09 +11:00
markus@openbsd.org 05efe270df upstream: passphrase depends on kdfname, not ciphername (possible
null-deref); ok djm

OpenBSD-Commit-ID: 0d39668edf5e790b5837df4926ee1141cec5471c
2020-03-13 13:18:09 +11:00
jsg@openbsd.org d5ba1c0327 upstream: change explicit_bzero();free() to freezero()
While freezero() returns early if the pointer is NULL the tests for
NULL in callers are left to avoid warnings about passing an
uninitialised size argument across a function boundry.

ok deraadt@ djm@

OpenBSD-Commit-ID: 2660fa334fcc7cd05ec74dd99cb036f9ade6384a
2020-02-28 12:26:28 +11:00
djm@openbsd.org 4a05d789b8 upstream: fix ssh-keygen not displaying authenticator touch
prompt; reported by jmc@

OpenBSD-Commit-ID: 04d4f582fc194eb3897ebcbfe286c49958ba2859
2020-01-21 18:09:09 +11:00
djm@openbsd.org c54cd1892c upstream: SK API and sk-helper error/PIN passing
Allow passing a PIN via the SK API (API major crank) and let the
ssh-sk-helper API follow.

Also enhance the ssh-sk-helper API to support passing back an error
code instead of a complete reply. Will be used to signal "wrong PIN",
etc.

feedback and ok markus@

OpenBSD-Commit-ID: a1bd6b0a2421646919a0c139b8183ad76d28fb71
2019-12-30 20:59:33 +11:00
Damien Miller 9244990ecd remove a bunch of ENABLE_SK #ifdefs
The ssh-sk-helper client API gives us a nice place to disable
security key support when it is wasn't enabled at compile time,
so we don't need to check everywere.

Also, verification of security key signatures can remain enabled
all the time - it has no additional dependencies. So sshd can
accept security key pubkeys in authorized_keys, etc regardless of
the host's support for dlopen, etc.
2019-12-14 09:21:46 +11:00
djm@openbsd.org b52ec0ba39 upstream: use ssh-sk-helper for all security key signing operations
This extracts and refactors the client interface for ssh-sk-helper
from ssh-agent and generalises it for use by the other programs.
This means that most OpenSSH tools no longer need to link against
libfido2 or directly interact with /dev/uhid*

requested by, feedback and ok markus@

OpenBSD-Commit-ID: 1abcd3aea9a7460eccfbf8ca154cdfa62f1dc93f
2019-12-14 07:17:44 +11:00
djm@openbsd.org b7e74ea072 upstream: Add new structure for signature options
This is populated during signature verification with additional fields
that are present in and covered by the signature. At the moment, it is
only used to record security key-specific options, especially the flags
field.

with and ok markus@

OpenBSD-Commit-ID: 338a1f0e04904008836130bedb9ece4faafd4e49
2019-11-25 12:23:33 +11:00
djm@openbsd.org 4bfc0503ad upstream: fix a bug that prevented serialisation of ed25519-sk keys
OpenBSD-Commit-ID: 066682b79333159cac04fcbe03ebd9c8dcc152a9
2019-11-18 17:59:43 +11:00
djm@openbsd.org 740c4bc987 upstream: fix bug that prevented certification of ed25519-sk keys
OpenBSD-Commit-ID: 64c8cc6f5de2cdd0ee3a81c3a9dee8d862645996
2019-11-18 17:42:11 +11:00
Darren Tucker 857f49e91e Move ifdef OPENSSL_HAS_ECC.
Found by -Wimplicit-fallthrough: one ECC case was not inside the ifdef.
ok djm@
2019-11-18 14:15:26 +11:00
djm@openbsd.org fd1a96490c upstream: remove most uses of BN_CTX
We weren't following the rules re BN_CTX_start/BN_CTX_end and the places
we were using it didn't benefit from its use anyway. ok dtucker@

OpenBSD-Commit-ID: ea9ba6c0d2e6f6adfe00b309a8f41842fe12fc7a
2019-11-17 09:44:43 +11:00
markus@openbsd.org 4f5e331cb8 upstream: in order to be able to figure out the number of
signatures left on a shielded key, we need to transfer the number of
signatures left from the private to the public key. ok djm@

OpenBSD-Commit-ID: 8a5d0d260aeace47d372695fdae383ce9b962574
2019-11-15 08:50:10 +11:00
markus@openbsd.org bf219920b7 upstream: fix shield/unshield for xmss keys: - in ssh-agent we need
to delay the call to shield   until we have received key specific options. -
when serializing xmss keys for shield we need to deal with   all optional
components (e.g. state might not be loaded). ok djm@

OpenBSD-Commit-ID: cc2db82524b209468eb176d6b4d6b9486422f41f
2019-11-15 08:50:10 +11:00
Darren Tucker 1e0b248d47 Put sshsk_sign call inside ifdef ENABLE_SK.
Fixes build against OpenSSL configured without ECC.
2019-11-14 16:08:17 +11:00