1 |
diff -up ldns-1.6.16/keys.c.dsa ldns-1.6.16/keys.c |
2 |
--- ldns-1.6.16/keys.c.dsa 2012-08-31 14:03:18.000000000 +0200 |
3 |
+++ ldns-1.6.16/keys.c 2014-03-18 17:48:57.474128661 +0100 |
4 |
@@ -1314,7 +1314,6 @@ ldns_key_dsa2bin(unsigned char *data, DS |
5 |
/* See RFC2536 */ |
6 |
*size = (uint16_t)BN_num_bytes(k->p); |
7 |
T = (*size - 64) / 8; |
8 |
- memcpy(data, &T, 1); |
9 |
|
10 |
if (T > 8) { |
11 |
fprintf(stderr, "DSA key with T > 8 (ie. > 1024 bits)"); |
12 |
@@ -1323,12 +1322,13 @@ ldns_key_dsa2bin(unsigned char *data, DS |
13 |
} |
14 |
|
15 |
/* size = 64 + (T * 8); */ |
16 |
+ memset(data, 0, 21 + *size * 3); |
17 |
data[0] = (unsigned char)T; |
18 |
BN_bn2bin(k->q, data + 1 ); /* 20 octects */ |
19 |
BN_bn2bin(k->p, data + 21 ); /* offset octects */ |
20 |
- BN_bn2bin(k->g, data + 21 + *size); /* offset octets */ |
21 |
- BN_bn2bin(k->pub_key, data + 21 + *size + *size); /* offset octets */ |
22 |
- *size = 21 + (*size * 3); |
23 |
+ BN_bn2bin(k->g, data + 21 + *size * 2 - BN_num_bytes(k->g)); |
24 |
+ BN_bn2bin(k->pub_key,data + 21 + *size * 3 - BN_num_bytes(k->pub_key)); |
25 |
+ *size = 21 + *size * 3; |
26 |
return true; |
27 |
} |
28 |
|