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",
165 fprintf(fd,
"\t\t\t<Key>\n");
166 fprintf(fd,
"\t\t\t\t<Flags>%u</Flags>\n", key->
flags);
167 fprintf(fd,
"\t\t\t\t<Algorithm>%u</Algorithm>\n", key->
algorithm);
169 fprintf(fd,
"\t\t\t\t<Locator>%s</Locator>\n", key->
locator);
172 fprintf(fd,
"\t\t\t\t<KSK />\n");
175 fprintf(fd,
"\t\t\t\t<ZSK />\n");
178 fprintf(fd,
"\t\t\t\t<Publish />\n");
181 fprintf(fd,
"\t\t\t\t<RFC5011 />\n");
183 fprintf(fd,
"\t\t\t</Key>\n");
194 key_log(
key_type* key,
const char* name)
199 ods_log_debug(
"[%s] zone %s key: LOCATOR[%s] FLAGS[%u] ALGORITHM[%u] " 200 "KSK[%i] ZSK[%i] PUBLISH[%i] RFC5011[%i]", key_str, name?name:
"(null)", key->
locator,
214 if (!fd || !kl || kl->
count <= 0) {
217 for (i=0; i < kl->
count; i++) {
218 key_print(fd, &kl->
keys[i]);
232 if (!kl || kl->
count <= 0) {
235 for (i=0; i < kl->
count; i++) {
236 key_log(&kl->
keys[i], name);
253 hsm_sign_params_free(key->
params);
271 for (i=0; i < kl->
count; i++) {
272 key_delfunc(&kl->
keys[i]);
285 key_backup(FILE* fd,
key_type* key,
const char* version)
290 fprintf(fd,
";;Key: locator %s algorithm %u flags %u publish %i ksk %i " 293 if (strcmp(version, ODS_SE_FILE_MAGIC_V2) == 0) {
297 fprintf(fd,
";;Keydone\n");
310 const char* locator = NULL;
311 uint8_t algorithm = 0;
335 free((
void*)locator);
341 return keylist_push(kl, locator, algorithm, flags, publish, ksk,
354 if (!fd || !kl || kl->
count <= 0) {
357 for (i=0; i < kl->
count; i++) {
358 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)