summaryrefslogtreecommitdiff
path: root/ssh-dss.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-dss.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-dss.c')
-rw-r--r--ssh-dss.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/ssh-dss.c b/ssh-dss.c
index 0215f1c9a..9ba2584dd 100644
--- a/ssh-dss.c
+++ b/ssh-dss.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: ssh-dss.c,v 1.16 2002/07/04 04:15:33 deraadt Exp $"); 26RCSID("$OpenBSD: ssh-dss.c,v 1.17 2002/07/04 10:41:47 markus Exp $");
27 27
28#include <openssl/bn.h> 28#include <openssl/bn.h>
29#include <openssl/evp.h> 29#include <openssl/evp.h>
@@ -46,7 +46,7 @@ ssh_dss_sign(Key *key, u_char **sigp, u_int *lenp,
46 DSA_SIG *sig; 46 DSA_SIG *sig;
47 const EVP_MD *evp_md = EVP_sha1(); 47 const EVP_MD *evp_md = EVP_sha1();
48 EVP_MD_CTX md; 48 EVP_MD_CTX md;
49 u_char *ret, digest[EVP_MAX_MD_SIZE], sigblob[SIGBLOB_LEN]; 49 u_char digest[EVP_MAX_MD_SIZE], sigblob[SIGBLOB_LEN];
50 u_int rlen, slen, len, dlen; 50 u_int rlen, slen, len, dlen;
51 Buffer b; 51 Buffer b;
52 52
@@ -79,29 +79,25 @@ ssh_dss_sign(Key *key, u_char **sigp, u_int *lenp,
79 DSA_SIG_free(sig); 79 DSA_SIG_free(sig);
80 80
81 if (datafellows & SSH_BUG_SIGBLOB) { 81 if (datafellows & SSH_BUG_SIGBLOB) {
82 ret = xmalloc(SIGBLOB_LEN);
83 memcpy(ret, sigblob, SIGBLOB_LEN);
84 if (lenp != NULL) 82 if (lenp != NULL)
85 *lenp = SIGBLOB_LEN; 83 *lenp = SIGBLOB_LEN;
86 if (sigp != NULL) 84 if (sigp != NULL) {
87 *sigp = ret; 85 *sigp = xmalloc(SIGBLOB_LEN);
88 else 86 memcpy(*sigp, sigblob, SIGBLOB_LEN);
89 xfree(ret); 87 }
90 } else { 88 } else {
91 /* ietf-drafts */ 89 /* ietf-drafts */
92 buffer_init(&b); 90 buffer_init(&b);
93 buffer_put_cstring(&b, "ssh-dss"); 91 buffer_put_cstring(&b, "ssh-dss");
94 buffer_put_string(&b, sigblob, SIGBLOB_LEN); 92 buffer_put_string(&b, sigblob, SIGBLOB_LEN);
95 len = buffer_len(&b); 93 len = buffer_len(&b);
96 ret = xmalloc(len);
97 memcpy(ret, buffer_ptr(&b), len);
98 buffer_free(&b);
99 if (lenp != NULL) 94 if (lenp != NULL)
100 *lenp = len; 95 *lenp = len;
101 if (sigp != NULL) 96 if (sigp != NULL) {
102 *sigp = ret; 97 *sigp = xmalloc(len);
103 else 98 memcpy(*sigp, buffer_ptr(&b), len);
104 xfree(ret); 99 }
100 buffer_free(&b);
105 } 101 }
106 return 0; 102 return 0;
107} 103}