41 static const char* key_str =
"keys";
50 uint32_t flags,
int publish,
int ksk,
int zsk)
55 ods_log_error(
"[%s] create key failed: no allocator available",
61 if (!locator || !algorithm || !flags) {
62 ods_log_error(
"[%s] create failed: missing required elements",
101 const char* locator = NULL;
102 uint8_t algorithm = 0;
126 free((
void*)locator);
133 ldns_rr_new_frm_fp(&rr, fd, NULL, NULL, NULL) != LDNS_STATUS_OK) {
134 ods_log_error(
"[%s] key in backup is published, but no rr found",
137 free((
void*)locator);
146 free((
void*)locator);
159 ods_log_error(
"[%s] unable to recover key: allocator failed",
162 free((
void*)locator);
186 free((
void*)locator);
203 fprintf(fd,
"\t\t\t<Key>\n");
204 fprintf(fd,
"\t\t\t\t<Flags>%u</Flags>\n", key->
flags);
205 fprintf(fd,
"\t\t\t\t<Algorithm>%u</Algorithm>\n", key->
algorithm);
207 fprintf(fd,
"\t\t\t\t<Locator>%s</Locator>\n", key->
locator);
210 fprintf(fd,
"\t\t\t\t<KSK />\n");
213 fprintf(fd,
"\t\t\t\t<ZSK />\n");
216 fprintf(fd,
"\t\t\t\t<Publish />\n");
218 fprintf(fd,
"\t\t\t</Key>\n");
235 fprintf(fd,
";;Key: locator %s algorithm %u flags %u publish %i ksk %i "
239 ldns_rr_print(fd, key->
dnskey);
241 fprintf(fd,
";;Keydone\n");
251 key_log(
key_type* key,
const char* name)
256 ods_log_verbose(
"[%s] zone %s key: LOCATOR[%s] FLAGS[%u] ALGORITHM[%u] "
257 "KSK[%i] ZSK[%i] PUBLISH[%i]", key_str, name?name:
"(null)", key->
locator,
273 ods_log_error(
"[%s] create list failed: no allocator available",
303 if (!kl || !key || !key->
locator) {
304 ods_log_error(
"[%s] push failed: no list or no key", key_str);
311 if (kl->
count == 0) {
335 if (!list || !locator) {
340 for (i=0; i < list->
count; i++) {
341 if (search && search->
locator) {
345 search = search->
next;
364 if (!list || !dnskey) {
369 for (i=0; i < list->
count; i++) {
370 if (search && search->
dnskey) {
371 if (ldns_rr_compare(search->
dnskey, dnskey) == 0) {
374 search = search->
next;
416 key_backup(fd, walk);
459 ldns_rr_free(key->
dnskey);
463 hsm_key_free(key->
hsmkey);
467 hsm_sign_params_free(key->
params);
void keylist_cleanup(keylist_type *kl)
int backup_read_str(FILE *in, const char **str)
void keylist_log(keylist_type *kl, const char *name)
int backup_read_uint8_t(FILE *in, uint8_t *v)
void ods_log_debug(const char *format,...)
allocator_type * allocator
void * allocator_alloc(allocator_type *allocator, size_t size)
enum ods_enum_status ods_status
void keylist_backup(FILE *fd, keylist_type *kl)
void ods_log_error(const char *format,...)
void keylist_print(FILE *fd, keylist_type *kl)
int ods_strcmp(const char *s1, const char *s2)
int backup_read_int(FILE *in, int *v)
ods_status keylist_push(keylist_type *kl, key_type *key)
key_type * key_create(allocator_type *allocator, const char *locator, uint8_t algorithm, uint32_t flags, int publish, int ksk, int zsk)
keylist_type * keylist_create(allocator_type *allocator)
key_type * key_recover(FILE *fd, allocator_type *allocator)
char * allocator_strdup(allocator_type *allocator, const char *string)
void ods_log_verbose(const char *format,...)
key_type * keylist_lookup_by_dnskey(keylist_type *list, ldns_rr *dnskey)
int backup_read_check_str(FILE *in, const char *str)
hsm_sign_params_t * params
key_type * keylist_lookup(keylist_type *list, const char *locator)
void allocator_deallocate(allocator_type *allocator, void *data)
allocator_type * allocator
#define ods_log_assert(x)
int backup_read_uint32_t(FILE *in, uint32_t *v)