diff options
Diffstat (limited to 'ssh-ed25519.c')
-rw-r--r-- | ssh-ed25519.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ssh-ed25519.c b/ssh-ed25519.c index 1aedcf83a..160d1f23b 100644 --- a/ssh-ed25519.c +++ b/ssh-ed25519.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-ed25519.c,v 1.1 2013/12/06 13:39:49 markus Exp $ */ | 1 | /* $OpenBSD: ssh-ed25519.c,v 1.3 2014/02/23 20:03:42 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2013 Markus Friedl <markus@openbsd.org> | 3 | * Copyright (c) 2013 Markus Friedl <markus@openbsd.org> |
4 | * | 4 | * |
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include "crypto_api.h" | 22 | #include "crypto_api.h" |
23 | 23 | ||
24 | #include <limits.h> | ||
24 | #include <string.h> | 25 | #include <string.h> |
25 | #include <stdarg.h> | 26 | #include <stdarg.h> |
26 | 27 | ||
@@ -45,6 +46,11 @@ ssh_ed25519_sign(const Key *key, u_char **sigp, u_int *lenp, | |||
45 | error("%s: no ED25519 key", __func__); | 46 | error("%s: no ED25519 key", __func__); |
46 | return -1; | 47 | return -1; |
47 | } | 48 | } |
49 | |||
50 | if (datalen >= UINT_MAX - crypto_sign_ed25519_BYTES) { | ||
51 | error("%s: datalen %u too long", __func__, datalen); | ||
52 | return -1; | ||
53 | } | ||
48 | smlen = slen = datalen + crypto_sign_ed25519_BYTES; | 54 | smlen = slen = datalen + crypto_sign_ed25519_BYTES; |
49 | sig = xmalloc(slen); | 55 | sig = xmalloc(slen); |
50 | 56 | ||
@@ -66,7 +72,7 @@ ssh_ed25519_sign(const Key *key, u_char **sigp, u_int *lenp, | |||
66 | memcpy(*sigp, buffer_ptr(&b), len); | 72 | memcpy(*sigp, buffer_ptr(&b), len); |
67 | } | 73 | } |
68 | buffer_free(&b); | 74 | buffer_free(&b); |
69 | memset(sig, 's', slen); | 75 | explicit_bzero(sig, slen); |
70 | free(sig); | 76 | free(sig); |
71 | 77 | ||
72 | return 0; | 78 | return 0; |
@@ -130,9 +136,9 @@ ssh_ed25519_verify(const Key *key, const u_char *signature, u_int signaturelen, | |||
130 | } | 136 | } |
131 | /* XXX compare 'm' and 'data' ? */ | 137 | /* XXX compare 'm' and 'data' ? */ |
132 | 138 | ||
133 | memset(sigblob, 's', len); | 139 | explicit_bzero(sigblob, len); |
134 | memset(sm, 'S', smlen); | 140 | explicit_bzero(sm, smlen); |
135 | memset(m, 'm', smlen); /* NB. mlen may be invalid if ret != 0 */ | 141 | explicit_bzero(m, smlen); /* NB. mlen may be invalid if ret != 0 */ |
136 | free(sigblob); | 142 | free(sigblob); |
137 | free(sm); | 143 | free(sm); |
138 | free(m); | 144 | free(m); |