summaryrefslogtreecommitdiffstats
path: root/contrib/bind/lib/dst/dst_api.c
diff options
context:
space:
mode:
authorasmodai <asmodai@FreeBSD.org>2001-07-30 16:51:36 +0000
committerasmodai <asmodai@FreeBSD.org>2001-07-30 16:51:36 +0000
commit4764c8658fdd2787fdd421279037fe93eb05ac7c (patch)
tree575f66c4e2766172b1fb832ef43000016e089b3c /contrib/bind/lib/dst/dst_api.c
parentc56e32d41edb68ef6a2360025bff9df4a544e5fa (diff)
downloadFreeBSD-src-4764c8658fdd2787fdd421279037fe93eb05ac7c.zip
FreeBSD-src-4764c8658fdd2787fdd421279037fe93eb05ac7c.tar.gz
Virgin import of BIND v8.2.4-REL
Diffstat (limited to 'contrib/bind/lib/dst/dst_api.c')
-rw-r--r--contrib/bind/lib/dst/dst_api.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/contrib/bind/lib/dst/dst_api.c b/contrib/bind/lib/dst/dst_api.c
index e32d075..c296fdd 100644
--- a/contrib/bind/lib/dst/dst_api.c
+++ b/contrib/bind/lib/dst/dst_api.c
@@ -1,5 +1,5 @@
#ifndef LINT
-static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/dst_api.c,v 1.16 2000/11/13 04:09:23 vixie Exp $";
+static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/dst_api.c,v 1.17 2001/04/05 22:00:02 bwelling Exp $";
#endif
/*
@@ -657,6 +657,7 @@ dst_dnskey_to_key(const char *in_name, const u_char *rdata, const int len)
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) {
@@ -760,6 +761,8 @@ dst_buffer_to_key(const char *key_name, /* name of the key */
{
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));
@@ -771,14 +774,17 @@ dst_buffer_to_key(const char *key_name, /* name of the key */
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
@@ -816,10 +822,12 @@ dst_s_read_private_key_file(char *name, DST_KEY *pk_key, u_int16_t in_id,
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"));
@@ -886,10 +894,13 @@ dst_s_read_private_key_file(char *name, DST_KEY *pk_key, u_int16_t in_id,
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) {
@@ -942,6 +953,9 @@ dst_generate_key(const char *name, const int bits, const int exp,
{
DST_KEY *new_key = NULL;
int res;
+ int dnslen;
+ u_char dns[2048];
+
if (name == NULL)
return (NULL);
@@ -966,6 +980,13 @@ dst_generate_key(const char *name, const int bits, const int exp,
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);
}
OpenPOWER on IntegriCloud