diff options
author | 2018-09-12 01:32:54 +0000 | |
---|---|---|
committer | 2018-09-12 01:32:54 +0000 | |
commit | 4668e1f3b8458a5748dae8d224fe246996df23b4 (patch) | |
tree | 4fd59ab2b94591fa1467c8b322442e9ba8cb29bc /usr.bin/ssh/sshkey.c | |
parent | add cert->signature_type field and keep it in sync with certificate (diff) | |
download | wireguard-openbsd-4668e1f3b8458a5748dae8d224fe246996df23b4.tar.xz wireguard-openbsd-4668e1f3b8458a5748dae8d224fe246996df23b4.zip |
add sshkey_check_cert_sigtype() that checks a cert->signature_type
against a supplied whitelist; ok markus
Diffstat (limited to 'usr.bin/ssh/sshkey.c')
-rw-r--r-- | usr.bin/ssh/sshkey.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/usr.bin/ssh/sshkey.c b/usr.bin/ssh/sshkey.c index 9b88f11107d..997d107cec4 100644 --- a/usr.bin/ssh/sshkey.c +++ b/usr.bin/ssh/sshkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshkey.c,v 1.67 2018/09/12 01:31:30 djm Exp $ */ +/* $OpenBSD: sshkey.c,v 1.68 2018/09/12 01:32:54 djm Exp $ */ /* * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. * Copyright (c) 2008 Alexander von Gernler. All rights reserved. @@ -2215,6 +2215,27 @@ get_sigtype(const u_char *sig, size_t siglen, char **sigtypep) } /* + * + * Checks whether a certificate's signature type is allowed. + * Returns 0 (success) if the certificate signature type appears in the + * "allowed" pattern-list, or the key is not a certificate to begin with. + * Otherwise returns a ssherr.h code. + */ +int +sshkey_check_cert_sigtype(const struct sshkey *key, const char *allowed) +{ + if (key == NULL || allowed == NULL) + return SSH_ERR_INVALID_ARGUMENT; + if (!sshkey_type_is_cert(key->type)) + return 0; + if (key->cert == NULL || key->cert->signature_type == NULL) + return SSH_ERR_INVALID_ARGUMENT; + if (match_pattern_list(key->cert->signature_type, allowed, 0) != 1) + return SSH_ERR_SIGN_ALG_UNSUPPORTED; + return 0; +} + +/* * Returns the expected signature algorithm for a given public key algorithm. */ const char * |