summaryrefslogtreecommitdiff
path: root/ssh-rsa.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2002-07-07 22:13:31 +0000
committerBen Lindstrom <mouring@eviladmin.org>2002-07-07 22:13:31 +0000
commit2bf759cba5f24c09e450bb8fcabfd9e6e32c137d (patch)
tree5eb3a30c6207558c8f8502afac3086cde4517cb6 /ssh-rsa.c
parent8b2eecdf9f6769520e2601d5de58991d5810873d (diff)
- markus@cvs.openbsd.org 2002/07/04 10:41:47
[key.c monitor_wrap.c ssh-dss.c ssh-rsa.c] don't allocate, copy, and discard if there is not interested in the data; ok deraadt@
Diffstat (limited to 'ssh-rsa.c')
-rw-r--r--ssh-rsa.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/ssh-rsa.c b/ssh-rsa.c
index c7f5ed0b..d6729b04 100644
--- a/ssh-rsa.c
+++ b/ssh-rsa.c
@@ -23,7 +23,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-rsa.c,v 1.22 2002/07/04 04:15:33 deraadt Exp $");
+RCSID("$OpenBSD: ssh-rsa.c,v 1.23 2002/07/04 10:41:47 markus Exp $");
#include <openssl/evp.h>
#include <openssl/err.h>
@@ -44,7 +44,7 @@ ssh_rsa_sign(Key *key, u_char **sigp, u_int *lenp,
{
const EVP_MD *evp_md;
EVP_MD_CTX md;
- u_char digest[EVP_MAX_MD_SIZE], *sig, *ret;
+ u_char digest[EVP_MAX_MD_SIZE], *sig;
u_int slen, dlen, len;
int ok, nid;
Buffer b;
@@ -90,18 +90,16 @@ ssh_rsa_sign(Key *key, u_char **sigp, u_int *lenp,
buffer_put_cstring(&b, "ssh-rsa");
buffer_put_string(&b, sig, slen);
len = buffer_len(&b);
- ret = xmalloc(len);
- memcpy(ret, buffer_ptr(&b), len);
+ if (lenp != NULL)
+ *lenp = len;
+ if (sigp != NULL) {
+ *sigp = xmalloc(len);
+ memcpy(*sigp, buffer_ptr(&b), len);
+ }
buffer_free(&b);
memset(sig, 's', slen);
xfree(sig);
- if (lenp != NULL)
- *lenp = len;
- if (sigp != NULL)
- *sigp = ret;
- else
- xfree(ret);
return 0;
}