hsm_key.h File Reference
`#include "db_object.h"`
`#include "hsm_key_ext.h"`
`#include "policy.h"`

Go to the source code of this file.

## Data Structures

struct | hsm_key
struct | hsm_key_list

## Typedefs

typedef struct hsm_key | hsm_key_t
typedef struct hsm_key_list | hsm_key_list_t
typedef enum hsm_key_state | hsm_key_state_t
typedef enum hsm_key_role | hsm_key_role_t
typedef enum hsm_key_key_type | hsm_key_key_type_t
typedef enum hsm_key_backup | hsm_key_backup_t

## Enumerations

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 }
enum | hsm_key_role { HSM_KEY_ROLE_INVALID = -1, HSM_KEY_ROLE_KSK = 1, HSM_KEY_ROLE_ZSK = 2, HSM_KEY_ROLE_CSK = 3 }
enum | hsm_key_key_type { HSM_KEY_KEY_TYPE_INVALID = -1, HSM_KEY_KEY_TYPE_RSA = 1 }
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 }

## Functions

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)
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)

## Variables

const db_enum_t | hsm_key_enum_set_state []
const db_enum_t | hsm_key_enum_set_role []
const db_enum_t | hsm_key_enum_set_backup []

## Typedef Documentation

## hsm_key_backup_t

typedef enum hsm_key_backup hsm_key_backup_t

## hsm_key_key_type_t

typedef enum hsm_key_key_type hsm_key_key_type_t

## hsm_key_list_t

typedef struct hsm_key_list hsm_key_list_t

Definition at line 38 of file hsm_key.h.

## hsm_key_role_t

typedef enum hsm_key_role hsm_key_role_t

## hsm_key_state_t

typedef enum hsm_key_state hsm_key_state_t

## hsm_key_t

typedef struct hsm_key hsm_key_t

Definition at line 37 of file hsm_key.h.

## Enumeration Type Documentation

## hsm_key_backup

enum hsm_key_backup

Enumerator
HSM_KEY_BACKUP_INVALID |
HSM_KEY_BACKUP_NO_BACKUP |
HSM_KEY_BACKUP_BACKUP_REQUIRED |
HSM_KEY_BACKUP_BACKUP_REQUESTED |
HSM_KEY_BACKUP_BACKUP_DONE |

Definition at line 62 of file hsm_key.h.

## hsm_key_key_type

enum hsm_key_key_type

Enumerator
HSM_KEY_KEY_TYPE_INVALID |
HSM_KEY_KEY_TYPE_RSA |

Definition at line 57 of file hsm_key.h.

## hsm_key_role

enum hsm_key_role

Enumerator
HSM_KEY_ROLE_INVALID |
HSM_KEY_ROLE_KSK |
HSM_KEY_ROLE_ZSK |
HSM_KEY_ROLE_CSK |

Definition at line 49 of file hsm_key.h.

## hsm_key_state

enum hsm_key_state

Enumerator
HSM_KEY_STATE_INVALID |
HSM_KEY_STATE_UNUSED |
HSM_KEY_STATE_PRIVATE |
HSM_KEY_STATE_SHARED |
HSM_KEY_STATE_DELETE |

Definition at line 40 of file hsm_key.h.

## Function Documentation

## hsm_key_algorithm()

unsigned int hsm_key_algorithm | ( | const hsm_key_t * | hsm_key | ) |

Get the algorithm of a hsm key object. Undefined behavior if `hsm_key` is NULL.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  an unsigned integer.

Definition at line 544 of file hsm_key.c.

References hsm_key::algorithm.

## hsm_key_algorithm_clause()

db_clause_t* hsm_key_algorithm_clause | ( | db_clause_list_t * | clause_list,
|  | unsigned int | algorithm
| ) |  |

Create a clause for algorithm of a hsm key object and add it to a database clause list. The clause operator is set to DB_CLAUSE_OPERATOR_AND and the clause type is set to DB_CLAUSE_EQUAL, if you want to change these you can do it with the returned db_clause_t pointer.

Parameters

  [in] | clause_list | db_clause_list_t pointer.
  [in] | algorithm | an unsigned integer.

Returns
  a db_clause_t pointer to the added clause or NULL on error.

Definition at line 798 of file hsm_key.c.

## hsm_key_backup()

hsm_key_backup_t hsm_key_backup | ( | const hsm_key_t * | hsm_key | ) |

Get the backup of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  a hsm_key_backup_t which may be HSM_KEY_BACKUP_INVALID on error or if no backup has been set.

Definition at line 576 of file hsm_key.c.

References hsm_key::backup, and HSM_KEY_BACKUP_INVALID.

## hsm_key_backup_clause()

db_clause_t* hsm_key_backup_clause | ( | db_clause_list_t * | clause_list,
|  | hsm_key_backup_t | backup
| ) |  |

Create a clause for backup of a hsm key object and add it to a database clause list. The clause operator is set to DB_CLAUSE_OPERATOR_AND and the clause type is set to DB_CLAUSE_EQUAL, if you want to change these you can do it with the returned db_clause_t pointer.

Parameters

  [in] | clause_list | db_clause_list_t pointer.
  [in] | backup | a hsm_key_backup_t.

Returns
  a db_clause_t pointer to the added clause or NULL on error.

Definition at line 906 of file hsm_key.c.

## hsm_key_bits()

unsigned int hsm_key_bits | ( | const hsm_key_t * | hsm_key | ) |

Get the bits of a hsm key object. Undefined behavior if `hsm_key` is NULL.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  an unsigned integer.

Definition at line 536 of file hsm_key.c.

References hsm_key::bits.

## hsm_key_bits_clause()

db_clause_t* hsm_key_bits_clause | ( | db_clause_list_t * | clause_list,
|  | unsigned int | bits
| ) |  |

Create a clause for bits of a hsm key object and add it to a database clause list. The clause operator is set to DB_CLAUSE_OPERATOR_AND and the clause type is set to DB_CLAUSE_EQUAL, if you want to change these you can do it with the returned db_clause_t pointer.

Parameters

  [in] | clause_list | db_clause_list_t pointer.
  [in] | bits | an unsigned integer.

Returns
  a db_clause_t pointer to the added clause or NULL on error.

Definition at line 777 of file hsm_key.c.

## hsm_key_copy()

int hsm_key_copy | ( | hsm_key_t * | hsm_key,
|  | const hsm_key_t * | hsm_key_copy
| ) |  |

Copy the content of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | hsm_key_copy | a hsm_key_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 307 of file hsm_key.c.

References hsm_key::algorithm, hsm_key::associated_policy_id, hsm_key::backup, hsm_key::bits, DB_ERROR_UNKNOWN, DB_OK, db_value_copy(), hsm_key::id, hsm_key::inception, hsm_key::is_revoked, hsm_key::key_type, hsm_key::locator, policy_free(), hsm_key::policy_id, policy_new_copy(), hsm_key::private_policy_id, hsm_key::repository, hsm_key::rev, hsm_key::role, and hsm_key::state.

Referenced by hsm_key_new_copy(), and key_data_get_hsm_key().

## hsm_key_count()

int hsm_key_count | ( | hsm_key_t * | hsm_key,
|  | db_clause_list_t * | clause_list,
|  | size_t * | count
| ) |  |

Count the number of hsm key objects in the database, if a selection of objects should be counted then it can be limited by a database clause list otherwise all objects are counted.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | clause_list | a db_clause_list_t pointer or NULL if all objects.
  [out] | count | a size_t pointer to where the count should be stored. should be counted.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 1435 of file hsm_key.c.

## hsm_key_create()

int hsm_key_create | ( | hsm_key_t * | hsm_key | ) |

Create a hsm key object in the database.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 927 of file hsm_key.c.

## hsm_key_free()

void hsm_key_free | ( | hsm_key_t * | hsm_key | ) |

Delete a hsm key object, this does not delete it from the database.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Definition at line 286 of file hsm_key.c.

References db_object_free(), db_value_reset(), hsm_key::dbo, hsm_key::id, hsm_key::locator, policy_free(), hsm_key::policy_id, hsm_key::private_policy_id, hsm_key::repository, and hsm_key::rev.

Referenced by hsm_key_list_copy(), hsm_key_list_free(), hsm_key_new_copy(), hsm_key_new_get_by_locator(), key_data_cache_hsm_key(), key_data_copy(), key_data_free(), and key_data_get_hsm_key().

## hsm_key_from_result()

int hsm_key_from_result | ( | hsm_key_t * | hsm_key,
|  | const db_result_t * | result
| ) |  |

Set the content of a hsm key object based on a database result.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | result | a db_result_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 405 of file hsm_key.c.

## hsm_key_get_by_id()

int hsm_key_get_by_id | ( | hsm_key_t * | hsm_key,
|  | const db_value_t * | id
| ) |  |

Get a hsm key object from the database by a id specified in `id`.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | id | a db_value_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 1102 of file hsm_key.c.

Referenced by key_data_cache_hsm_key(), and key_data_get_hsm_key().

## hsm_key_get_by_locator()

int hsm_key_get_by_locator | ( | hsm_key_t * | hsm_key,
|  | const char * | locator
| ) |  |

Get a hsm key object from the database by a locator specified in `locator`.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | locator | a character pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 1155 of file hsm_key.c.

Referenced by hsm_key_new_get_by_locator().

## hsm_key_id()

const db_value_t* hsm_key_id | ( | const hsm_key_t * | hsm_key | ) |

Get the id of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  a db_value_t pointer or NULL on error.

Definition at line 504 of file hsm_key.c.

References hsm_key::id.

Referenced by key_data_get_hsm_key().

## hsm_key_inception()

unsigned int hsm_key_inception | ( | const hsm_key_t * | hsm_key | ) |

Get the inception of a hsm key object. Undefined behavior if `hsm_key` is NULL.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  an unsigned integer.

Definition at line 560 of file hsm_key.c.

References hsm_key::inception.

## hsm_key_is_revoked_clause()

db_clause_t* hsm_key_is_revoked_clause | ( | db_clause_list_t * | clause_list,
|  | unsigned int | is_revoked
| ) |  |

Create a clause for is_revoked of a hsm key object and add it to a database clause list. The clause operator is set to DB_CLAUSE_OPERATOR_AND and the clause type is set to DB_CLAUSE_EQUAL, if you want to change these you can do it with the returned db_clause_t pointer.

Parameters

  [in] | clause_list | db_clause_list_t pointer.
  [in] | is_revoked | an unsigned integer.

Returns
  a db_clause_t pointer to the added clause or NULL on error.

Definition at line 840 of file hsm_key.c.

## 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
| ) |  |

Create a clause for key_type of a hsm key object and add it to a database clause list. The clause operator is set to DB_CLAUSE_OPERATOR_AND and the clause type is set to DB_CLAUSE_EQUAL, if you want to change these you can do it with the returned db_clause_t pointer.

Parameters

  [in] | clause_list | db_clause_list_t pointer.
  [in] | key_type | a hsm_key_key_type_t.

Returns
  a db_clause_t pointer to the added clause or NULL on error.

Definition at line 861 of file hsm_key.c.

## hsm_key_list_begin()

const hsm_key_t* hsm_key_list_begin | ( | hsm_key_list_t * | hsm_key_list | ) |

Get the first hsm key object in a hsm key object list and reset the position of the list.

Parameters

  [in] | hsm_key_list | a hsm_key_list_t pointer.

Returns
  a hsm_key_t pointer or NULL on error or if there are no hsm key objects in the hsm key object list.

Definition at line 1832 of file hsm_key.c.

## 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
| ) |  |

free global allocator. hsm_key_list_free MUST be called for all its contents. Copy the content of another hsm key object list.

Parameters

  [in] | hsm_key_list | a hsm_key_list_t pointer.
  [in] | from_hsm_key_list | a hsm_key_list_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 1524 of file hsm_key.c.

References hsm_key_list::associated_fetch, DB_ERROR_UNKNOWN, DB_OK, db_result_list_free(), db_result_list_new_copy(), hsm_key_free(), hsm_key_new_copy(), hsm_key_list::object_list, hsm_key_list::object_list_first, hsm_key_list::object_list_position, hsm_key_list::object_list_size, hsm_key_list::object_store, hsm_key_list::policy_id_list, policy_list_new_copy(), and hsm_key_list::result_list.

Referenced by hsm_key_list_new_copy().

## hsm_key_list_free()

void hsm_key_list_free | ( | hsm_key_list_t * | hsm_key_list | ) |

Delete a hsm key object list.

Parameters

  [in] | hsm_key_list | a hsm_key_list_t pointer.

Definition at line 1496 of file hsm_key.c.

References db_object_free(), db_result_list_free(), hsm_key_list::dbo, hsm_key_list::hsm_key, hsm_key_free(), hsm_key_list::object_list, hsm_key_list::object_list_size, hsm_key_list::policy_id_list, policy_list_free(), and hsm_key_list::result_list.

Referenced by hsm_key_list_new_copy(), hsm_key_list_new_get_by_policy_id(), key_data_list_free(), policy_copy(), and policy_free().

## hsm_key_list_get_begin()

hsm_key_t* hsm_key_list_get_begin | ( | hsm_key_list_t * | hsm_key_list | ) |

Get the first hsm key object in a hsm key object list and reset the position of the list. The caller will be given ownership of this object and is responsible for freeing it.

Parameters

  [in] | hsm_key_list | a hsm_key_list_t pointer.

Returns
  a hsm_key_t pointer or NULL on error or if there are no hsm key objects in the hsm key object list.

Definition at line 1888 of file hsm_key.c.

## 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
| ) |  |

Get hsm key objects from the database by a clause list.

Parameters

  [in] | hsm_key_list | a hsm_key_list_t pointer.
  [in] | clause_list | a db_clause_list_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 1684 of file hsm_key.c.

## 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
| ) |  |

Get hsm key objects from the database by a policy_id specified in `policy_id`.

Parameters

  [in] | hsm_key_list | a hsm_key_list_t pointer.
  [in] | policy_id | a db_value_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 1746 of file hsm_key.c.

Referenced by hsm_key_list_new_get_by_policy_id().

## hsm_key_list_get_next()

hsm_key_t* hsm_key_list_get_next | ( | hsm_key_list_t * | hsm_key_list | ) |

Get the next hsm key object in a hsm key object list. The caller will be given ownership of this object and is responsible for freeing it.

Parameters

  [in] | hsm_key_list | a hsm_key_list_t pointer.

Returns
  a hsm_key_t pointer or NULL on error or if there are no more hsm key objects in the hsm key object list.

Definition at line 1990 of file hsm_key.c.

## hsm_key_list_new()

hsm_key_list_t* hsm_key_list_new | ( | const db_connection_t * | connection | ) |

Create a new hsm key object list.

Parameters

  [in] | connection | a db_connection_t pointer.

Returns
  a hsm_key_list_t pointer or NULL on error.

Definition at line 1453 of file hsm_key.c.

References hsm_key_list::dbo.

Referenced by hsm_key_list_new_copy(), and hsm_key_list_new_get_by_policy_id().

## hsm_key_list_new_copy()

hsm_key_list_t* hsm_key_list_new_copy | ( | const hsm_key_list_t * | hsm_key_copy | ) |

Create a new hsm key object list that is a copy of another.

Parameters

  [in] | hsm_key_list | a hsm_key_list_t pointer.

Returns
  a hsm_key_list_t pointer or NULL on error.

Definition at line 1467 of file hsm_key.c.

References db_object_connection(), hsm_key_list::dbo, hsm_key_list_copy(), hsm_key_list_free(), and hsm_key_list_new().

Referenced by key_data_list_copy(), and policy_copy().

## 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
| ) |  |

Get a new list of hsm key objects from the database by a clause list.

Parameters

  [in] | connection | a db_connection_t pointer.
  [in] | clause_list | a db_clause_list_t pointer.

Returns
  a hsm_key_list_t pointer or NULL on error.

Definition at line 1726 of file hsm_key.c.

## 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
| ) |  |

Get a new list of hsm key objects from the database by a policy_id specified in `policy_id`.

Parameters

  [in] | connection | a db_connection_t pointer.
  [in] | policy_id | a db_value_t pointer.

Returns
  a hsm_key_list_t pointer or NULL on error.

Definition at line 1809 of file hsm_key.c.

References db_value_not_empty(), hsm_key_list_free(), hsm_key_list_get_by_policy_id(), and hsm_key_list_new().

## hsm_key_list_next()

const hsm_key_t* hsm_key_list_next | ( | hsm_key_list_t * | hsm_key_list | ) |

Get the next hsm key object in a hsm key object list. Ownership of this object is retained within the list and the object is only valid until the next call to this function.

Parameters

  [in] | hsm_key_list | a hsm_key_list_t pointer.

Returns
  a hsm_key_t pointer or NULL on error or if there are no more hsm key objects in the hsm key object list.

Definition at line 1924 of file hsm_key.c.

## hsm_key_list_object_store()

int hsm_key_list_object_store | ( | hsm_key_list_t * | hsm_key_list | ) |

Specify that objects should be stored within the list as they are fetch, this is optimal if the list is to be iterated over more then once.

Parameters

  [in] | hsm_key_list | a hsm_key_list_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 1486 of file hsm_key.c.

References DB_ERROR_UNKNOWN, DB_OK, and hsm_key_list::object_store.

## hsm_key_locator()

const char* hsm_key_locator | ( | const hsm_key_t * | hsm_key | ) |

Get the locator of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  a character pointer or NULL on error or if no locator has been set.

Definition at line 520 of file hsm_key.c.

References hsm_key::locator.

## hsm_key_new()

hsm_key_t* hsm_key_new | ( | const db_connection_t * | connection | ) |

Create a new hsm key object.

Parameters

  [in] | connection | a db_connection_t pointer.

Returns
  a hsm_key_t pointer or NULL on error.

Definition at line 244 of file hsm_key.c.

References hsm_key::dbo.

Referenced by hsm_key_new_copy(), hsm_key_new_get_by_locator(), key_data_cache_hsm_key(), and key_data_get_hsm_key().

## hsm_key_new_copy()

hsm_key_t* hsm_key_new_copy | ( | const hsm_key_t * | hsm_key | ) |

Create a new hsm key object that is a copy of another hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  a hsm_key_t pointer or NULL on error.

Definition at line 267 of file hsm_key.c.

References db_object_connection(), hsm_key::dbo, hsm_key_copy(), hsm_key_free(), and hsm_key_new().

Referenced by hsm_key_list_copy(), and key_data_copy().

## hsm_key_new_get_by_locator()

hsm_key_t* hsm_key_new_get_by_locator | ( | const db_connection_t * | connection,
|  | const char * | locator
| ) |  |

Get a new hsm key object from the database by a locator specified in `locator`.

Parameters

  [in] | connection | a db_connection_t pointer.
  [in] | locator | a character pointer.

Returns
  a hsm_key_t pointer or NULL on error or if it does not exist.

Definition at line 1205 of file hsm_key.c.

References hsm_key_free(), hsm_key_get_by_locator(), and hsm_key_new().

## hsm_key_policy_id()

const db_value_t* hsm_key_policy_id | ( | const hsm_key_t * | hsm_key | ) |

Get the policy_id of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  a db_value_t pointer or NULL on error.

Definition at line 512 of file hsm_key.c.

References hsm_key::policy_id.

## 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
| ) |  |

Create a clause for policy_id of a hsm key object and add it to a database clause list. The clause operator is set to DB_CLAUSE_OPERATOR_AND and the clause type is set to DB_CLAUSE_EQUAL, if you want to change these you can do it with the returned db_clause_t pointer.

Parameters

  [in] | clause_list | db_clause_list_t pointer.
  [in] | policy_id | a db_value_t pointer.

Returns
  a db_clause_t pointer to the added clause or NULL on error.

Definition at line 729 of file hsm_key.c.

## hsm_key_repository()

const char* hsm_key_repository | ( | const hsm_key_t * | hsm_key | ) |

Get the repository of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  a character pointer or NULL on error or if no repository has been set.

Definition at line 568 of file hsm_key.c.

References hsm_key::repository.

## hsm_key_repository_clause()

db_clause_t* hsm_key_repository_clause | ( | db_clause_list_t * | clause_list,
|  | const char * | repository_text
| ) |  |

Create a clause for repository of a hsm key object and add it to a database clause list. The clause operator is set to DB_CLAUSE_OPERATOR_AND and the clause type is set to DB_CLAUSE_EQUAL, if you want to change these you can do it with the returned db_clause_t pointer.

Parameters

  [in] | clause_list | db_clause_list_t pointer.
  [in] | repository_text | a character pointer.

Returns
  a db_clause_t pointer to the added clause or NULL on error.

Definition at line 882 of file hsm_key.c.

## hsm_key_role()

hsm_key_role_t hsm_key_role | ( | const hsm_key_t * | hsm_key | ) |

Get the role of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  a hsm_key_role_t which may be HSM_KEY_ROLE_INVALID on error or if no role has been set.

Definition at line 552 of file hsm_key.c.

References HSM_KEY_ROLE_INVALID, and hsm_key::role.

## hsm_key_role_clause()

db_clause_t* hsm_key_role_clause | ( | db_clause_list_t * | clause_list,
|  | hsm_key_role_t | role
| ) |  |

Create a clause for role of a hsm key object and add it to a database clause list. The clause operator is set to DB_CLAUSE_OPERATOR_AND and the clause type is set to DB_CLAUSE_EQUAL, if you want to change these you can do it with the returned db_clause_t pointer.

Parameters

  [in] | clause_list | db_clause_list_t pointer.
  [in] | role | a hsm_key_role_t.

Returns
  a db_clause_t pointer to the added clause or NULL on error.

Definition at line 819 of file hsm_key.c.

## hsm_key_set_algorithm()

int hsm_key_set_algorithm | ( | hsm_key_t * | hsm_key,
|  | unsigned int | algorithm
| ) |  |

Set the algorithm of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | algorithm | an unsigned integer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 648 of file hsm_key.c.

References hsm_key::algorithm, DB_ERROR_UNKNOWN, and DB_OK.

## hsm_key_set_backup()

int hsm_key_set_backup | ( | hsm_key_t * | hsm_key,
|  | hsm_key_backup_t | backup
| ) |  |

Set the backup of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | backup | a hsm_key_backup_t.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 716 of file hsm_key.c.

References hsm_key::backup, DB_ERROR_UNKNOWN, DB_OK, and HSM_KEY_BACKUP_INVALID.

## hsm_key_set_bits()

int hsm_key_set_bits | ( | hsm_key_t * | hsm_key,
|  | unsigned int | bits
| ) |  |

Set the bits of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | bits | an unsigned integer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 638 of file hsm_key.c.

References hsm_key::bits, DB_ERROR_UNKNOWN, and DB_OK.

## hsm_key_set_inception()

int hsm_key_set_inception | ( | hsm_key_t * | hsm_key,
|  | unsigned int | inception
| ) |  |

Set the inception of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | inception | an unsigned integer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 671 of file hsm_key.c.

References DB_ERROR_UNKNOWN, DB_OK, and hsm_key::inception.

## hsm_key_set_key_type()

int hsm_key_set_key_type | ( | hsm_key_t * | hsm_key,
|  | hsm_key_key_type_t | key_type
| ) |  |

Set the key_type of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | key_type | a hsm_key_key_type_t.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 681 of file hsm_key.c.

References DB_ERROR_UNKNOWN, DB_OK, HSM_KEY_KEY_TYPE_INVALID, and hsm_key::key_type.

## hsm_key_set_locator()

int hsm_key_set_locator | ( | hsm_key_t * | hsm_key,
|  | const char * | locator_text
| ) |  |

Set the locator of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | locator_text | a character pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 603 of file hsm_key.c.

References DB_ERROR_UNKNOWN, DB_OK, and hsm_key::locator.

## hsm_key_set_policy_id()

int hsm_key_set_policy_id | ( | hsm_key_t * | hsm_key,
|  | const db_value_t * | policy_id
| ) |  |

Set the policy_id of a hsm key object. If this fails the original value may have been lost.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | policy_id | a db_value_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 584 of file hsm_key.c.

References DB_ERROR_UNKNOWN, DB_OK, db_value_copy(), db_value_not_empty(), db_value_reset(), and hsm_key::policy_id.

## hsm_key_set_repository()

int hsm_key_set_repository | ( | hsm_key_t * | hsm_key,
|  | const char * | repository_text
| ) |  |

Set the repository of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | repository_text | a character pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 694 of file hsm_key.c.

References DB_ERROR_UNKNOWN, DB_OK, and hsm_key::repository.

## hsm_key_set_role()

int hsm_key_set_role | ( | hsm_key_t * | hsm_key,
|  | hsm_key_role_t | role
| ) |  |

Set the role of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | role | a hsm_key_role_t.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 658 of file hsm_key.c.

References DB_ERROR_UNKNOWN, DB_OK, HSM_KEY_ROLE_INVALID, and hsm_key::role.

## hsm_key_set_state()

int hsm_key_set_state | ( | hsm_key_t * | hsm_key,
|  | hsm_key_state_t | state
| ) |  |

Set the state of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.
  [in] | state | a hsm_key_state_t.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 625 of file hsm_key.c.

References DB_ERROR_UNKNOWN, DB_OK, HSM_KEY_STATE_INVALID, and hsm_key::state.

## hsm_key_state()

hsm_key_state_t hsm_key_state | ( | const hsm_key_t * | hsm_key | ) |

Get the state of a hsm key object.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  a hsm_key_state_t which may be HSM_KEY_STATE_INVALID on error or if no state has been set.

Definition at line 528 of file hsm_key.c.

References HSM_KEY_STATE_INVALID, and hsm_key::state.

## hsm_key_state_clause()

db_clause_t* hsm_key_state_clause | ( | db_clause_list_t * | clause_list,
|  | hsm_key_state_t | state
| ) |  |

Create a clause for state of a hsm key object and add it to a database clause list. The clause operator is set to DB_CLAUSE_OPERATOR_AND and the clause type is set to DB_CLAUSE_EQUAL, if you want to change these you can do it with the returned db_clause_t pointer.

Parameters

  [in] | clause_list | db_clause_list_t pointer.
  [in] | state | a hsm_key_state_t.

Returns
  a db_clause_t pointer to the added clause or NULL on error.

Definition at line 756 of file hsm_key.c.

## hsm_key_update()

int hsm_key_update | ( | hsm_key_t * | hsm_key | ) |

Update a hsm key object in the database.

Parameters

  [in] | hsm_key | a hsm_key_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 1225 of file hsm_key.c.

## Variable Documentation

## hsm_key_enum_set_backup

const db_enum_t hsm_key_enum_set_backup[]

Definition at line 56 of file hsm_key.c.

Referenced by hsm_key_to_backup_state().

## hsm_key_enum_set_role

const db_enum_t hsm_key_enum_set_role[]

Definition at line 44 of file hsm_key.c.

## hsm_key_enum_set_state

const db_enum_t hsm_key_enum_set_state[]

Definition at line 36 of file hsm_key.c.