summaryrefslogtreecommitdiff
path: root/ssh-rsa.c
diff options
context:
space:
mode:
authormouring <mouring>2002-07-07 22:13:31 +0000
committermouring <mouring>2002-07-07 22:13:31 +0000
commit98827b7d34ee5a056ba0d45a9a3ae91b1f3af87f (patch)
tree2cbe32379c4136082dca4588a7563f139c59a553 /ssh-rsa.c
parente95d0e1619544139590f693b2afcecedcd621379 (diff)
downloadopenssh-98827b7d34ee5a056ba0d45a9a3ae91b1f3af87f.tar.gz
- 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;
}