~mdw
/
sgt
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bleh, grammar.
[sgt/putty]
/
sshdss.c
diff --git
a/sshdss.c
b/sshdss.c
index
7489467
..
fa3ac38
100644
(file)
--- a/
sshdss.c
+++ b/
sshdss.c
@@
-91,7
+91,7
@@
static void *dss_newkey(char *data, int len)
int slen;
struct dss_key *dss;
int slen;
struct dss_key *dss;
- dss = s
malloc(sizeof(struct dss_key)
);
+ dss = s
new(struct dss_key
);
if (!dss)
return NULL;
getstring(&data, &len, &p, &slen);
if (!dss)
return NULL;
getstring(&data, &len, &p, &slen);
@@
-141,7
+141,7
@@
static char *dss_fmtkey(void *key)
len += 4 * (bignum_bitcount(dss->q) + 15) / 16;
len += 4 * (bignum_bitcount(dss->g) + 15) / 16;
len += 4 * (bignum_bitcount(dss->y) + 15) / 16;
len += 4 * (bignum_bitcount(dss->q) + 15) / 16;
len += 4 * (bignum_bitcount(dss->g) + 15) / 16;
len += 4 * (bignum_bitcount(dss->y) + 15) / 16;
- p = s
malloc(len
);
+ p = s
newn(len, char
);
if (!p)
return NULL;
if (!p)
return NULL;
@@
-209,7
+209,7
@@
static char *dss_fingerprint(void *key)
for (i = 0; i < 16; i++)
sprintf(buffer + strlen(buffer), "%s%02x", i ? ":" : "",
digest[i]);
for (i = 0; i < 16; i++)
sprintf(buffer + strlen(buffer), "%s%02x", i ? ":" : "",
digest[i]);
- ret = s
malloc(strlen(buffer) + 1
);
+ ret = s
newn(strlen(buffer) + 1, char
);
if (ret)
strcpy(ret, buffer);
return ret;
if (ret)
strcpy(ret, buffer);
return ret;
@@
-322,7
+322,7
@@
static unsigned char *dss_public_blob(void *key, int *len)
* 27 + sum of lengths. (five length fields, 20+7=27).
*/
bloblen = 27 + plen + qlen + glen + ylen;
* 27 + sum of lengths. (five length fields, 20+7=27).
*/
bloblen = 27 + plen + qlen + glen + ylen;
- blob = s
malloc(bloblen
);
+ blob = s
newn(bloblen, unsigned char
);
p = blob;
PUT_32BIT(p, 7);
p += 4;
p = blob;
PUT_32BIT(p, 7);
p += 4;
@@
-362,7
+362,7
@@
static unsigned char *dss_private_blob(void *key, int *len)
* mpint x, string[20] the SHA of p||q||g. Total 4 + xlen.
*/
bloblen = 4 + xlen;
* mpint x, string[20] the SHA of p||q||g. Total 4 + xlen.
*/
bloblen = 4 + xlen;
- blob = s
malloc(bloblen
);
+ blob = s
newn(bloblen, unsigned char
);
p = blob;
PUT_32BIT(p, xlen);
p += 4;
p = blob;
PUT_32BIT(p, xlen);
p += 4;
@@
-422,7
+422,7
@@
static void *dss_openssh_createkey(unsigned char **blob, int *len)
char **b = (char **) blob;
struct dss_key *dss;
char **b = (char **) blob;
struct dss_key *dss;
- dss = s
malloc(sizeof(struct dss_key)
);
+ dss = s
new(struct dss_key
);
if (!dss)
return NULL;
if (!dss)
return NULL;
@@
-473,6
+473,18
@@
static int dss_openssh_fmtkey(void *key, unsigned char *blob, int len)
return bloblen;
}
return bloblen;
}
+static int dss_pubkey_bits(void *blob, int len)
+{
+ struct dss_key *dss;
+ int ret;
+
+ dss = dss_newkey((char *) blob, len);
+ ret = bignum_bitcount(dss->p);
+ dss_freekey(dss);
+
+ return ret;
+}
+
static unsigned char *dss_sign(void *key, char *data, int datalen, int *siglen)
{
/*
static unsigned char *dss_sign(void *key, char *data, int datalen, int *siglen)
{
/*
@@
-606,7
+618,7
@@
static unsigned char *dss_sign(void *key, char *data, int datalen, int *siglen)
* i.e. 4+7 + 4+40 bytes.
*/
nbytes = 4 + 7 + 4 + 40;
* i.e. 4+7 + 4+40 bytes.
*/
nbytes = 4 + 7 + 4 + 40;
- bytes = s
malloc(nbytes
);
+ bytes = s
newn(nbytes, unsigned char
);
PUT_32BIT(bytes, 7);
memcpy(bytes + 4, "ssh-dss", 7);
PUT_32BIT(bytes + 4 + 7, 40);
PUT_32BIT(bytes, 7);
memcpy(bytes + 4, "ssh-dss", 7);
PUT_32BIT(bytes + 4 + 7, 40);
@@
-630,6
+642,7
@@
const struct ssh_signkey ssh_dss = {
dss_createkey,
dss_openssh_createkey,
dss_openssh_fmtkey,
dss_createkey,
dss_openssh_createkey,
dss_openssh_fmtkey,
+ dss_pubkey_bits,
dss_fingerprint,
dss_verifysig,
dss_sign,
dss_fingerprint,
dss_verifysig,
dss_sign,