OpenDNSSEC-libhsm
1.4.7
|
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <termios.h>
#include <errno.h>
#include "libhsm.h"
Go to the source code of this file.
Data Structures | |
union | semun |
Macros | |
#define | SHM_KEY (key_t)0x0d50d5ec |
#define | SEM_KEY (key_t)0x0d50d5ec |
#define | SHM_PERM S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP |
#define | SEM_PERM S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP |
Functions | |
void | hsm_ctx_set_error (hsm_ctx_t *ctx, int error, const char *action, const char *message,...) |
char * | prompt_pass (char *prompt) |
int | hsm_sem_open () |
int | hsm_sem_wait (int semid) |
int | hsm_sem_post (int semid) |
int | hsm_shm_open () |
char * | hsm_prompt_pin (unsigned int id, const char *repository, unsigned int mode) |
char * | hsm_check_pin (unsigned int id, const char *repository, unsigned int mode) |
int | hsm_logout_pin () |
Variables | |
hsm_ctx_t * | _hsm_ctx |
#define SEM_KEY (key_t)0x0d50d5ec |
Definition at line 52 of file pin.c.
Referenced by hsm_logout_pin(), and hsm_sem_open().
#define SEM_PERM S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP |
Definition at line 54 of file pin.c.
Referenced by hsm_sem_open().
#define SHM_KEY (key_t)0x0d50d5ec |
Definition at line 51 of file pin.c.
Referenced by hsm_logout_pin(), and hsm_shm_open().
#define SHM_PERM S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP |
Definition at line 53 of file pin.c.
Referenced by hsm_shm_open().
char* hsm_check_pin | ( | unsigned int | id, |
const char * | repository, | ||
unsigned int | mode | ||
) |
Function that will check if there is a PIN in the shared memory and returns it.
id | Used for identifying the repository. Will have a value between zero and HSM_MAX_SESSIONS. |
repository | The repository name will be included in the prompt |
mode | The type of mode the function should run in. |
Definition at line 325 of file pin.c.
References hsm_ctx_set_error(), HSM_ERROR, HSM_MAX_PIN_LENGTH, HSM_MAX_SESSIONS, HSM_PIN_FIRST, HSM_PIN_RETRY, HSM_PIN_SAVE, hsm_sem_open(), hsm_sem_post(), hsm_sem_wait(), and hsm_shm_open().
void hsm_ctx_set_error | ( | hsm_ctx_t * | ctx, |
int | error, | ||
const char * | action, | ||
const char * | message, | ||
... | |||
) |
Set HSM Context Error
If the ctx is given, and it's error value is still 0, the value will be set to 'error', and the error_message and error_action will be set to the given strings.
ctx | HSM context |
error | error code |
action | action for which the error occured |
message | error message format string |
Definition at line 210 of file libhsm.c.
References hsm_ctx_t::error, hsm_ctx_t::error_action, and hsm_ctx_t::error_message.
Referenced by hsm_check_context(), hsm_check_pin(), hsm_get_dnskey(), hsm_get_slot_id(), hsm_logout_pin(), hsm_nsec3_hash_name(), hsm_open(), hsm_sem_open(), hsm_sem_post(), hsm_sem_wait(), hsm_shm_open(), and hsm_token_attached().
int hsm_logout_pin | ( | ) |
Logout
Function that will logout the user by deleting the shared memory and semaphore. Any authenticated process will still be able to interact with the HSM.
Definition at line 413 of file pin.c.
References hsm_ctx_set_error(), HSM_ERROR, HSM_OK, SEM_KEY, and SHM_KEY.
Referenced by cmd_logout().
char* hsm_prompt_pin | ( | unsigned int | id, |
const char * | repository, | ||
unsigned int | mode | ||
) |
Function that queries for a PIN, can be used as callback for hsm_open(). Stores the PIN in the shared memory.
id | Used for identifying the repository. Will have a value between zero and HSM_MAX_SESSIONS. |
repository | The repository name will be included in the prompt |
mode | The type of mode the function should run in. |
Definition at line 228 of file pin.c.
References HSM_MAX_PIN_LENGTH, HSM_MAX_SESSIONS, HSM_PIN_FIRST, HSM_PIN_RETRY, HSM_PIN_SAVE, hsm_sem_open(), hsm_sem_post(), hsm_sem_wait(), hsm_shm_open(), and prompt_pass().
Referenced by main().
int hsm_sem_open | ( | ) |
Definition at line 105 of file pin.c.
References semun::buf, hsm_ctx_set_error(), HSM_ERROR, SEM_KEY, SEM_PERM, and semun::val.
Referenced by hsm_check_pin(), and hsm_prompt_pin().
int hsm_sem_post | ( | int | semid | ) |
Definition at line 165 of file pin.c.
References hsm_ctx_set_error(), and HSM_ERROR.
Referenced by hsm_check_pin(), and hsm_prompt_pin().
int hsm_sem_wait | ( | int | semid | ) |
Definition at line 151 of file pin.c.
References hsm_ctx_set_error(), and HSM_ERROR.
Referenced by hsm_check_pin(), and hsm_prompt_pin().
int hsm_shm_open | ( | ) |
Definition at line 179 of file pin.c.
References hsm_ctx_set_error(), HSM_ERROR, HSM_MAX_PIN_LENGTH, HSM_MAX_SESSIONS, SHM_KEY, and SHM_PERM.
Referenced by hsm_check_pin(), and hsm_prompt_pin().
char* prompt_pass | ( | char * | prompt | ) |
hsm_ctx_t* _hsm_ctx |
Global (initial) context
Definition at line 53 of file libhsm.c.
Referenced by hsm_check_context(), hsm_count_keys(), hsm_count_keys_repository(), hsm_generate_dsa_key(), hsm_generate_gost_key(), hsm_generate_rsa_key(), hsm_get_dnskey(), hsm_get_error(), hsm_get_key_id(), hsm_get_key_info(), hsm_list_keys(), hsm_list_keys_repository(), hsm_nsec3_hash_name(), hsm_print_ctx(), hsm_print_tokeninfo(), hsm_random_buffer(), hsm_remove_key(), hsm_sign_rrset(), and hsm_token_attached().