41 static const char* key_str =
"keys";
60 ods_log_error(
"[%s] create list failed: allocator_alloc() failed",
79 if (!kl || !locator || kl->
count <= 0) {
82 for (i=0; i < kl->
count; i++) {
101 if (!kl || !dnskey || kl->
count <= 0) {
104 for (i=0; i < kl->
count; i++) {
106 if (ldns_rr_compare(kl->
keys[i].
dnskey, dnskey) == 0) {
121 uint8_t algorithm, uint32_t flags,
int publish,
int ksk,
int zsk)
135 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");
181 fprintf(fd,
"\t\t\t</Key>\n");
192 key_log(
key_type* key,
const char* name)
197 ods_log_debug(
"[%s] zone %s key: LOCATOR[%s] FLAGS[%u] ALGORITHM[%u] "
198 "KSK[%i] ZSK[%i] PUBLISH[%i]", key_str, name?name:
"(null)", key->
locator,
212 if (!fd || !kl || kl->
count <= 0) {
215 for (i=0; i < kl->
count; i++) {
216 key_print(fd, &kl->
keys[i]);
230 if (!kl || kl->
count <= 0) {
233 for (i=0; i < kl->
count; i++) {
234 key_log(&kl->
keys[i], name);
251 hsm_key_free(key->
hsmkey);
252 hsm_sign_params_free(key->
params);
270 for (i=0; i < kl->
count; i++) {
271 key_delfunc(&kl->
keys[i]);
284 key_backup(FILE* fd,
key_type* key,
const char* version)
289 fprintf(fd,
";;Key: locator %s algorithm %u flags %u publish %i ksk %i "
292 if (strcmp(version, ODS_SE_FILE_MAGIC_V2) == 0) {
296 fprintf(fd,
";;Keydone\n");
309 const char* locator = NULL;
310 uint8_t algorithm = 0;
331 free((
void*)locator);
337 return keylist_push(kl, locator, algorithm, flags, publish, ksk, zsk);
349 if (!fd || !kl || kl->
count <= 0) {
352 for (i=0; i < kl->
count; i++) {
353 key_backup(fd, &kl->
keys[i], version);
void keylist_cleanup(keylist_type *kl)
int backup_read_str(FILE *in, const char **str)
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)
key_type * keylist_push(keylist_type *kl, const char *locator, uint8_t algorithm, uint32_t flags, int publish, int ksk, int zsk)
#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)