hsm_key.h
Go to the documentation of this file.
/*
* Copyright (c) 2014 Jerry Lundström <lundstrom.jerry@gmail.com>
* Copyright (c) 2014 .SE (The Internet Infrastructure Foundation).
* Copyright (c) 2014 OpenDNSSEC AB (svb)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __hsm_key_h
#define __hsm_key_h
#include "db_object.h"
struct hsm_key;
struct hsm_key_list;
typedef struct hsm_key hsm_key_t;
typedef struct hsm_key_list hsm_key_list_t;
typedef enum hsm_key_state {
HSM_KEY_STATE_INVALID = -1,
HSM_KEY_STATE_UNUSED = 1,
HSM_KEY_STATE_PRIVATE = 2,
HSM_KEY_STATE_SHARED = 3,
HSM_KEY_STATE_DELETE = 4
} hsm_key_state_t;
extern const db_enum_t hsm_key_enum_set_state[];
typedef enum hsm_key_role {
HSM_KEY_ROLE_INVALID = -1,
HSM_KEY_ROLE_KSK = 1,
HSM_KEY_ROLE_ZSK = 2,
HSM_KEY_ROLE_CSK = 3
} hsm_key_role_t;
extern const db_enum_t hsm_key_enum_set_role[];
typedef enum hsm_key_key_type {
HSM_KEY_KEY_TYPE_INVALID = -1,
HSM_KEY_KEY_TYPE_RSA = 1
} hsm_key_key_type_t;
typedef enum hsm_key_backup {
HSM_KEY_BACKUP_INVALID = -1,
HSM_KEY_BACKUP_NO_BACKUP = 0,
HSM_KEY_BACKUP_BACKUP_REQUIRED = 1,
HSM_KEY_BACKUP_BACKUP_REQUESTED = 2,
HSM_KEY_BACKUP_BACKUP_DONE = 3
} hsm_key_backup_t;
extern const db_enum_t hsm_key_enum_set_backup[];
#include "hsm_key_ext.h"
#include "policy.h"
struct hsm_key {
db_object_t* dbo;
db_value_t id;
db_value_t rev;
db_value_t policy_id;
const policy_t* associated_policy_id;
policy_t* private_policy_id;
char* locator;
hsm_key_state_t state;
unsigned int bits;
unsigned int algorithm;
hsm_key_role_t role;
unsigned int inception;
unsigned int is_revoked;
hsm_key_key_type_t key_type;
char* repository;
hsm_key_backup_t backup;
};
hsm_key_t* hsm_key_new(const db_connection_t* connection);
hsm_key_t* hsm_key_new_copy(const hsm_key_t* hsm_key);
void hsm_key_free(hsm_key_t* hsm_key);
int hsm_key_copy(hsm_key_t* hsm_key, const hsm_key_t* hsm_key_copy);
int hsm_key_from_result(hsm_key_t* hsm_key, const db_result_t* result);
const db_value_t* hsm_key_id(const hsm_key_t* hsm_key);
const db_value_t* hsm_key_policy_id(const hsm_key_t* hsm_key);
const char* hsm_key_locator(const hsm_key_t* hsm_key);
hsm_key_state_t hsm_key_state(const hsm_key_t* hsm_key);
unsigned int hsm_key_bits(const hsm_key_t* hsm_key);
unsigned int hsm_key_algorithm(const hsm_key_t* hsm_key);
hsm_key_role_t hsm_key_role(const hsm_key_t* hsm_key);
unsigned int hsm_key_inception(const hsm_key_t* hsm_key);
const char* hsm_key_repository(const hsm_key_t* hsm_key);
hsm_key_backup_t hsm_key_backup(const hsm_key_t* hsm_key);
int hsm_key_set_policy_id(hsm_key_t* hsm_key, const db_value_t* policy_id);
int hsm_key_set_locator(hsm_key_t* hsm_key, const char* locator_text);
int hsm_key_set_state(hsm_key_t* hsm_key, hsm_key_state_t state);
int hsm_key_set_bits(hsm_key_t* hsm_key, unsigned int bits);
int hsm_key_set_algorithm(hsm_key_t* hsm_key, unsigned int algorithm);
int hsm_key_set_role(hsm_key_t* hsm_key, hsm_key_role_t role);
int hsm_key_set_inception(hsm_key_t* hsm_key, unsigned int inception);
int hsm_key_set_key_type(hsm_key_t* hsm_key, hsm_key_key_type_t key_type);
int hsm_key_set_repository(hsm_key_t* hsm_key, const char* repository_text);
int hsm_key_set_backup(hsm_key_t* hsm_key, hsm_key_backup_t backup);
db_clause_t* hsm_key_policy_id_clause(db_clause_list_t* clause_list, const db_value_t* policy_id);
db_clause_t* hsm_key_state_clause(db_clause_list_t* clause_list, hsm_key_state_t state);
db_clause_t* hsm_key_bits_clause(db_clause_list_t* clause_list, unsigned int bits);
db_clause_t* hsm_key_algorithm_clause(db_clause_list_t* clause_list, unsigned int algorithm);
db_clause_t* hsm_key_role_clause(db_clause_list_t* clause_list, hsm_key_role_t role);
db_clause_t* hsm_key_is_revoked_clause(db_clause_list_t* clause_list, unsigned int is_revoked);
db_clause_t* hsm_key_key_type_clause(db_clause_list_t* clause_list, hsm_key_key_type_t key_type);
db_clause_t* hsm_key_repository_clause(db_clause_list_t* clause_list, const char* repository_text);
db_clause_t* hsm_key_backup_clause(db_clause_list_t* clause_list, hsm_key_backup_t backup);
int hsm_key_create(hsm_key_t* hsm_key);
int hsm_key_get_by_id(hsm_key_t* hsm_key, const db_value_t* id);
int hsm_key_get_by_locator(hsm_key_t* hsm_key, const char* locator);
hsm_key_t* hsm_key_new_get_by_locator(const db_connection_t* connection, const char* locator);
int hsm_key_update(hsm_key_t* hsm_key);
int hsm_key_count(hsm_key_t* hsm_key, db_clause_list_t* clause_list, size_t* count);
struct hsm_key_list {
db_object_t* dbo;
db_result_list_t* result_list;
const db_result_t* result;
hsm_key_t* hsm_key;
int object_store;
hsm_key_t** object_list;
size_t object_list_size;
size_t object_list_position;
int object_list_first;
int associated_fetch;
policy_list_t* policy_id_list;
};
hsm_key_list_t* hsm_key_list_new(const db_connection_t* connection);
hsm_key_list_t* hsm_key_list_new_copy(const hsm_key_list_t* hsm_key_copy);
int hsm_key_list_object_store(hsm_key_list_t* hsm_key_list);
void hsm_key_list_free(hsm_key_list_t* hsm_key_list);
int hsm_key_list_copy(hsm_key_list_t* hsm_key_list, const hsm_key_list_t* from_hsm_key_list);
int hsm_key_list_get_by_clauses(hsm_key_list_t* hsm_key_list, const db_clause_list_t* clause_list);
hsm_key_list_t* hsm_key_list_new_get_by_clauses(const db_connection_t* connection, const db_clause_list_t* clause_list);
int hsm_key_list_get_by_policy_id(hsm_key_list_t* hsm_key_list, const db_value_t* policy_id);
hsm_key_list_t* hsm_key_list_new_get_by_policy_id(const db_connection_t* connection, const db_value_t* policy_id);
const hsm_key_t* hsm_key_list_begin(hsm_key_list_t* hsm_key_list);
hsm_key_t* hsm_key_list_get_begin(hsm_key_list_t* hsm_key_list);
const hsm_key_t* hsm_key_list_next(hsm_key_list_t* hsm_key_list);
hsm_key_t* hsm_key_list_get_next(hsm_key_list_t* hsm_key_list);
#endif
hsm_key::bits
unsigned int bits
Definition: hsm_key.h:86
policy_list
Definition: policy.h:733
hsm_key_set_algorithm
int hsm_key_set_algorithm(hsm_key_t *hsm_key, unsigned int algorithm)
Definition: hsm_key.c:648
hsm_key_list_begin
const hsm_key_t * hsm_key_list_begin(hsm_key_list_t *hsm_key_list)
Definition: hsm_key.c:1832
hsm_key_list_object_store
int hsm_key_list_object_store(hsm_key_list_t *hsm_key_list)
Definition: hsm_key.c:1486
db_object
Definition: db_object.h:201
hsm_key_key_type_t
enum hsm_key_key_type hsm_key_key_type_t
hsm_key_list_new_get_by_policy_id
hsm_key_list_t * hsm_key_list_new_get_by_policy_id(const db_connection_t *connection, const db_value_t *policy_id)
Definition: hsm_key.c:1809
hsm_key_update
int hsm_key_update(hsm_key_t *hsm_key)
Definition: hsm_key.c:1225
hsm_key_key_type_clause
db_clause_t * hsm_key_key_type_clause(db_clause_list_t *clause_list, hsm_key_key_type_t key_type)
Definition: hsm_key.c:861
hsm_key_new_get_by_locator
hsm_key_t * hsm_key_new_get_by_locator(const db_connection_t *connection, const char *locator)
Definition: hsm_key.c:1205
db_clause_list
Definition: db_clause.h:226
hsm_key_repository_clause
db_clause_t * hsm_key_repository_clause(db_clause_list_t *clause_list, const char *repository_text)
Definition: hsm_key.c:882
HSM_KEY_STATE_PRIVATE
Definition: hsm_key.h:43
hsm_key_count
int hsm_key_count(hsm_key_t *hsm_key, db_clause_list_t *clause_list, size_t *count)
Definition: hsm_key.c:1435
hsm_key_bits_clause
db_clause_t * hsm_key_bits_clause(db_clause_list_t *clause_list, unsigned int bits)
Definition: hsm_key.c:777
hsm_key::backup
hsm_key_backup_t backup
Definition: hsm_key.h:93
hsm_key_inception
unsigned int hsm_key_inception(const hsm_key_t *hsm_key)
Definition: hsm_key.c:560
hsm_key_list::result
const db_result_t * result
Definition: hsm_key.h:437
hsm_key::policy_id
db_value_t policy_id
Definition: hsm_key.h:81
hsm_key_enum_set_role
const db_enum_t hsm_key_enum_set_role[]
Definition: hsm_key.c:44
hsm_key_algorithm
unsigned int hsm_key_algorithm(const hsm_key_t *hsm_key)
Definition: hsm_key.c:544
db_result_list
Definition: db_result.h:114
HSM_KEY_KEY_TYPE_RSA
Definition: hsm_key.h:59
db_value
Definition: db_value.h:48
hsm_key
Definition: hsm_key.h:77
hsm_key_key_type
hsm_key_key_type
Definition: hsm_key.h:57
hsm_key_list_new
hsm_key_list_t * hsm_key_list_new(const db_connection_t *connection)
Definition: hsm_key.c:1453
HSM_KEY_STATE_UNUSED
Definition: hsm_key.h:42
hsm_key_free
void hsm_key_free(hsm_key_t *hsm_key)
Definition: hsm_key.c:286
hsm_key_locator
const char * hsm_key_locator(const hsm_key_t *hsm_key)
Definition: hsm_key.c:520
hsm_key_state
hsm_key_state
Definition: hsm_key.h:40
hsm_key::algorithm
unsigned int algorithm
Definition: hsm_key.h:87
db_clause
Definition: db_clause.h:118
hsm_key_state_clause
db_clause_t * hsm_key_state_clause(db_clause_list_t *clause_list, hsm_key_state_t state)
Definition: hsm_key.c:756
hsm_key_get_by_id
int hsm_key_get_by_id(hsm_key_t *hsm_key, const db_value_t *id)
Definition: hsm_key.c:1102
hsm_key_list::object_list_size
size_t object_list_size
Definition: hsm_key.h:441
hsm_key_state_t
enum hsm_key_state hsm_key_state_t
hsm_key_ext.h
hsm_key::dbo
db_object_t * dbo
Definition: hsm_key.h:78
hsm_key_set_state
int hsm_key_set_state(hsm_key_t *hsm_key, hsm_key_state_t state)
Definition: hsm_key.c:625
hsm_key_algorithm_clause
db_clause_t * hsm_key_algorithm_clause(db_clause_list_t *clause_list, unsigned int algorithm)
Definition: hsm_key.c:798
hsm_key_list_get_next
hsm_key_t * hsm_key_list_get_next(hsm_key_list_t *hsm_key_list)
Definition: hsm_key.c:1990
hsm_key_set_bits
int hsm_key_set_bits(hsm_key_t *hsm_key, unsigned int bits)
Definition: hsm_key.c:638
hsm_key_list::policy_id_list
policy_list_t * policy_id_list
Definition: hsm_key.h:445
hsm_key_set_inception
int hsm_key_set_inception(hsm_key_t *hsm_key, unsigned int inception)
Definition: hsm_key.c:671
hsm_key_set_role
int hsm_key_set_role(hsm_key_t *hsm_key, hsm_key_role_t role)
Definition: hsm_key.c:658
hsm_key_id
const db_value_t * hsm_key_id(const hsm_key_t *hsm_key)
Definition: hsm_key.c:504
hsm_key_list::object_list_position
size_t object_list_position
Definition: hsm_key.h:442
policy.h
hsm_key_list
Definition: hsm_key.h:434
hsm_key_set_backup
int hsm_key_set_backup(hsm_key_t *hsm_key, hsm_key_backup_t backup)
Definition: hsm_key.c:716
HSM_KEY_ROLE_CSK
Definition: hsm_key.h:53
hsm_key_list_new_get_by_clauses
hsm_key_list_t * hsm_key_list_new_get_by_clauses(const db_connection_t *connection, const db_clause_list_t *clause_list)
Definition: hsm_key.c:1726
HSM_KEY_ROLE_INVALID
Definition: hsm_key.h:50
hsm_key_role_clause
db_clause_t * hsm_key_role_clause(db_clause_list_t *clause_list, hsm_key_role_t role)
Definition: hsm_key.c:819
hsm_key_enum_set_backup
const db_enum_t hsm_key_enum_set_backup[]
Definition: hsm_key.c:56
hsm_key_new
hsm_key_t * hsm_key_new(const db_connection_t *connection)
Definition: hsm_key.c:244
hsm_key_copy
int hsm_key_copy(hsm_key_t *hsm_key, const hsm_key_t *hsm_key_copy)
Definition: hsm_key.c:307
hsm_key::associated_policy_id
const policy_t * associated_policy_id
Definition: hsm_key.h:82
hsm_key_enum_set_state
const db_enum_t hsm_key_enum_set_state[]
Definition: hsm_key.c:36
HSM_KEY_BACKUP_BACKUP_REQUIRED
Definition: hsm_key.h:65
HSM_KEY_ROLE_KSK
Definition: hsm_key.h:51
hsm_key_is_revoked_clause
db_clause_t * hsm_key_is_revoked_clause(db_clause_list_t *clause_list, unsigned int is_revoked)
Definition: hsm_key.c:840
hsm_key_list_copy
int hsm_key_list_copy(hsm_key_list_t *hsm_key_list, const hsm_key_list_t *from_hsm_key_list)
Definition: hsm_key.c:1524
hsm_key_list::object_list
hsm_key_t ** object_list
Definition: hsm_key.h:440
hsm_key_policy_id
const db_value_t * hsm_key_policy_id(const hsm_key_t *hsm_key)
Definition: hsm_key.c:512
hsm_key_list::object_store
int object_store
Definition: hsm_key.h:439
hsm_key::private_policy_id
policy_t * private_policy_id
Definition: hsm_key.h:83
hsm_key_list_free
void hsm_key_list_free(hsm_key_list_t *hsm_key_list)
Definition: hsm_key.c:1496
db_result
Definition: db_result.h:56
hsm_key_bits
unsigned int hsm_key_bits(const hsm_key_t *hsm_key)
Definition: hsm_key.c:536
hsm_key_list_next
const hsm_key_t * hsm_key_list_next(hsm_key_list_t *hsm_key_list)
Definition: hsm_key.c:1924
hsm_key_list_get_by_clauses
int hsm_key_list_get_by_clauses(hsm_key_list_t *hsm_key_list, const db_clause_list_t *clause_list)
Definition: hsm_key.c:1684
hsm_key_list_get_by_policy_id
int hsm_key_list_get_by_policy_id(hsm_key_list_t *hsm_key_list, const db_value_t *policy_id)
Definition: hsm_key.c:1746
HSM_KEY_ROLE_ZSK
Definition: hsm_key.h:52
hsm_key_list::associated_fetch
int associated_fetch
Definition: hsm_key.h:444
hsm_key_list::object_list_first
int object_list_first
Definition: hsm_key.h:443
HSM_KEY_BACKUP_BACKUP_REQUESTED
Definition: hsm_key.h:66
hsm_key_list::result_list
db_result_list_t * result_list
Definition: hsm_key.h:436
hsm_key_role
hsm_key_role
Definition: hsm_key.h:49
hsm_key::repository
char * repository
Definition: hsm_key.h:92
HSM_KEY_KEY_TYPE_INVALID
Definition: hsm_key.h:58
hsm_key_repository
const char * hsm_key_repository(const hsm_key_t *hsm_key)
Definition: hsm_key.c:568
HSM_KEY_BACKUP_BACKUP_DONE
Definition: hsm_key.h:67
hsm_key_backup
hsm_key_backup
Definition: hsm_key.h:62
hsm_key::rev
db_value_t rev
Definition: hsm_key.h:80
hsm_key::inception
unsigned int inception
Definition: hsm_key.h:89
hsm_key_list_get_begin
hsm_key_t * hsm_key_list_get_begin(hsm_key_list_t *hsm_key_list)
Definition: hsm_key.c:1888
hsm_key_backup_clause
db_clause_t * hsm_key_backup_clause(db_clause_list_t *clause_list, hsm_key_backup_t backup)
Definition: hsm_key.c:906
db_object.h
HSM_KEY_BACKUP_NO_BACKUP
Definition: hsm_key.h:64
policy
Definition: policy.h:60
hsm_key::role
hsm_key_role_t role
Definition: hsm_key.h:88
db_connection
Definition: db_connection.h:46
db_enum
Definition: db_enum.h:38
hsm_key_from_result
int hsm_key_from_result(hsm_key_t *hsm_key, const db_result_t *result)
Definition: hsm_key.c:405
hsm_key_get_by_locator
int hsm_key_get_by_locator(hsm_key_t *hsm_key, const char *locator)
Definition: hsm_key.c:1155
hsm_key_set_repository
int hsm_key_set_repository(hsm_key_t *hsm_key, const char *repository_text)
Definition: hsm_key.c:694
hsm_key_list::hsm_key
hsm_key_t * hsm_key
Definition: hsm_key.h:438
hsm_key_set_locator
int hsm_key_set_locator(hsm_key_t *hsm_key, const char *locator_text)
Definition: hsm_key.c:603
hsm_key_policy_id_clause
db_clause_t * hsm_key_policy_id_clause(db_clause_list_t *clause_list, const db_value_t *policy_id)
Definition: hsm_key.c:729
hsm_key::id
db_value_t id
Definition: hsm_key.h:79
hsm_key::is_revoked
unsigned int is_revoked
Definition: hsm_key.h:90
HSM_KEY_BACKUP_INVALID
Definition: hsm_key.h:63
hsm_key_backup_t
enum hsm_key_backup hsm_key_backup_t
hsm_key_create
int hsm_key_create(hsm_key_t *hsm_key)
Definition: hsm_key.c:927
HSM_KEY_STATE_INVALID
Definition: hsm_key.h:41
hsm_key_new_copy
hsm_key_t * hsm_key_new_copy(const hsm_key_t *hsm_key)
Definition: hsm_key.c:267
HSM_KEY_STATE_SHARED
Definition: hsm_key.h:44
hsm_key_set_key_type
int hsm_key_set_key_type(hsm_key_t *hsm_key, hsm_key_key_type_t key_type)
Definition: hsm_key.c:681
hsm_key::key_type
hsm_key_key_type_t key_type
Definition: hsm_key.h:91
HSM_KEY_STATE_DELETE
Definition: hsm_key.h:45
hsm_key::state
hsm_key_state_t state
Definition: hsm_key.h:85
hsm_key_list::dbo
db_object_t * dbo
Definition: hsm_key.h:435
hsm_key_list_new_copy
hsm_key_list_t * hsm_key_list_new_copy(const hsm_key_list_t *hsm_key_copy)
Definition: hsm_key.c:1467
hsm_key::locator
char * locator
Definition: hsm_key.h:84
hsm_key_role_t
enum hsm_key_role hsm_key_role_t
hsm_key_set_policy_id
int hsm_key_set_policy_id(hsm_key_t *hsm_key, const db_value_t *policy_id)
Definition: hsm_key.c:584