mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
Export dst_key_buildfilename and make various dst functions call it.
This commit is contained in:
parent
c5c3b17a0a
commit
94a7e85857
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Principal Author: Brian Wellington
|
* Principal Author: Brian Wellington
|
||||||
* $Id: bsafe_link.c,v 1.17 2000/05/13 19:28:15 tale Exp $
|
* $Id: bsafe_link.c,v 1.18 2000/05/15 21:02:27 bwelling Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(BSAFE) || defined(DNSSAFE)
|
#if defined(BSAFE) || defined(DNSSAFE)
|
||||||
@ -592,8 +592,7 @@ dst_bsafe_to_file(const dst_key_t *key) {
|
|||||||
priv.elements[cnt++].length = private->coefficient.len;
|
priv.elements[cnt++].length = private->coefficient.len;
|
||||||
|
|
||||||
priv.nelements = cnt;
|
priv.nelements = cnt;
|
||||||
return (dst_s_write_private_key_file(key->key_name, key->key_alg,
|
return (dst_s_write_private_key_file(key, &priv));
|
||||||
key->key_id, &priv));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -624,8 +623,7 @@ dst_bsafe_from_file(dst_key_t *key, const isc_uint16_t id, isc_mem_t *mctx) {
|
|||||||
/*
|
/*
|
||||||
* Read private key file.
|
* Read private key file.
|
||||||
*/
|
*/
|
||||||
ret = dst_s_parse_private_key_file(key->key_name, key->key_alg,
|
ret = dst_s_parse_private_key_file(key, &priv, mctx);
|
||||||
id, &priv, mctx);
|
|
||||||
if (ret != ISC_R_SUCCESS)
|
if (ret != ISC_R_SUCCESS)
|
||||||
return (ret);
|
return (ret);
|
||||||
/*
|
/*
|
||||||
|
@ -19,11 +19,12 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Principal Author: Brian Wellington
|
* Principal Author: Brian Wellington
|
||||||
* $Id: dst_api.c,v 1.34 2000/05/11 02:11:44 gson Exp $
|
* $Id: dst_api.c,v 1.35 2000/05/15 21:02:28 bwelling Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <isc/buffer.h>
|
||||||
#include <isc/dir.h>
|
#include <isc/dir.h>
|
||||||
#include <isc/lex.h>
|
#include <isc/lex.h>
|
||||||
#include <isc/mem.h>
|
#include <isc/mem.h>
|
||||||
@ -743,6 +744,35 @@ dst_key_isnullkey(const dst_key_t *key) {
|
|||||||
return (ISC_TRUE);
|
return (ISC_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dst_key_buildfilename(const dst_key_t *key, const int type, isc_buffer_t *out) {
|
||||||
|
char *suffix;
|
||||||
|
unsigned int namelen;
|
||||||
|
isc_region_t r;
|
||||||
|
|
||||||
|
REQUIRE(VALID_KEY(key));
|
||||||
|
REQUIRE(type == DST_TYPE_PRIVATE || type == DST_TYPE_PUBLIC ||
|
||||||
|
type == 0);
|
||||||
|
REQUIRE(out != NULL);
|
||||||
|
if (type == 0)
|
||||||
|
suffix = "";
|
||||||
|
else if (type == DST_TYPE_PRIVATE)
|
||||||
|
suffix = ".private";
|
||||||
|
else
|
||||||
|
suffix = ".key";
|
||||||
|
namelen = 1 + strlen(key->key_name) + 1 + 3 + 1 + 5 + 1 +
|
||||||
|
strlen(suffix);
|
||||||
|
isc_buffer_availableregion(out, &r);
|
||||||
|
if (namelen >= r.length)
|
||||||
|
return (ISC_R_NOSPACE);
|
||||||
|
if (namelen >= ISC_DIR_NAMEMAX)
|
||||||
|
return (ISC_R_INVALIDFILE);
|
||||||
|
sprintf((char *) r.base, "K%s+%03d+%05d%s", key->key_name,
|
||||||
|
key->key_alg, key->key_id, suffix);
|
||||||
|
isc_buffer_add(out, namelen);
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dst_sig_size
|
* dst_sig_size
|
||||||
* Computes the maximum size of a signature generated by the given key
|
* Computes the maximum size of a signature generated by the given key
|
||||||
@ -967,7 +997,7 @@ get_key_struct(const char *name, const int alg, const int flags,
|
|||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
read_public_key(const char *name, const isc_uint16_t id, int alg,
|
read_public_key(const char *name, const isc_uint16_t id, int alg,
|
||||||
isc_mem_t *mctx, dst_key_t **keyp)
|
isc_mem_t *mctx, dst_key_t **keyp)
|
||||||
{
|
{
|
||||||
char filename[ISC_DIR_NAMEMAX];
|
char filename[ISC_DIR_NAMEMAX];
|
||||||
u_char rdatabuf[DST_KEY_MAXSIZE];
|
u_char rdatabuf[DST_KEY_MAXSIZE];
|
||||||
@ -977,10 +1007,17 @@ read_public_key(const char *name, const isc_uint16_t id, int alg,
|
|||||||
isc_result_t ret;
|
isc_result_t ret;
|
||||||
dns_rdata_t rdata;
|
dns_rdata_t rdata;
|
||||||
unsigned int opt = ISC_LEXOPT_DNSMULTILINE;
|
unsigned int opt = ISC_LEXOPT_DNSMULTILINE;
|
||||||
|
dst_key_t *tempkey;
|
||||||
|
|
||||||
if (dst_s_build_filename(filename, name, id, alg, PUBLIC_KEY,
|
tempkey = get_key_struct(name, alg, 0, 0, 0, mctx);
|
||||||
sizeof(filename)) != ISC_R_SUCCESS)
|
if (tempkey == NULL)
|
||||||
return (DST_R_NAMETOOLONG);
|
return (ISC_R_NOMEMORY);
|
||||||
|
tempkey->key_id = id;
|
||||||
|
isc_buffer_init(&b, filename, sizeof(filename));
|
||||||
|
ret = dst_key_buildfilename(tempkey, DST_TYPE_PUBLIC, &b);
|
||||||
|
dst_key_free(tempkey);
|
||||||
|
if (ret != ISC_R_SUCCESS)
|
||||||
|
return (ret);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open the file and read its formatted contents
|
* Open the file and read its formatted contents
|
||||||
@ -1070,7 +1107,7 @@ cleanup:
|
|||||||
static isc_result_t
|
static isc_result_t
|
||||||
write_public_key(const dst_key_t *key) {
|
write_public_key(const dst_key_t *key) {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
isc_buffer_t keyb, textb;
|
isc_buffer_t keyb, textb, fileb;
|
||||||
isc_region_t r;
|
isc_region_t r;
|
||||||
char filename[ISC_DIR_NAMEMAX];
|
char filename[ISC_DIR_NAMEMAX];
|
||||||
unsigned char key_array[DST_KEY_MAXSIZE];
|
unsigned char key_array[DST_KEY_MAXSIZE];
|
||||||
@ -1102,10 +1139,10 @@ write_public_key(const dst_key_t *key) {
|
|||||||
/*
|
/*
|
||||||
* Make the filename.
|
* Make the filename.
|
||||||
*/
|
*/
|
||||||
if (dst_s_build_filename(filename,
|
isc_buffer_init(&fileb, filename, sizeof(filename));
|
||||||
key->key_name, key->key_id, key->key_alg,
|
ret = dst_key_buildfilename(key, DST_TYPE_PUBLIC, &fileb);
|
||||||
PUBLIC_KEY, sizeof(filename)) < 0)
|
if (ret != ISC_R_SUCCESS)
|
||||||
return (DST_R_NAMETOOLONG);
|
return (ret);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create public key file.
|
* Create public key file.
|
||||||
|
@ -85,12 +85,6 @@ struct dst_func {
|
|||||||
|
|
||||||
extern dst_func *dst_t_func[DST_MAX_ALGS];
|
extern dst_func *dst_t_func[DST_MAX_ALGS];
|
||||||
|
|
||||||
/*
|
|
||||||
* Suffixes for key file names.
|
|
||||||
*/
|
|
||||||
#define PRIVATE_KEY "private"
|
|
||||||
#define PUBLIC_KEY "key"
|
|
||||||
|
|
||||||
#ifndef DST_HASH_SIZE
|
#ifndef DST_HASH_SIZE
|
||||||
#define DST_HASH_SIZE 20 /* RIPEMD160 & SHA-1 are 20 bytes, MD5 is 16 */
|
#define DST_HASH_SIZE 20 /* RIPEMD160 & SHA-1 are 20 bytes, MD5 is 16 */
|
||||||
#endif
|
#endif
|
||||||
@ -111,9 +105,6 @@ int
|
|||||||
dst_s_calculate_bits(const unsigned char *str, const int max_bits);
|
dst_s_calculate_bits(const unsigned char *str, const int max_bits);
|
||||||
isc_uint16_t
|
isc_uint16_t
|
||||||
dst_s_id_calc(const unsigned char *key, const int keysize);
|
dst_s_id_calc(const unsigned char *key, const int keysize);
|
||||||
int
|
|
||||||
dst_s_build_filename(char *filename, const char *name, isc_uint16_t id,
|
|
||||||
int alg, const char *suffix, size_t filename_length);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Digest functions.
|
* Digest functions.
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Principal Author: Brian Wellington
|
* Principal Author: Brian Wellington
|
||||||
* $Id: dst_parse.c,v 1.13 2000/05/13 19:30:19 tale Exp $
|
* $Id: dst_parse.c,v 1.14 2000/05/15 21:02:32 bwelling Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
@ -187,8 +187,7 @@ dst_s_free_private_structure_fields(dst_private_t *priv, isc_mem_t *mctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dst_s_parse_private_key_file(const char *name, const int alg,
|
dst_s_parse_private_key_file(const dst_key_t *key, dst_private_t *priv,
|
||||||
const isc_uint16_t id, dst_private_t *priv,
|
|
||||||
isc_mem_t *mctx)
|
isc_mem_t *mctx)
|
||||||
{
|
{
|
||||||
char filename[ISC_DIR_NAMEMAX];
|
char filename[ISC_DIR_NAMEMAX];
|
||||||
@ -203,10 +202,10 @@ dst_s_parse_private_key_file(const char *name, const int alg,
|
|||||||
|
|
||||||
priv->nelements = 0;
|
priv->nelements = 0;
|
||||||
|
|
||||||
ret = dst_s_build_filename(filename, name, id, alg, PRIVATE_KEY,
|
isc_buffer_init(&b, filename, sizeof(filename));
|
||||||
sizeof(filename));
|
ret = dst_key_buildfilename(key, DST_TYPE_PRIVATE, &b);
|
||||||
if (ret < 0)
|
if (ret != ISC_R_SUCCESS)
|
||||||
return (DST_R_NAMETOOLONG);
|
return (ret);
|
||||||
|
|
||||||
iret = isc_lex_create(mctx, 1024, &lex);
|
iret = isc_lex_create(mctx, 1024, &lex);
|
||||||
if (iret != ISC_R_SUCCESS)
|
if (iret != ISC_R_SUCCESS)
|
||||||
@ -259,7 +258,7 @@ dst_s_parse_private_key_file(const char *name, const int alg,
|
|||||||
|
|
||||||
NEXTTOKEN(lex, opt | ISC_LEXOPT_NUMBER, &token);
|
NEXTTOKEN(lex, opt | ISC_LEXOPT_NUMBER, &token);
|
||||||
if (token.type != isc_tokentype_number ||
|
if (token.type != isc_tokentype_number ||
|
||||||
token.value.as_ulong != (unsigned long) alg)
|
token.value.as_ulong != (unsigned long) dst_key_alg(key))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
READLINE(lex, opt, &token);
|
READLINE(lex, opt, &token);
|
||||||
@ -281,8 +280,8 @@ dst_s_parse_private_key_file(const char *name, const int alg,
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
memset(&priv->elements[n], 0, sizeof(dst_private_element_t));
|
memset(&priv->elements[n], 0, sizeof(dst_private_element_t));
|
||||||
tag = find_value(token.value.as_pointer, alg);
|
tag = find_value(token.value.as_pointer, dst_key_alg(key));
|
||||||
if (tag < 0 || TAG_ALG(tag) != alg)
|
if (tag < 0 || TAG_ALG(tag) != dst_key_alg(key))
|
||||||
goto fail;
|
goto fail;
|
||||||
priv->elements[n].tag = tag;
|
priv->elements[n].tag = tag;
|
||||||
|
|
||||||
@ -303,7 +302,7 @@ dst_s_parse_private_key_file(const char *name, const int alg,
|
|||||||
|
|
||||||
priv->nelements = n;
|
priv->nelements = n;
|
||||||
|
|
||||||
if (check_data(priv, alg) < 0)
|
if (check_data(priv, dst_key_alg(key)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
isc_lex_close(lex);
|
isc_lex_close(lex);
|
||||||
@ -323,24 +322,23 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dst_s_write_private_key_file(const char *name, const int alg,
|
dst_s_write_private_key_file(const dst_key_t *key, const dst_private_t *priv) {
|
||||||
const isc_uint16_t id, const dst_private_t *priv)
|
|
||||||
{
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
isc_result_t iret;
|
isc_result_t iret;
|
||||||
char filename[ISC_DIR_NAMEMAX];
|
char filename[ISC_DIR_NAMEMAX];
|
||||||
char buffer[MAXFIELDSIZE * 2];
|
char buffer[MAXFIELDSIZE * 2];
|
||||||
|
isc_buffer_t b;
|
||||||
|
|
||||||
REQUIRE(priv != NULL);
|
REQUIRE(priv != NULL);
|
||||||
|
|
||||||
if (check_data(priv, alg) < 0)
|
if (check_data(priv, dst_key_alg(key)) < 0)
|
||||||
return (DST_R_INVALIDPRIVATEKEY);
|
return (DST_R_INVALIDPRIVATEKEY);
|
||||||
|
|
||||||
ret = dst_s_build_filename(filename, name, id, alg, PRIVATE_KEY,
|
isc_buffer_init(&b, filename, sizeof(filename));
|
||||||
sizeof(filename));
|
ret = dst_key_buildfilename(key, DST_TYPE_PRIVATE, &b);
|
||||||
if (ret < 0)
|
if (ret != ISC_R_SUCCESS)
|
||||||
return (DST_R_NAMETOOLONG);
|
return (ret);
|
||||||
|
|
||||||
if ((fp = fopen(filename, "w")) == NULL)
|
if ((fp = fopen(filename, "w")) == NULL)
|
||||||
return (DST_R_WRITEERROR);
|
return (DST_R_WRITEERROR);
|
||||||
@ -351,8 +349,8 @@ dst_s_write_private_key_file(const char *name, const int alg,
|
|||||||
fprintf(fp, "%s v%d.%d\n", PRIVATE_KEY_STR, MAJOR_VERSION,
|
fprintf(fp, "%s v%d.%d\n", PRIVATE_KEY_STR, MAJOR_VERSION,
|
||||||
MINOR_VERSION);
|
MINOR_VERSION);
|
||||||
|
|
||||||
fprintf(fp, "%s %d ", ALGORITHM_STR, alg);
|
fprintf(fp, "%s %d ", ALGORITHM_STR, dst_key_alg(key));
|
||||||
switch (alg) {
|
switch (dst_key_alg(key)) {
|
||||||
case DST_ALG_RSA: fprintf(fp, "(RSA)\n"); break;
|
case DST_ALG_RSA: fprintf(fp, "(RSA)\n"); break;
|
||||||
case DST_ALG_DH: fprintf(fp, "(DH)\n"); break;
|
case DST_ALG_DH: fprintf(fp, "(DH)\n"); break;
|
||||||
case DST_ALG_DSA: fprintf(fp, "(DSA)\n"); break;
|
case DST_ALG_DSA: fprintf(fp, "(DSA)\n"); break;
|
||||||
|
@ -78,13 +78,11 @@ void
|
|||||||
dst_s_free_private_structure_fields(dst_private_t *priv, isc_mem_t *mctx);
|
dst_s_free_private_structure_fields(dst_private_t *priv, isc_mem_t *mctx);
|
||||||
|
|
||||||
int
|
int
|
||||||
dst_s_parse_private_key_file(const char *name, const int alg,
|
dst_s_parse_private_key_file(const dst_key_t *key, dst_private_t *priv,
|
||||||
const isc_uint16_t id, dst_private_t *priv,
|
|
||||||
isc_mem_t *mctx);
|
isc_mem_t *mctx);
|
||||||
|
|
||||||
int
|
int
|
||||||
dst_s_write_private_key_file(const char *name, const int alg,
|
dst_s_write_private_key_file(const dst_key_t *key, const dst_private_t *priv);
|
||||||
const isc_uint16_t id, const dst_private_t *priv);
|
|
||||||
|
|
||||||
ISC_LANG_ENDDECLS
|
ISC_LANG_ENDDECLS
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Principal Author: Brian Wellington
|
* Principal Author: Brian Wellington
|
||||||
* $Id: dst_support.c,v 1.4 2000/05/08 14:37:06 tale Exp $
|
* $Id: dst_support.c,v 1.5 2000/05/15 21:02:34 bwelling Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
@ -81,48 +81,3 @@ dst_s_id_calc(const unsigned char *key, const int keysize) {
|
|||||||
|
|
||||||
return ((isc_uint16_t)(ac & 0xffff));
|
return ((isc_uint16_t)(ac & 0xffff));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* dst_s_build_filename
|
|
||||||
* Builds a key filename from the key name, its id, and a
|
|
||||||
* suffix. '\', '/' and ':' are not allowed. fA filename is of the
|
|
||||||
* form: K<keyname><id>.<suffix>
|
|
||||||
* form: K<keyname>+<alg>+<id>.<suffix>
|
|
||||||
*
|
|
||||||
* Returns -1 if the conversion fails:
|
|
||||||
* if the filename would be too long for space allotted
|
|
||||||
* if the filename would contain a '\', '/' or ':'
|
|
||||||
* Returns 0 on success
|
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
|
||||||
dst_s_build_filename(char *filename, const char *name, isc_uint16_t id,
|
|
||||||
int alg, const char *suffix, size_t filename_length)
|
|
||||||
{
|
|
||||||
isc_uint32_t my_id;
|
|
||||||
char *dot;
|
|
||||||
if (filename == NULL)
|
|
||||||
return (-1);
|
|
||||||
memset(filename, 0, filename_length);
|
|
||||||
if (name == NULL)
|
|
||||||
return (-1);
|
|
||||||
if (suffix == NULL)
|
|
||||||
return (-1);
|
|
||||||
if (filename_length <
|
|
||||||
1 + strlen(name) + 1 + 4 + 6 + 1 + strlen(suffix))
|
|
||||||
return (-1);
|
|
||||||
my_id = id;
|
|
||||||
if (name[strlen(name) - 1] == '.')
|
|
||||||
dot = "";
|
|
||||||
else
|
|
||||||
dot = ".";
|
|
||||||
sprintf(filename, "K%s%s+%03d+%05d.%s", name, dot, alg, my_id,
|
|
||||||
(char *) suffix);
|
|
||||||
if (strrchr(filename, '/'))
|
|
||||||
return (-1);
|
|
||||||
if (strrchr(filename, '\\'))
|
|
||||||
return (-1);
|
|
||||||
if (strrchr(filename, ':'))
|
|
||||||
return (-1);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Principal Author: Brian Wellington
|
* Principal Author: Brian Wellington
|
||||||
* $Id: hmac_link.c,v 1.24 2000/05/13 19:31:35 tale Exp $
|
* $Id: hmac_link.c,v 1.25 2000/05/15 21:02:35 bwelling Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
@ -375,8 +375,7 @@ dst_hmacmd5_to_file(const dst_key_t *key) {
|
|||||||
priv.elements[cnt++].data = keydata;
|
priv.elements[cnt++].data = keydata;
|
||||||
|
|
||||||
priv.nelements = cnt;
|
priv.nelements = cnt;
|
||||||
return (dst_s_write_private_key_file(key->key_name, key->key_alg,
|
return (dst_s_write_private_key_file(key, &priv));
|
||||||
key->key_id, &priv));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -400,8 +399,7 @@ dst_hmacmd5_from_file(dst_key_t *key, const isc_uint16_t id, isc_mem_t *mctx) {
|
|||||||
#define DST_RET(a) {ret = a; goto err;}
|
#define DST_RET(a) {ret = a; goto err;}
|
||||||
|
|
||||||
/* read private key file */
|
/* read private key file */
|
||||||
ret = dst_s_parse_private_key_file(key->key_name, key->key_alg,
|
ret = dst_s_parse_private_key_file(key, &priv, mctx);
|
||||||
id, &priv, mctx);
|
|
||||||
if (ret != ISC_R_SUCCESS)
|
if (ret != ISC_R_SUCCESS)
|
||||||
return (ret);
|
return (ret);
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ dst_key_fromfile(const char *name, const isc_uint16_t id, const int alg,
|
|||||||
const int type, isc_mem_t *mctx, dst_key_t **keyp);
|
const int type, isc_mem_t *mctx, dst_key_t **keyp);
|
||||||
/*
|
/*
|
||||||
* Reads a key from permanent storage.
|
* Reads a key from permanent storage.
|
||||||
*
|
G*
|
||||||
* Requires:
|
* Requires:
|
||||||
* "name" is not NULL.
|
* "name" is not NULL.
|
||||||
* "id" is a valid key tag identifier.
|
* "id" is a valid key tag identifier.
|
||||||
@ -302,6 +302,21 @@ dst_key_iszonekey(const dst_key_t *key);
|
|||||||
isc_boolean_t
|
isc_boolean_t
|
||||||
dst_key_isnullkey(const dst_key_t *key);
|
dst_key_isnullkey(const dst_key_t *key);
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dst_key_buildfilename(const dst_key_t *key, const int type, isc_buffer_t *out);
|
||||||
|
/*
|
||||||
|
* Generates the filename used by dst to store the specified key.
|
||||||
|
*
|
||||||
|
* Requires:
|
||||||
|
* "key" is a valid key
|
||||||
|
* "type" is either DST_TYPE_PUBLIC, DST_TYPE_PRIVATE, or 0
|
||||||
|
* "out" is a valid buffer
|
||||||
|
*
|
||||||
|
* Ensures:
|
||||||
|
* the file name will be written to "out", and the used pointer will
|
||||||
|
* be advanced.
|
||||||
|
*/
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dst_sig_size(const dst_key_t *key, unsigned int *n);
|
dst_sig_size(const dst_key_t *key, unsigned int *n);
|
||||||
/*
|
/*
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Principal Author: Brian Wellington
|
* Principal Author: Brian Wellington
|
||||||
* $Id: openssl_link.c,v 1.21 2000/05/11 22:48:12 gson Exp $
|
* $Id: openssl_link.c,v 1.22 2000/05/15 21:02:36 bwelling Exp $
|
||||||
*/
|
*/
|
||||||
#if defined(OPENSSL)
|
#if defined(OPENSSL)
|
||||||
|
|
||||||
@ -422,8 +422,7 @@ dst_openssl_to_file(const dst_key_t *key) {
|
|||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
priv.nelements = cnt;
|
priv.nelements = cnt;
|
||||||
return (dst_s_write_private_key_file(key->key_name, key->key_alg,
|
return (dst_s_write_private_key_file(key, &priv));
|
||||||
key->key_id, &priv));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -451,8 +450,7 @@ dst_openssl_from_file(dst_key_t *key, const isc_uint16_t id, isc_mem_t *mctx) {
|
|||||||
#define DST_RET(a) {ret = a; goto err;}
|
#define DST_RET(a) {ret = a; goto err;}
|
||||||
|
|
||||||
/* read private key file */
|
/* read private key file */
|
||||||
ret = dst_s_parse_private_key_file(key->key_name, key->key_alg,
|
ret = dst_s_parse_private_key_file(key, &priv, mctx);
|
||||||
id, &priv, mctx);
|
|
||||||
if (ret != ISC_R_SUCCESS)
|
if (ret != ISC_R_SUCCESS)
|
||||||
return (ret);
|
return (ret);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Principal Author: Brian Wellington
|
* Principal Author: Brian Wellington
|
||||||
* $Id: openssldh_link.c,v 1.14 2000/05/11 22:47:02 gson Exp $
|
* $Id: openssldh_link.c,v 1.15 2000/05/15 21:02:37 bwelling Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(OPENSSL)
|
#if defined(OPENSSL)
|
||||||
@ -412,8 +412,7 @@ dst_openssldh_to_file(const dst_key_t *key) {
|
|||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
priv.nelements = cnt;
|
priv.nelements = cnt;
|
||||||
return (dst_s_write_private_key_file(key->key_name, key->key_alg,
|
return (dst_s_write_private_key_file(key, &priv));
|
||||||
key->key_id, &priv));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -442,8 +441,7 @@ dst_openssldh_from_file(dst_key_t *key, const isc_uint16_t id,
|
|||||||
#define DST_RET(a) {ret = a; goto err;}
|
#define DST_RET(a) {ret = a; goto err;}
|
||||||
|
|
||||||
/* read private key file */
|
/* read private key file */
|
||||||
ret = dst_s_parse_private_key_file(key->key_name, key->key_alg,
|
ret = dst_s_parse_private_key_file(key, &priv, mctx);
|
||||||
id, &priv, mctx);
|
|
||||||
if (ret != ISC_R_SUCCESS)
|
if (ret != ISC_R_SUCCESS)
|
||||||
return (ret);
|
return (ret);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user