summaryrefslogtreecommitdiffstats
path: root/sshkey.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2017-12-18 03:22:29 +0100
committerDamien Miller <djm@mindrot.org>2017-12-19 05:20:44 +0100
commit931c78dfd7fe30669681a59e536bbe66535f3ee9 (patch)
tree9c3aa653449bf532eb0f48d416d5906db2c4f977 /sshkey.c
parentupstream commit (diff)
downloadopenssh-931c78dfd7fe30669681a59e536bbe66535f3ee9.tar.xz
openssh-931c78dfd7fe30669681a59e536bbe66535f3ee9.zip
upstream commit
sshkey_sigtype() function to return the type of a signature; ok markus@ OpenBSD-Commit-ID: d3772b065ad6eed97285589bfb544befed9032e8
Diffstat (limited to 'sshkey.c')
-rw-r--r--sshkey.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/sshkey.c b/sshkey.c
index 1e390420d..19f26a117 100644
--- a/sshkey.c
+++ b/sshkey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshkey.c,v 1.57 2017/10/13 06:24:51 djm Exp $ */
+/* $OpenBSD: sshkey.c,v 1.58 2017/12/18 02:22:29 djm Exp $ */
/*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
* Copyright (c) 2008 Alexander von Gernler. All rights reserved.
@@ -2050,6 +2050,31 @@ sshkey_froms(struct sshbuf *buf, struct sshkey **keyp)
}
int
+sshkey_sigtype(const u_char *sig, size_t siglen, char **sigtypep)
+{
+ int r;
+ struct sshbuf *b = NULL;
+ char *sigtype = NULL;
+
+ if (sigtypep != NULL)
+ *sigtypep = NULL;
+ if ((b = sshbuf_from(sig, siglen)) == NULL)
+ return SSH_ERR_ALLOC_FAIL;
+ if ((r = sshbuf_get_cstring(b, &sigtype, NULL)) != 0)
+ goto out;
+ /* success */
+ if (sigtypep != NULL) {
+ *sigtypep = sigtype;
+ sigtype = NULL;
+ }
+ r = 0;
+ out:
+ free(sigtype);
+ sshbuf_free(b);
+ return r;
+}
+
+int
sshkey_sign(const struct sshkey *key,
u_char **sigp, size_t *lenp,
const u_char *data, size_t datalen, const char *alg, u_int compat)