#ifndef LINT
-static const char rcsid[] = "$Header: /u0/home/explorer/proj/ISC/git-conversion/cvsroot/bind9/lib/bind/dst/Attic/dst_api.c,v 1.4.2.2 2001/11/02 21:38:18 gson Exp $";
+static const char rcsid[] = "$Header: /u0/home/explorer/proj/ISC/git-conversion/cvsroot/bind9/lib/bind/dst/Attic/dst_api.c,v 1.4.2.3 2001/11/02 22:25:28 gson Exp $";
#endif
/*
if (in_name == NULL)
return (NULL);
+ key_st->dk_id = dst_s_dns_key_id(rdata, len);
key_st->dk_flags = dst_s_get_int16(rdata);
key_st->dk_proto = (u_int16_t) rdata[DST_KEY_PROT];
if (key_st->dk_flags & DST_EXTEND_FLAG) {
{
DST_KEY *dkey = NULL;
+ int dnslen;
+ u_char dns[2048];
if (!dst_check_algorithm(alg)) { /* make sure alg is available */
EREPORT(("dst_buffer_to_key(): Algorithm %d not suppored\n", alg));
if (dkey == NULL)
return (NULL);
- if (dkey->dk_func != NULL && dkey->dk_func->from_dns_key != NULL) {
- if (dkey->dk_func->from_dns_key(dkey, key_buf, key_len) < 0) {
- EREPORT(("dst_buffer_to_key(): dst_buffer_to_hmac failed\n"));
- return (dst_free_key(dkey));
- }
- return (dkey);
+ if (dkey->dk_func == NULL || dkey->dk_func->from_dns_key == NULL)
+ return NULL;
+
+ if (dkey->dk_func->from_dns_key(dkey, key_buf, key_len) < 0) {
+ EREPORT(("dst_buffer_to_key(): dst_buffer_to_hmac failed\n"));
+ return (dst_free_key(dkey));
}
- return (NULL);
+
+ dnslen = dst_key_to_dnskey(dkey, dns, sizeof(dns));
+ dkey->dk_id = dst_s_dns_key_id(dns, dnslen);
+ return (dkey);
}
int
int in_alg)
{
int cnt, alg, len, major, minor, file_major, file_minor;
- int id;
+ int ret, id;
char filename[PATH_MAX];
u_char in_buff[RAW_KEY_SIZE], *p;
FILE *fp;
+ int dnslen;
+ u_char dns[2048];
if (name == NULL || pk_key == NULL) {
EREPORT(("dst_read_private_key_file(): No key name given\n"));
if (pk_key->dk_func == NULL || pk_key->dk_func->from_file_fmt == NULL)
goto fail;
- id = pk_key->dk_func->from_file_fmt(pk_key, (char *)p, &in_buff[len] - p);
- if (id < 0)
+ ret = pk_key->dk_func->from_file_fmt(pk_key, (char *)p, &in_buff[len] - p);
+ if (ret < 0)
goto fail;
+ dnslen = dst_key_to_dnskey(pk_key, dns, sizeof(dns));
+ id = dst_s_dns_key_id(dns, dnslen);
+
/* Make sure the actual key tag matches the input tag used in the filename
*/
if (id != in_id) {
{
DST_KEY *new_key = NULL;
int res;
+ int dnslen;
+ u_char dns[2048];
+
if (name == NULL)
return (NULL);
new_key->dk_key_size, exp));
return (dst_free_key(new_key));
}
+
+ dnslen = dst_key_to_dnskey(new_key, dns, sizeof(dns));
+ if (dnslen != UNSUPPORTED_KEYALG)
+ new_key->dk_id = dst_s_dns_key_id(dns, dnslen);
+ else
+ new_key->dk_id = 0;
+
return (new_key);
}
-static const char rcsid[] = "$Header: /u0/home/explorer/proj/ISC/git-conversion/cvsroot/bind9/lib/bind/dst/Attic/support.c,v 1.2 2001/04/03 00:48:09 bwelling Exp $";
+static const char rcsid[] = "$Header: /u0/home/explorer/proj/ISC/git-conversion/cvsroot/bind9/lib/bind/dst/Attic/support.c,v 1.2.2.1 2001/11/02 22:25:29 gson Exp $";
/*
/*
- * calculates a checksum used in kmt for a id.
+ * calculates a checksum used in dst for an id.
* takes an array of bytes and a length.
* returns a 16 bit checksum.
*/
}
/*
- * dst_s_dns_key_id() Function to calculated DNSSEC footprint from KEY reocrd
- * rdata (all of record)
+ * dst_s_dns_key_id() Function to calculate DNSSEC footprint from KEY record
+ * rdata
* Input:
* dns_key_rdata: the raw data in wire format
* rdata_len: the size of the input data
* Output:
- * the key footprint/id calcuated from the key data
+ * the key footprint/id calculated from the key data
*/
u_int16_t
dst_s_dns_key_id(const u_char *dns_key_rdata, const int rdata_len)
{
- int key_data = 4;
-
- if (!dns_key_rdata || (rdata_len < key_data))
+ if (!dns_key_rdata)
return 0;
- /* check the extended parameters bit in the DNS Key RR flags */
- if (dst_s_get_int16(dns_key_rdata) & DST_EXTEND_FLAG)
- key_data += 2;
-
/* compute id */
if (dns_key_rdata[3] == KEY_RSA) /* Algorithm RSA */
return dst_s_get_int16((const u_char *)
&dns_key_rdata[rdata_len - 3]);
+ else if (dns_key_rdata[3] == KEY_HMAC_MD5)
+ /* compatibility */
+ return 0;
else
/* compute a checksum on the key part of the key rr */
- return dst_s_id_calc(&dns_key_rdata[key_data],
- (rdata_len - key_data));
+ return dst_s_id_calc(dns_key_rdata, rdata_len);
}
/*