summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sshkey.c27
-rw-r--r--sshkey.h3
2 files changed, 28 insertions, 2 deletions
diff --git a/sshkey.c b/sshkey.c
index 1e390420d..19f26a117 100644
--- a/sshkey.c
+++ b/sshkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshkey.c,v 1.57 2017/10/13 06:24:51 djm Exp $ */ 1/* $OpenBSD: sshkey.c,v 1.58 2017/12/18 02:22:29 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2008 Alexander von Gernler. All rights reserved. 4 * Copyright (c) 2008 Alexander von Gernler. All rights reserved.
@@ -2050,6 +2050,31 @@ sshkey_froms(struct sshbuf *buf, struct sshkey **keyp)
2050} 2050}
2051 2051
2052int 2052int
2053sshkey_sigtype(const u_char *sig, size_t siglen, char **sigtypep)
2054{
2055 int r;
2056 struct sshbuf *b = NULL;
2057 char *sigtype = NULL;
2058
2059 if (sigtypep != NULL)
2060 *sigtypep = NULL;
2061 if ((b = sshbuf_from(sig, siglen)) == NULL)
2062 return SSH_ERR_ALLOC_FAIL;
2063 if ((r = sshbuf_get_cstring(b, &sigtype, NULL)) != 0)
2064 goto out;
2065 /* success */
2066 if (sigtypep != NULL) {
2067 *sigtypep = sigtype;
2068 sigtype = NULL;
2069 }
2070 r = 0;
2071 out:
2072 free(sigtype);
2073 sshbuf_free(b);
2074 return r;
2075}
2076
2077int
2053sshkey_sign(const struct sshkey *key, 2078sshkey_sign(const struct sshkey *key,
2054 u_char **sigp, size_t *lenp, 2079 u_char **sigp, size_t *lenp,
2055 const u_char *data, size_t datalen, const char *alg, u_int compat) 2080 const u_char *data, size_t datalen, const char *alg, u_int compat)
diff --git a/sshkey.h b/sshkey.h
index 9093eac51..b5346a92d 100644
--- a/sshkey.h
+++ b/sshkey.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshkey.h,v 1.21 2017/07/01 13:50:45 djm Exp $ */ 1/* $OpenBSD: sshkey.h,v 1.22 2017/12/18 02:22:29 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -174,6 +174,7 @@ int sshkey_puts(const struct sshkey *, struct sshbuf *);
174int sshkey_plain_to_blob(const struct sshkey *, u_char **, size_t *); 174int sshkey_plain_to_blob(const struct sshkey *, u_char **, size_t *);
175int sshkey_putb_plain(const struct sshkey *, struct sshbuf *); 175int sshkey_putb_plain(const struct sshkey *, struct sshbuf *);
176 176
177int sshkey_sigtype(const u_char *, size_t, char **);
177int sshkey_sign(const struct sshkey *, u_char **, size_t *, 178int sshkey_sign(const struct sshkey *, u_char **, size_t *,
178 const u_char *, size_t, const char *, u_int); 179 const u_char *, size_t, const char *, u_int);
179int sshkey_verify(const struct sshkey *, const u_char *, size_t, 180int sshkey_verify(const struct sshkey *, const u_char *, size_t,