Parse key-store config
Add the code that actually stores the key-store configuration into structures, also store the reference into the kasp key.
This commit is contained in:
@@ -51,6 +51,7 @@ struct dns_kasp_key {
|
||||
ISC_LINK(struct dns_kasp_key) link;
|
||||
|
||||
/* Configuration */
|
||||
char *keystore;
|
||||
uint32_t lifetime;
|
||||
uint8_t algorithm;
|
||||
int length;
|
||||
|
||||
@@ -385,21 +385,20 @@ dns_kasp_addkey(dns_kasp_t *kasp, dns_kasp_key_t *key) {
|
||||
|
||||
isc_result_t
|
||||
dns_kasp_key_create(dns_kasp_t *kasp, dns_kasp_key_t **keyp) {
|
||||
dns_kasp_key_t *key;
|
||||
dns_kasp_key_t *key = NULL;
|
||||
dns_kasp_key_t k = { .length = -1 };
|
||||
|
||||
REQUIRE(DNS_KASP_VALID(kasp));
|
||||
REQUIRE(keyp != NULL && *keyp == NULL);
|
||||
|
||||
key = isc_mem_get(kasp->mctx, sizeof(*key));
|
||||
*key = k;
|
||||
|
||||
key->mctx = NULL;
|
||||
isc_mem_attach(kasp->mctx, &key->mctx);
|
||||
|
||||
ISC_LINK_INIT(key, link);
|
||||
|
||||
key->lifetime = 0;
|
||||
key->algorithm = 0;
|
||||
key->length = -1;
|
||||
key->role = 0;
|
||||
*keyp = key;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -408,6 +407,10 @@ void
|
||||
dns_kasp_key_destroy(dns_kasp_key_t *key) {
|
||||
REQUIRE(key != NULL);
|
||||
|
||||
if (key->keystore != NULL) {
|
||||
isc_mem_free(key->mctx, key->keystore);
|
||||
key->keystore = NULL;
|
||||
}
|
||||
isc_mem_putanddetach(&key->mctx, key, sizeof(*key));
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,12 @@ cfg_kaspkey_fromconfig(const cfg_obj_t *config, dns_kasp_t *kasp,
|
||||
key->role |= DNS_KASP_KEY_ROLE_ZSK;
|
||||
}
|
||||
|
||||
obj = cfg_tuple_get(config, "keystorage");
|
||||
if (cfg_obj_isstring(obj)) {
|
||||
key->keystore = isc_mem_strdup(key->mctx,
|
||||
cfg_obj_asstring(obj));
|
||||
}
|
||||
|
||||
key->lifetime = 0; /* unlimited */
|
||||
obj = cfg_tuple_get(config, "lifetime");
|
||||
if (cfg_obj_isduration(obj)) {
|
||||
|
||||
Reference in New Issue
Block a user