EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
Functions
generic_hsm_driver.c File Reference

File containing the implementation of generic HSM driver configuration utilities. More...

#include <sys/types.h>
#include "generic_hsm_driver.h"
#include "../utils/allocs.h"
#include "../utils/log.h"
#include "../utils/os.h"
Include dependency graph for generic_hsm_driver.c:

Functions

struct hsm_contextinit_hsm (void)
 Initialises an HSM context. More...
 
int close_hsm (struct hsm_context *context)
 Closes the HSM context. More...
 
int generate_hsm_key (struct hsm_context *context, uint8_t *key, size_t key_size)
 Generate an HSM key. More...
 
int encrypt_hsm_blob (struct hsm_context *context, uint8_t *in, size_t in_size, uint8_t **out, size_t *out_size)
 Encrypt a byte array wiht the HSM. More...
 
int decrypt_hsm_blob (struct hsm_context *context, uint8_t *in, size_t in_size, uint8_t **out, size_t *out_size)
 Decrypt a byte array wiht the HSM. More...
 

Detailed Description

File containing the implementation of generic HSM driver configuration utilities.

Author
Alexandru Mereacre
Date
2021

Function Documentation

◆ close_hsm()

int close_hsm ( struct hsm_context context)

Closes the HSM context.

Parameters
contextTje HSM context
Returns
int 0 on success, -1 on failure

◆ decrypt_hsm_blob()

int decrypt_hsm_blob ( struct hsm_context context,
uint8_t *  in,
size_t  in_size,
uint8_t **  out,
size_t *  out_size 
)

Decrypt a byte array wiht the HSM.

Parameters
contextThe HSM context
inThe input array
in_sizeThe input array size
outThe output decrypted array
out_sizeThe output array size
Returns
int 0 on success, -1 on failure

◆ encrypt_hsm_blob()

int encrypt_hsm_blob ( struct hsm_context context,
uint8_t *  in,
size_t  in_size,
uint8_t **  out,
size_t *  out_size 
)

Encrypt a byte array wiht the HSM.

Parameters
contextThe HSM context
inThe input array
in_sizeThe input array size
outThe output encrypted array
out_sizeThe output array size
Returns
int 0 on success, -1 on failure

◆ generate_hsm_key()

int generate_hsm_key ( struct hsm_context context,
uint8_t *  key,
size_t  key_size 
)

Generate an HSM key.

Parameters
contextThe HSM context
keyThe returned key
key_sizeThe key size
Returns
int 0 on success, -1 on failure

◆ init_hsm()

struct hsm_context* init_hsm ( void  )

Initialises an HSM context.

Returns
struct hsm_context* The returned context, NULL on error