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[];
#define HSM_KEY_ROLE_SEP(role) ((role) == HSM_KEY_ROLE_KSK || (role) == HSM_KEY_ROLE_CSK)
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;
};
extern hsm_key_t* hsm_key_new(const db_connection_t* connection);
extern hsm_key_t* hsm_key_new_copy(const hsm_key_t* hsm_key);
extern void hsm_key_free(hsm_key_t* hsm_key);
extern int hsm_key_copy(hsm_key_t* hsm_key, const hsm_key_t* hsm_key_copy);
extern int hsm_key_from_result(hsm_key_t* hsm_key, const db_result_t* result);
extern const db_value_t* hsm_key_id(const hsm_key_t* hsm_key);
extern const db_value_t* hsm_key_policy_id(const hsm_key_t* hsm_key);
extern const char* hsm_key_locator(const hsm_key_t* hsm_key);
extern hsm_key_state_t hsm_key_state(const hsm_key_t* hsm_key);
extern unsigned int hsm_key_bits(const hsm_key_t* hsm_key);
extern unsigned int hsm_key_algorithm(const hsm_key_t* hsm_key);
extern hsm_key_role_t hsm_key_role(const hsm_key_t* hsm_key);
extern unsigned int hsm_key_inception(const hsm_key_t* hsm_key);
extern const char* hsm_key_repository(const hsm_key_t* hsm_key);
extern hsm_key_backup_t hsm_key_backup(const hsm_key_t* hsm_key);
extern int hsm_key_set_policy_id(hsm_key_t* hsm_key, const db_value_t* policy_id);
extern int hsm_key_set_locator(hsm_key_t* hsm_key, const char* locator_text);
extern int hsm_key_set_state(hsm_key_t* hsm_key, hsm_key_state_t state);
extern int hsm_key_set_bits(hsm_key_t* hsm_key, unsigned int bits);
extern int hsm_key_set_algorithm(hsm_key_t* hsm_key, unsigned int algorithm);
extern int hsm_key_set_role(hsm_key_t* hsm_key, hsm_key_role_t role);
extern int hsm_key_set_inception(hsm_key_t* hsm_key, unsigned int inception);
extern int hsm_key_set_key_type(hsm_key_t* hsm_key, hsm_key_key_type_t key_type);
extern int hsm_key_set_repository(hsm_key_t* hsm_key, const char* repository_text);
extern int hsm_key_set_backup(hsm_key_t* hsm_key, hsm_key_backup_t backup);
extern db_clause_t* hsm_key_policy_id_clause(db_clause_list_t* clause_list, const db_value_t* policy_id);
extern db_clause_t* hsm_key_state_clause(db_clause_list_t* clause_list, hsm_key_state_t state);
extern db_clause_t* hsm_key_bits_clause(db_clause_list_t* clause_list, unsigned int bits);
extern db_clause_t* hsm_key_algorithm_clause(db_clause_list_t* clause_list, unsigned int algorithm);
extern db_clause_t* hsm_key_role_clause(db_clause_list_t* clause_list, hsm_key_role_t role);
extern db_clause_t* hsm_key_is_revoked_clause(db_clause_list_t* clause_list, unsigned int is_revoked);
extern db_clause_t* hsm_key_key_type_clause(db_clause_list_t* clause_list, hsm_key_key_type_t key_type);
extern db_clause_t* hsm_key_repository_clause(db_clause_list_t* clause_list, const char* repository_text);
extern db_clause_t* hsm_key_backup_clause(db_clause_list_t* clause_list, hsm_key_backup_t backup);
extern int hsm_key_create(hsm_key_t* hsm_key);
extern int hsm_key_get_by_id(hsm_key_t* hsm_key, const db_value_t* id);
extern int hsm_key_get_by_locator(hsm_key_t* hsm_key, const char* locator);
extern hsm_key_t* hsm_key_new_get_by_locator(const db_connection_t* connection, const char* locator);
extern int hsm_key_update(hsm_key_t* hsm_key);
extern 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;
};
extern hsm_key_list_t* hsm_key_list_new(const db_connection_t* connection);
extern hsm_key_list_t* hsm_key_list_new_copy(const hsm_key_list_t* hsm_key_copy);
extern int hsm_key_list_object_store(hsm_key_list_t* hsm_key_list);
extern void hsm_key_list_free(hsm_key_list_t* hsm_key_list);
extern int hsm_key_list_copy(hsm_key_list_t* hsm_key_list, const hsm_key_list_t* from_hsm_key_list);
extern int hsm_key_list_get_by_clauses(hsm_key_list_t* hsm_key_list, const db_clause_list_t* clause_list);
extern hsm_key_list_t* hsm_key_list_new_get_by_clauses(const db_connection_t* connection, const db_clause_list_t* clause_list);
extern int hsm_key_list_get_by_policy_id(hsm_key_list_t* hsm_key_list, const db_value_t* policy_id);
extern hsm_key_list_t* hsm_key_list_new_get_by_policy_id(const db_connection_t* connection, const db_value_t* policy_id);
extern const hsm_key_t* hsm_key_list_begin(hsm_key_list_t* hsm_key_list);
extern hsm_key_t* hsm_key_list_get_begin(hsm_key_list_t* hsm_key_list);
extern const hsm_key_t* hsm_key_list_next(hsm_key_list_t* hsm_key_list);
extern hsm_key_t* hsm_key_list_get_next(hsm_key_list_t* hsm_key_list);
#endif
db_object.h
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_free
void hsm_key_free(hsm_key_t *hsm_key)
Definition hsm_key.c:286
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_enum_set_role
const db_enum_t hsm_key_enum_set_role[]
Definition hsm_key.c:44
hsm_key_backup_t
enum hsm_key_backup hsm_key_backup_t
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_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_set_state
int hsm_key_set_state(hsm_key_t *hsm_key, hsm_key_state_t state)
Definition hsm_key.c:625
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_repository
const char * hsm_key_repository(const hsm_key_t *hsm_key)
Definition hsm_key.c:568
hsm_key_list_object_store
int hsm_key_list_object_store(hsm_key_list_t *hsm_key_list)
Definition hsm_key.c:1486
hsm_key_locator
const char * hsm_key_locator(const hsm_key_t *hsm_key)
Definition hsm_key.c:520
hsm_key_set_inception
int hsm_key_set_inception(hsm_key_t *hsm_key, unsigned int inception)
Definition hsm_key.c:671
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
hsm_key_new
hsm_key_t * hsm_key_new(const db_connection_t *connection)
Definition hsm_key.c:244
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_next
const hsm_key_t * hsm_key_list_next(hsm_key_list_t *hsm_key_list)
Definition hsm_key.c:1924
hsm_key_state_t
enum hsm_key_state hsm_key_state_t
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_update
int hsm_key_update(hsm_key_t *hsm_key)
Definition hsm_key.c:1225
hsm_key_role_t
enum hsm_key_role hsm_key_role_t
hsm_key_create
int hsm_key_create(hsm_key_t *hsm_key)
Definition hsm_key.c:927
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_list_free
void hsm_key_list_free(hsm_key_list_t *hsm_key_list)
Definition hsm_key.c:1496
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_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_state
hsm_key_state
Definition hsm_key.h:40
HSM_KEY_STATE_UNUSED
@ HSM_KEY_STATE_UNUSED
Definition hsm_key.h:42
HSM_KEY_STATE_INVALID
@ HSM_KEY_STATE_INVALID
Definition hsm_key.h:41
HSM_KEY_STATE_PRIVATE
@ HSM_KEY_STATE_PRIVATE
Definition hsm_key.h:43
HSM_KEY_STATE_SHARED
@ HSM_KEY_STATE_SHARED
Definition hsm_key.h:44
HSM_KEY_STATE_DELETE
@ HSM_KEY_STATE_DELETE
Definition hsm_key.h:45
hsm_key_algorithm
unsigned int hsm_key_algorithm(const hsm_key_t *hsm_key)
Definition hsm_key.c:544
hsm_key_enum_set_state
const db_enum_t hsm_key_enum_set_state[]
Definition hsm_key.c:36
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_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_backup
hsm_key_backup
Definition hsm_key.h:64
HSM_KEY_BACKUP_BACKUP_REQUESTED
@ HSM_KEY_BACKUP_BACKUP_REQUESTED
Definition hsm_key.h:68
HSM_KEY_BACKUP_NO_BACKUP
@ HSM_KEY_BACKUP_NO_BACKUP
Definition hsm_key.h:66
HSM_KEY_BACKUP_INVALID
@ HSM_KEY_BACKUP_INVALID
Definition hsm_key.h:65
HSM_KEY_BACKUP_BACKUP_DONE
@ HSM_KEY_BACKUP_BACKUP_DONE
Definition hsm_key.h:69
HSM_KEY_BACKUP_BACKUP_REQUIRED
@ HSM_KEY_BACKUP_BACKUP_REQUIRED
Definition hsm_key.h:67
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_new
hsm_key_list_t * hsm_key_list_new(const db_connection_t *connection)
Definition hsm_key.c:1453
hsm_key_key_type_t
enum hsm_key_key_type hsm_key_key_type_t
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
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_bits
unsigned int hsm_key_bits(const hsm_key_t *hsm_key)
Definition hsm_key.c:536
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_from_result
int hsm_key_from_result(hsm_key_t *hsm_key, const db_result_t *result)
Definition hsm_key.c:405
hsm_key_role
hsm_key_role
Definition hsm_key.h:49
HSM_KEY_ROLE_INVALID
@ HSM_KEY_ROLE_INVALID
Definition hsm_key.h:50
HSM_KEY_ROLE_KSK
@ HSM_KEY_ROLE_KSK
Definition hsm_key.h:51
HSM_KEY_ROLE_ZSK
@ HSM_KEY_ROLE_ZSK
Definition hsm_key.h:52
HSM_KEY_ROLE_CSK
@ HSM_KEY_ROLE_CSK
Definition hsm_key.h:53
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_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_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_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
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_new_copy
hsm_key_t * hsm_key_new_copy(const hsm_key_t *hsm_key)
Definition hsm_key.c:267
hsm_key_inception
unsigned int hsm_key_inception(const hsm_key_t *hsm_key)
Definition hsm_key.c:560
hsm_key_id
const db_value_t * hsm_key_id(const hsm_key_t *hsm_key)
Definition hsm_key.c:504
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_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_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_enum_set_backup
const db_enum_t hsm_key_enum_set_backup[]
Definition hsm_key.c:56
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_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_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_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_key_type
hsm_key_key_type
Definition hsm_key.h:59
HSM_KEY_KEY_TYPE_RSA
@ HSM_KEY_KEY_TYPE_RSA
Definition hsm_key.h:61
HSM_KEY_KEY_TYPE_INVALID
@ HSM_KEY_KEY_TYPE_INVALID
Definition hsm_key.h:60
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_set_locator
int hsm_key_set_locator(hsm_key_t *hsm_key, const char *locator_text)
Definition hsm_key.c:603
hsm_key_set_algorithm
int hsm_key_set_algorithm(hsm_key_t *hsm_key, unsigned int algorithm)
Definition hsm_key.c:648
hsm_key_ext.h
policy_id
const db_value_t * policy_id(const policy_t *policy)
Definition policy.c:805
policy.h
db_clause_list
Definition db_clause.h:226
db_clause
Definition db_clause.h:118
db_connection
Definition db_connection.h:46
db_enum
Definition db_enum.h:38
db_object
Definition db_object.h:201
db_result_list
Definition db_result.h:114
db_result
Definition db_result.h:56
db_value
Definition db_value.h:48
hsm_key_list
Definition hsm_key.h:436
hsm_key_list::object_list_position
size_t object_list_position
Definition hsm_key.h:444
hsm_key_list::object_store
int object_store
Definition hsm_key.h:441
hsm_key_list::result
const db_result_t * result
Definition hsm_key.h:439
hsm_key_list::associated_fetch
int associated_fetch
Definition hsm_key.h:446
hsm_key_list::hsm_key
hsm_key_t * hsm_key
Definition hsm_key.h:440
hsm_key_list::policy_id_list
policy_list_t * policy_id_list
Definition hsm_key.h:447
hsm_key_list::result_list
db_result_list_t * result_list
Definition hsm_key.h:438
hsm_key_list::object_list
hsm_key_t ** object_list
Definition hsm_key.h:442
hsm_key_list::object_list_first
int object_list_first
Definition hsm_key.h:445
hsm_key_list::object_list_size
size_t object_list_size
Definition hsm_key.h:443
hsm_key_list::dbo
db_object_t * dbo
Definition hsm_key.h:437
hsm_key
Definition hsm_key.h:79
hsm_key::backup
hsm_key_backup_t backup
Definition hsm_key.h:95
hsm_key::state
hsm_key_state_t state
Definition hsm_key.h:87
hsm_key::associated_policy_id
const policy_t * associated_policy_id
Definition hsm_key.h:84
hsm_key::inception
unsigned int inception
Definition hsm_key.h:91
hsm_key::key_type
hsm_key_key_type_t key_type
Definition hsm_key.h:93
hsm_key::locator
char * locator
Definition hsm_key.h:86
hsm_key::policy_id
db_value_t policy_id
Definition hsm_key.h:83
hsm_key::rev
db_value_t rev
Definition hsm_key.h:82
hsm_key::bits
unsigned int bits
Definition hsm_key.h:88
hsm_key::repository
char * repository
Definition hsm_key.h:94
hsm_key::private_policy_id
policy_t * private_policy_id
Definition hsm_key.h:85
hsm_key::id
db_value_t id
Definition hsm_key.h:81
hsm_key::dbo
db_object_t * dbo
Definition hsm_key.h:80
hsm_key::is_revoked
unsigned int is_revoked
Definition hsm_key.h:92
hsm_key::role
hsm_key_role_t role
Definition hsm_key.h:90
hsm_key::algorithm
unsigned int algorithm
Definition hsm_key.h:89
policy_list
Definition policy.h:733
policy
Definition policy.h:60