39 static const char* key_str =
"keys";
58 ods_log_error(
"[%s] create list failed: allocator_alloc() failed",
77 if (!kl || !locator || kl->
count <= 0) {
80 for (i=0; i < kl->
count; i++) {
99 if (!kl || !dnskey || kl->
count <= 0) {
102 for (i=0; i < kl->
count; i++) {
104 if (ldns_rr_compare(kl->
keys[i].
dnskey, dnskey) == 0) {
119 uint8_t algorithm, uint32_t flags,
int publish,
int ksk,
int zsk,
134 ods_fatal_exit(
"[%s] unable to add key: allocator_alloc() failed",
166 fprintf(fd,
"\t\t\t<Key>\n");
167 fprintf(fd,
"\t\t\t\t<Flags>%u</Flags>\n", key->
flags);
168 fprintf(fd,
"\t\t\t\t<Algorithm>%u</Algorithm>\n", key->
algorithm);
170 fprintf(fd,
"\t\t\t\t<Locator>%s</Locator>\n", key->
locator);
173 fprintf(fd,
"\t\t\t\t<KSK />\n");
176 fprintf(fd,
"\t\t\t\t<ZSK />\n");
179 fprintf(fd,
"\t\t\t\t<Publish />\n");
182 fprintf(fd,
"\t\t\t\t<RFC5011 />\n");
184 fprintf(fd,
"\t\t\t</Key>\n");
195 key_log(
key_type* key,
const char* name)
200 ods_log_debug(
"[%s] zone %s key: LOCATOR[%s] FLAGS[%u] ALGORITHM[%u] " 201 "KSK[%i] ZSK[%i] PUBLISH[%i] RFC5011[%i]", key_str, name?name:
"(null)", key->
locator,
215 if (!fd || !kl || kl->
count <= 0) {
218 for (i=0; i < kl->
count; i++) {
219 key_print(fd, &kl->
keys[i]);
233 if (!kl || kl->
count <= 0) {
236 for (i=0; i < kl->
count; i++) {
237 key_log(&kl->
keys[i], name);
254 hsm_key_free(key->
hsmkey);
255 hsm_sign_params_free(key->
params);
273 for (i=0; i < kl->
count; i++) {
274 key_delfunc(&kl->
keys[i]);
287 key_backup(FILE* fd,
key_type* key,
const char* version)
292 fprintf(fd,
";;Key: locator %s algorithm %u flags %u publish %i ksk %i " 295 if (strcmp(version, ODS_SE_FILE_MAGIC_V2) == 0) {
299 fprintf(fd,
";;Keydone\n");
312 const char* locator = NULL;
313 uint8_t algorithm = 0;
337 free((
void*)locator);
343 return keylist_push(kl, locator, algorithm, flags, publish, ksk,
356 if (!fd || !kl || kl->
count <= 0) {
359 for (i=0; i < kl->
count; i++) {
360 key_backup(fd, &kl->
keys[i], version);
void keylist_cleanup(keylist_type *kl)
int backup_read_str(FILE *in, const char **str)
key_type * keylist_push(keylist_type *kl, const char *locator, uint8_t algorithm, uint32_t flags, int publish, int ksk, int zsk, int rfc5011)
void keylist_log(keylist_type *kl, const char *name)
key_type * keylist_lookup_by_locator(keylist_type *kl, const char *locator)
int backup_read_uint8_t(FILE *in, uint8_t *v)
void ods_log_debug(const char *format,...)
void * allocator_alloc(allocator_type *allocator, size_t size)
void ods_fatal_exit(const char *format,...)
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 util_rr_print(FILE *fd, const ldns_rr *rr)
keylist_type * keylist_create(void *sc)
allocator_type * allocator
int backup_read_check_str(FILE *in, const char *str)
hsm_sign_params_t * params
key_type * keylist_lookup_by_dnskey(keylist_type *kl, ldns_rr *dnskey)
void allocator_deallocate(allocator_type *allocator, void *data)
#define ods_log_assert(x)
key_type * key_recover2(FILE *fd, keylist_type *kl)
void keylist_backup(FILE *fd, keylist_type *kl, const char *version)
int backup_read_uint32_t(FILE *in, uint32_t *v)