Wire Sysio Wire Sysion 1.0.0
|
#include <yubihsm.h>
#include "internal.h"
#include <arpa/inet.h>
#include <dlfcn.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include <limits.h>
#include "../common/rand.h"
#include "../common/pkcs5.h"
#include "../common/hash.h"
#include "../aes_cmac/aes_cmac.h"
#include "debug_lib.h"
#include "../common/insecure_memzero.h"
Go to the source code of this file.
Macros | |
#define | STATIC_USB_BACKEND "usb" |
#define | STATIC_HTTP_BACKEND "http" |
#define | LIST_SEPARATORS ":,;|" |
#define | LIST_ID 1 |
#define | LIST_TYPE 2 |
#define | LIST_DOMAINS 3 |
#define | LIST_CAPABILITIES 4 |
#define | LIST_ALGORITHM 5 |
#define | LIST_LABEL 6 |
#define | STATUS_ENDPOINT "/connector/status" |
#define | API_ENDPOINT "/connector/api" |
#define | USB_LIB "libyubihsm_usb.so." SOVERSION |
#define | HTTP_LIB "libyubihsm_http.so." SOVERSION |
#define | htonll(x) |
Variables | |
uint8_t _yh_verbosity | YH_INTERNAL = 0 |
#define htonll | ( | x | ) |
#define HTTP_LIB "libyubihsm_http.so." SOVERSION |
#define USB_LIB "libyubihsm_usb.so." SOVERSION |
yh_rc yh_algo_to_string | ( | yh_algorithm | algo, |
char const ** | result ) |
Convert an algorithm to its string representation.
algo | Algorithm to convert. See yh_algorithm |
result | The algorithm as a String. "Unknown" if the algorithm is not supported by YubiHSM 2. |
result
is NULL.Definition at line 4384 of file yubihsm.c.
yh_rc yh_authenticate_session | ( | yh_session * | session | ) |
Authenticate session
session | Session to authenticate |
Definition at line 2927 of file yubihsm.c.
yh_rc yh_begin_create_session_ext | ( | yh_connector * | connector, |
uint16_t | authkey_id, | ||
uint8_t ** | context, | ||
uint8_t * | card_cryptogram, | ||
size_t | card_cryptogram_len, | ||
yh_session ** | session ) |
Begin creating an external session. The session's encryption key and MAC key are not stored in the device.
This function must be followed by yh_finish_create_session_ext() to set the session keys.
connector | Connector to the device |
authkey_id | Object ID of the Authentication Key used to authenticate the session |
context | pointer to where context data is saved |
card_cryptogram | Card cryptogram |
card_cryptogram_len | Length of card cryptogram |
session | created session |
Definition at line 751 of file yubihsm.c.
yh_rc yh_capabilities_to_strings | ( | const yh_capabilities * | num, |
const char * | result[], | ||
size_t * | n_result ) |
Convert an array of yh_capabilities into strings separated by ','
num | Array of yh_capabilities |
result | Array of the capabilies as strings |
n_result | Number of elements in result |
n_result
is too smallDefinition at line 4168 of file yubihsm.c.
bool yh_check_capability | ( | const yh_capabilities * | capabilities, |
const char * | capability ) |
Check if a capability is set
capabilities | Array of yh_capabilities |
capability | Capability to check as a string. |
capability
is in capabilities
. False otherwisechar *capabilities_str = "sign-pkcs,decrypt-pkcs,set-option"; yh_capabilities capabilities = {{0}}; yh_string_to_capabilities(capabilities_str, &capabilities); //yh_check_capability(&capabilities, "something") => false //yh_check_capability(&capabilities, "sign-pss") => false //yh_check_capability(&capabilities, "decrypt-pkcs") => true
Definition at line 4198 of file yubihsm.c.
yh_rc yh_connect | ( | yh_connector * | connector, |
int | timeout ) |
Connect to the device through the specified connector
connector | Connector to the device |
timeout | Connection timeout in seconds |
Definition at line 4079 of file yubihsm.c.
bool yh_connector_has_device | ( | yh_connector * | connector | ) |
yh_rc yh_create_session | ( | yh_connector * | connector, |
uint16_t | authkey_id, | ||
const uint8_t * | key_enc, | ||
size_t | key_enc_len, | ||
const uint8_t * | key_mac, | ||
size_t | key_mac_len, | ||
bool | recreate_session, | ||
yh_session ** | session ) |
Create a session that uses the specified encryption key and MAC key to derive session-specific keys
connector | Connector to the device |
authkey_id | Object ID of the Authentication Key used to authenticate the session |
key_enc | Encryption key used to derive the session encryption key |
key_enc_len | Length of the encryption key. |
key_mac | MAC key used to derive the session MAC key |
key_mac_len | Length of the MAC key. |
recreate_session | If true, the session will be recreated if expired. This caches the password in memory |
session | created session |
Definition at line 616 of file yubihsm.c.
yh_rc yh_create_session_derived | ( | yh_connector * | connector, |
uint16_t | authkey_id, | ||
const uint8_t * | password, | ||
size_t | password_len, | ||
bool | recreate_session, | ||
yh_session ** | session ) |
Create a session that uses an encryption key and a MAC key derived from a password
connector | Connector to the device |
authkey_id | Object ID of the Authentication Key used to authenticate the session |
password | Password used to derive the session encryption key and MAC key |
password_len | Length of the password in bytes |
recreate_session | If true, the session will be recreated if expired. This caches the password in memory |
session | The created session |
Definition at line 593 of file yubihsm.c.
yh_rc yh_destroy_session | ( | yh_session ** | session | ) |
Free data associated with the session
session | Pointer to the session to destroy |
Definition at line 890 of file yubihsm.c.
yh_rc yh_disconnect | ( | yh_connector * | connector | ) |
Disconnect from a connector
connector | Connector from which to disconnect |
Definition at line 4097 of file yubihsm.c.
Convert domains parameter to its String representation
domains | Encoded domains |
string | Domains as a string |
max_len | Maximum length of the string |
max_len
is too smallDefinition at line 4587 of file yubihsm.c.
yh_rc yh_exit | ( | void | ) |
Global library clean up
Definition at line 3910 of file yubihsm.c.
yh_rc yh_filter_capabilities | ( | const yh_capabilities * | capabilities, |
const yh_capabilities * | filter, | ||
yh_capabilities * | result ) |
Filter one set of capabilities with another. The resulting set of capabilities contains only the capabilities that exist in both sets of input capabilities
capabilities | Array of yh_capabilities |
filter | Array of yh_capabilities |
result | Resulting array of yh_capabilities |
Definition at line 4231 of file yubihsm.c.
yh_rc yh_finish_create_session_ext | ( | yh_connector * | connector, |
yh_session * | session, | ||
const uint8_t * | key_senc, | ||
size_t | key_senc_len, | ||
const uint8_t * | key_smac, | ||
size_t | key_smac_len, | ||
const uint8_t * | key_srmac, | ||
size_t | key_srmac_len, | ||
uint8_t * | card_cryptogram, | ||
size_t | card_cryptogram_len ) |
Finish creating external session. The session's encryption key and MAC key are not stored in the device.
This function must be called after yh_begin_create_session_ext().
connector | Connector to the device |
session | The session created with yh_begin_create_session_ext() |
key_senc | Session encryption key used to encrypt the messages exchanged with the device |
key_senc_len | Lenght of the encryption key. Must be YH_KEY_LEN |
key_smac | Session MAC key used for creating the authentication tag for each message |
key_smac_len | Length of the MAC key. Must be YH_KEY_LEN |
key_srmac | Session return MAC key used for creating the authentication tag for each response message |
key_srmac_len | Length of the return MAC key. Must be YH_KEY_LEN |
card_cryptogram | Card cryptogram |
card_cryptogram_len | Length of card cryptogram |
Definition at line 847 of file yubihsm.c.
yh_rc yh_get_connector_address | ( | yh_connector * | connector, |
char **const | address ) |
Get connector address
connector | Connector currently in use |
address | Pointer to the connector address as string |
Definition at line 926 of file yubihsm.c.
yh_rc yh_get_connector_version | ( | yh_connector * | connector, |
uint8_t * | major, | ||
uint8_t * | minor, | ||
uint8_t * | patch ) |
Get the connector version
connector | Connector currently in use |
major | Connector major version |
minor | Connector minor version |
patch | Connector patch version |
Definition at line 911 of file yubihsm.c.
yh_rc yh_get_key_bitlength | ( | yh_algorithm | algorithm, |
size_t * | result ) |
Get the expected key length of a key generated by the given algorithm
algorithm | Algorithm to check. See yh_algorithm |
result | Expected bitlength of a key generated by the algorithm |
result
is NULL or if the algorithm is no supported by YubiHSM 2. For a list of supported algorithms, see yh_algorithm Definition at line 4309 of file yubihsm.c.
yh_rc yh_get_session_id | ( | yh_session * | session, |
uint8_t * | sid ) |
Get the session ID
session | Authenticated session to use |
sid | Session ID |
Definition at line 2915 of file yubihsm.c.
Get verbosity level when executing commands
verbosity | The verbosity level |
Definition at line 3837 of file yubihsm.c.
yh_rc yh_init | ( | void | ) |
Global library initialization
Definition at line 3857 of file yubihsm.c.
yh_rc yh_init_connector | ( | const char * | url, |
yh_connector ** | connector ) |
Instantiate a new connector
url | URL associated with this connector |
connector | Connector to the device |
Definition at line 4024 of file yubihsm.c.
bool yh_is_ec | ( | yh_algorithm | algorithm | ) |
Check if an algorithm is a supported Elliptic Curve algorithm.
Supported EC algorithms: YH_ALGO_EC_P224, YH_ALGO_EC_P256, YH_ALGO_EC_P384, YH_ALGO_EC_P521, YH_ALGO_EC_K256, YH_ALGO_EC_BP256, YH_ALGO_EC_BP384 and YH_ALGO_EC_BP512
algorithm | Algorithm to check. See yh_algorithm |
Definition at line 4260 of file yubihsm.c.
bool yh_is_ed | ( | yh_algorithm | algorithm | ) |
Check if an algorithm is a supported ED algorithm.
Supported ED algorithms: YH_ALGO_EC_ED25519
algorithm | algorithm. See yh_algorithm |
Definition at line 4280 of file yubihsm.c.
bool yh_is_hmac | ( | yh_algorithm | algorithm | ) |
Check if algorithm is a supported HMAC algorithm.
Supported HMAC algorithms: YH_ALGO_HMAC_SHA1, YH_ALGO_HMAC_SHA256, YH_ALGO_HMAC_SHA384 and YH_ALGO_HMAC_SHA512
algorithm | Algorithm to check. See yh_algorithm |
Definition at line 4293 of file yubihsm.c.
bool yh_is_rsa | ( | yh_algorithm | algorithm | ) |
Check if an algorithm is a supported RSA algorithm.
Supported RSA algorithms: YH_ALGO_RSA_2048, YH_ALGO_RSA_3072 and YH_ALGO_RSA_4096
algorithm | Algorithm to check. See yh_algorithm |
Definition at line 4245 of file yubihsm.c.
yh_rc yh_merge_capabilities | ( | const yh_capabilities * | a, |
const yh_capabilities * | b, | ||
yh_capabilities * | result ) |
Merge two sets of capabilities. The resulting set of capabilities contain all capabilities from both arrays
a | Array of yh_capabilities |
b | Array of yh_capabilities |
result | Resulting array of yh_capabilities |
Definition at line 4219 of file yubihsm.c.
yh_rc yh_send_plain_msg | ( | yh_connector * | connector, |
yh_cmd | cmd, | ||
const uint8_t * | data, | ||
size_t | data_len, | ||
yh_cmd * | response_cmd, | ||
uint8_t * | response, | ||
size_t * | response_len ) |
Send a plain (unencrypted) message to the device through a connector
connector | Connector to the device |
cmd | Command to send. See yh_cmd |
data | Data to send |
data_len | length of data to send |
response_cmd | Response command |
response | Response data |
response_len | Length of response data |
Definition at line 126 of file yubihsm.c.
yh_rc yh_send_secure_msg | ( | yh_session * | session, |
yh_cmd | cmd, | ||
const uint8_t * | data, | ||
size_t | data_len, | ||
yh_cmd * | response_cmd, | ||
uint8_t * | response, | ||
size_t * | response_len ) |
Send an encrypted message to the device over a session. The session has to be authenticated
session | Session to send the message over |
cmd | Command to send |
data | Data to send |
data_len | Length of data to send |
response_cmd | Response command |
response | Response data |
response_len | Length of response data |
Definition at line 416 of file yubihsm.c.
yh_rc yh_set_connector_option | ( | yh_connector * | connector, |
yh_connector_option | opt, | ||
const void * | val ) |
Set connector options.
Note that backend options are not supported with winhttp or USB connectors
connector | Connector to set an option on |
opt | Option to set. See yh_connector_option |
val | Value of the option. Type of value is specific to the given option |
Definition at line 4063 of file yubihsm.c.
void yh_set_debug_output | ( | yh_connector * | connector, |
FILE * | output ) |
Set file for debug output
connector | If not NULL, the debug messages will be written to the specified output file |
output | The destination of the debug messages |
Definition at line 3848 of file yubihsm.c.
yh_rc yh_set_verbosity | ( | yh_connector * | connector, |
uint8_t | verbosity ) |
Set verbosity level when executing commands. Default verbosity is YH_VERB_QUIET
This function may be called prior to global library initialization to set the debug level
connector | If not NULL, the verbosity of the specific connector will be set |
verbosity | The desired level of debug output |
Definition at line 3825 of file yubihsm.c.
yh_rc yh_string_to_algo | ( | const char * | string, |
yh_algorithm * | algo ) |
Convert a string to an algorithm's numeric value
string | Algorithm as string. See yh_algorithm |
algo | Algorithm numeric value |
yh_algorithm algorithm; //yh_string_to_algo(NULL, &algorithm) => YHR_INVALID_PARAMETERS //yh_string_to_algo("something", NULL) => YHR_INVALID_PARAMETERS //yh_string_to_algo("something", &algorithm) => YHR_INVALID_PARAMETERS //yh_string_to_algo("rsa-pkcs1-sha1", &algorithm) =>YH_ALGO_RSA_PKCS1_SHA1 //yh_string_to_algo("rsa2048", &algorithm) => YH_ALGO_RSA_2048
Definition at line 4403 of file yubihsm.c.
yh_rc yh_string_to_capabilities | ( | const char * | capability, |
yh_capabilities * | result ) |
Convert capability string to byte array
capability | String of capabilities separated by ',', ':' or '|' |
result | Array of yh_capabilities |
capability
is too bigDefinition at line 4115 of file yubihsm.c.
Convert a string to a domain's numeric value.
The domains string can contain one or several domains separated by ',', ':' or '|'. Each domain can be written in decimal or hex format
domains | String of domains |
result | Resulting parsed domains as an unsigned int |
Definition at line 4535 of file yubihsm.c.
Convert a string to an option's numeric value
string | Option as string. See yh_option |
option | Option numeric value |
yh_option option; //yh_string_to_option(NULL, &option) => YHR_INVALID_PARAMETERS //yh_string_to_option("something", NULL) => YHR_INVALID_PARAMETERS //yh_string_to_option("something", &option) => YHR_INVALID_PARAMETERS //yh_string_to_option("force-audit", &option) =>option=YH_OPTION_FORCE_AUDIT
Definition at line 4463 of file yubihsm.c.
yh_rc yh_string_to_type | ( | const char * | string, |
yh_object_type * | type ) |
Convert a string to a type's numeric value
string | Type as a String. See yh_object_type |
type | Type numeric value |
yh_object_type type; //yh_string_to_type(NULL, &type) => YHR_INVALID_PARAMETERS //yh_string_to_type("something", NULL) => YHR_INVALID_PARAMETERS //yh_string_to_type("something", &type) => YHR_INVALID_PARAMETERS //yh_string_to_type("opaque", &type) => type=YH_OPAQUE //yh_string_to_type("authentication-key", &type) =>type=YH_AUTHENTICATION_KEY
Definition at line 4442 of file yubihsm.c.
yh_rc yh_type_to_string | ( | yh_object_type | type, |
char const ** | result ) |
Convert a yh_object_type to its string representation
type | Type to convert. See yh_object_type |
result | The type as a String. "Unknown" if the type was not recognized |
result
is NULL.const char *string; //yh_type_to_string(0, NULL) => YHR_INVALID_PARAMETERS //yh_type_to_string(99, &string) => string="Unknown" //yh_type_to_string(YH_OPAQUE, &string) => string="opaque" //yh_type_to_string(YH_AUTHENTICATION_KEY, &string) =>string="authentication-key"
Definition at line 4424 of file yubihsm.c.
yh_rc yh_util_blink_device | ( | yh_session * | session, |
uint8_t | seconds ) |
Blink the LED of the device to identify it
session | Authenticated session to use |
seconds | Number of seconds to blink |
Definition at line 3766 of file yubihsm.c.
yh_rc yh_util_change_authentication_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const uint8_t * | key_enc, | ||
size_t | key_enc_len, | ||
const uint8_t * | key_mac, | ||
size_t | key_mac_len ) |
Replace the long lived encryption key and MAC key associated with an YH_AUTHENTICATION_KEY in the device
session | Authenticated session to use |
key_id | Object ID of the key to replace |
key_enc | New long lived encryption key |
key_enc_len | Length of the new encryption key. Must be YH_KEY_LEN |
key_mac | New long lived MAC key |
key_mac_len | Length of the new MAC key. Must be YH_KEY_LEN |
key_enc_len
or key_mac_len
are not the expected values. See yh_rc for other possible errorsDefinition at line 3094 of file yubihsm.c.
yh_rc yh_util_change_authentication_key_derived | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const uint8_t * | password, | ||
size_t | password_len ) |
Replace the long lived encryption key and MAC key associated with an YH_AUTHENTICATION_KEY in the device with keys derived from a password
session | Authenticated session to use |
key_id | Object ID of the key to replace |
password | Password to derive the new encryption key and MAC key |
password_len | Length of password |
Definition at line 3155 of file yubihsm.c.
yh_rc yh_util_close_session | ( | yh_session * | session | ) |
Close a session
session | Session to close |
Definition at line 1257 of file yubihsm.c.
yh_rc yh_util_create_otp_aead | ( | yh_session * | session, |
uint16_t | key_id, | ||
const uint8_t * | key, | ||
const uint8_t * | private_id, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Create a Yubico OTP AEAD using the provided data
session | Authenticated session to use |
key_id | Object ID of the Otp-aead Key to use |
key | OTP key |
private_id | OTP private id |
out | The created AEAD |
out_len | Length of the created AEAD |
Definition at line 3179 of file yubihsm.c.
yh_rc yh_util_decrypt_oaep | ( | yh_session * | session, |
uint16_t | key_id, | ||
const uint8_t * | in, | ||
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len, | ||
const uint8_t * | label, | ||
size_t | label_len, | ||
yh_algorithm | mgf1Algo ) |
Decrypt data using RSA-OAEP
session | Authenticated session to use |
key_id | Object ID of the RSA key to use for decryption |
in | Encrypted data |
in_len | Length of encrypted data. Must be 256, 384 or 512 |
out | Decrypted data |
out_len | Length of decrypted data |
label | OAEP label |
label_len | Length of OAEP label. Must be 20, 32, 48 or 64 |
mgf1Algo | MGF1 algorithm |
in_len
or label_len
are not what expected. See yh_rc for other possible errors Definition at line 2107 of file yubihsm.c.
yh_rc yh_util_decrypt_otp | ( | yh_session * | session, |
uint16_t | key_id, | ||
const uint8_t * | aead, | ||
size_t | aead_len, | ||
const uint8_t * | otp, | ||
uint16_t * | useCtr, | ||
uint8_t * | sessionCtr, | ||
uint8_t * | tstph, | ||
uint16_t * | tstpl ) |
Decrypt a Yubico OTP and return counters and time information.
session | Authenticated session to use |
key_id | Object ID of the key used for decryption |
aead | AEAD as created by yh_util_create_otp_aead() or yh_util_randomize_otp_aead() |
aead_len | Length of AEAD |
otp | OTP |
useCtr | OTP use counter |
sessionCtr | OTP session counter |
tstph | OTP timestamp high |
tstpl | OTP timestamp low |
Definition at line 3261 of file yubihsm.c.
yh_rc yh_util_decrypt_pkcs1v1_5 | ( | yh_session * | session, |
uint16_t | key_id, | ||
const uint8_t * | in, | ||
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Decrypt data that was encrypted using RSA-PKCS#1v1.5
session | Authenticated session to use |
key_id | Object ID of the RSA key to use for decryption |
in | Encrypted data |
in_len | Length of encrypted data |
out | Decrypted data |
out_len | Length of decrypted data |
in_len
is bigger than YH_MSG_BUF_SIZE-2. See yh_rc for other possible errors Definition at line 2059 of file yubihsm.c.
yh_rc yh_util_delete_object | ( | yh_session * | session, |
uint16_t | id, | ||
yh_object_type | type ) |
Delete an object in the device
session | Authenticated session to use |
id | Object ID of the object to delete |
type | Type of object to delete. See yh_object_type |
Definition at line 2222 of file yubihsm.c.
yh_rc yh_util_derive_ecdh | ( | yh_session * | session, |
uint16_t | key_id, | ||
const uint8_t * | in, | ||
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Derive an ECDH key from a private EC key on the device and a provided public EC key
session | Authenticated session to use |
key_id | Object ID of the EC private key to use for ECDH derivation |
in | Public key of another EC key-pair |
in_len | Length of public key |
out | Shared secret ECDH key |
out_len | Length of the shared ECDH key |
in_len
is bigger than YH_MSG_BUF_SIZE-2. See yh_rc for other possible errors Definition at line 2174 of file yubihsm.c.
yh_rc yh_util_export_wrapped | ( | yh_session * | session, |
uint16_t | wrapping_key_id, | ||
yh_object_type | target_type, | ||
uint16_t | target_id, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Export an object under wrap from the device
session | Authenticated session to use |
wrapping_key_id | Object ID of the Wrap Key to use to wrap the object |
target_type | Type of the object to be exported. See yh_object_type |
target_id | Object ID of the object to be exported |
out | Wrapped data |
out_len | Length of wrapped data |
Definition at line 2265 of file yubihsm.c.
yh_rc yh_util_generate_ec_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm ) |
Generate an Elliptic Curve key in the device
session | Authenticated session to use |
key_id | Object ID of the key. 0 if the Object ID should be generated by the device |
label | Label of the key. Maximum length is YH_OBJ_LABEL_LEN |
domains | Domains to which the key belongs. See yh_string_to_domains() |
capabilities | Capabilities of the key. See yh_string_to_capabilities() |
algorithm | Algorithm to use to generate the EC key. Supported algorithm: YH_ALGO_EC_P224, YH_ALGO_EC_P256, YH_ALGO_EC_K256, YH_ALGO_EC_BP256, YH_ALGO_EC_P384, YH_ALGO_EC_BP384, YH_ALGO_EC_BP512 and YH_ALGO_EC_P521. |
Definition at line 1913 of file yubihsm.c.
yh_rc yh_util_generate_ed_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm ) |
Generate an ED key in the device
session | Authenticated session to use |
key_id | Object ID of the key. 0 if the Object ID should be generated by the device |
label | Label for the key. Maximum length YH_OBJ_LABEL_LEN |
domains | Domains to which the key belongs. See yh_string_to_domains() |
capabilities | Capabilities of the ED key. See yh_string_to_capabilities() |
algorithm | Algorithm to use to generate the ED key. Supported algorithm: YH_ALGO_EC_ED25519 |
Definition at line 1926 of file yubihsm.c.
yh_rc yh_util_generate_hmac_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm ) |
Generate an HMAC key in the device
session | Authenticated session to use |
key_id | Object ID of the key. 0 if the Object ID should be generated by the device |
label | Label of the key. Maximum length YH_OBJ_LABEL_LEN |
domains | Domains to which the key belongs. See yh_string_to_domains() |
capabilities | Capabilities of the key. See yh_string_to_capabilities() |
algorithm | Algorithm to use to generate the HMAC key. Supported algorithims: YH_ALGO_HMAC_SHA1, YH_ALGO_HMAC_SHA256, YH_ALGO_HMAC_SHA384 and YH_ALGO_HMAC_SHA512 |
Definition at line 1992 of file yubihsm.c.
yh_rc yh_util_generate_otp_aead_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm, | ||
uint32_t | nonce_id ) |
Generate an YH_OTP_AEAD_KEY for Yubico OTP decryption in the device.
session | Authenticated session to use |
key_id | Object ID of the AEAD Key. 0 if the Object ID should be generated by the device |
label | Label of the AEAD Key. Maximum length is YH_OBJ_LABEL_LEN |
domains | Domains the AEAD Key will be operating within. See yh_string_to_domains() |
capabilities | Capabilities of the AEAD Key. See yh_string_to_capabilities() |
algorithm | Algorithm used to generate the AEAD Key. Supported algorithms: YH_ALGO_AES128_YUBICO_OTP, YH_ALGO_AES192_YUBICO_OTP and YH_ALGO_AES256_YUBICO_OTP |
nonce_id | Nonce ID |
Definition at line 3422 of file yubihsm.c.
yh_rc yh_util_generate_rsa_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm ) |
Generate an RSA key in the device
session | Authenticated session to use |
key_id | Object ID of the key. 0 if the Object ID should be generated by the device |
label | Label of the key. Maximum length is YH_OBJ_LABEL_LEN |
domains | Domains to which the key belongs. See yh_string_to_domains() |
capabilities | Capabilities of the key. See yh_string_to_capabilities() |
algorithm | Algorithm to use to generate the RSA key. Supported algorithms: YH_ALGO_RSA_2048, YH_ALGO_RSA_3072 and YH_ALGO_RSA_4096 |
Definition at line 1900 of file yubihsm.c.
yh_rc yh_util_generate_wrap_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm, | ||
const yh_capabilities * | delegated_capabilities ) |
Generate a Wrap Key that can be used for export, import, wrap data and unwrap data in the device.
session | Authenticated session to use |
key_id | Object ID of the Wrap Key. 0 if the Object ID should be generated by the device |
label | Label of the Wrap Key. Maximum length YH_OBJ_LABEL_LEN |
domains | Domains where the Wrap Key will be operating within. See yh_string_to_domains() |
capabilities | Capabilities of the Wrap Key. See yh_string_to_capabilities() |
algorithm | Algorithm used to generate the Wrap Key |
delegated_capabilities | Delegated capabilitites of the Wrap Key. See yh_string_to_capabilities() |
Definition at line 2458 of file yubihsm.c.
yh_rc yh_util_get_device_info | ( | yh_connector * | connector, |
uint8_t * | major, | ||
uint8_t * | minor, | ||
uint8_t * | patch, | ||
uint32_t * | serial, | ||
uint8_t * | log_total, | ||
uint8_t * | log_used, | ||
yh_algorithm * | algorithms, | ||
size_t * | n_algorithms ) |
Get device version, device serial number, supported algorithms and available log entries.
connector | Connector to the device |
major | Device major version number |
minor | Device minor version number |
patch | Device build version number |
serial | Device serial number |
log_total | Total number of log entries |
log_used | Number of written log entries |
algorithms | List of supported algorithms |
n_algorithms | Number of supported algorithms |
Definition at line 938 of file yubihsm.c.
yh_rc yh_util_get_log_entries | ( | yh_session * | session, |
uint16_t * | unlogged_boot, | ||
uint16_t * | unlogged_auth, | ||
yh_log_entry * | out, | ||
size_t * | n_items ) |
Get audit logs from the device.
When audit enforce is set, if the log buffer is full, no new operations (other than authentication operations) can be performed unless the log entries are read by this command and then the log index is set by calling yh_util_set_log_index().
session | Authenticated session to use |
unlogged_boot | Number of unlogged boot events. Used if the log buffer is full and audit enforce is set |
unlogged_auth | Number of unlogged authentication events. Used if the log buffer is full and audit enforce is set |
out | Log entries on the device |
n_items | Number of log entries |
n_items
is smaller than the actual number of retrieved log entries. See yh_rc for other possible errors Definition at line 2531 of file yubihsm.c.
yh_rc yh_util_get_object_info | ( | yh_session * | session, |
uint16_t | id, | ||
yh_object_type | type, | ||
yh_object_descriptor * | object ) |
Get metadata of the object with the specified Object ID and Type
session | Authenticated session to use |
id | Object ID of the object to get |
type | Object type. See yh_object_type |
object | Object information |
Definition at line 1128 of file yubihsm.c.
yh_rc yh_util_get_opaque | ( | yh_session * | session, |
uint16_t | object_id, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Get an YH_OPAQUE object (like an X.509 certificate) from the device
session | Authenticated session to use |
object_id | Object ID of the Opaque object |
out | the retrieved Opaque object |
out_len | Length of the retrieved Opaque object |
Definition at line 2636 of file yubihsm.c.
yh_rc yh_util_get_option | ( | yh_session * | session, |
yh_option | option, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Get a device-global option
session | Authenticated session to use |
option | Option to get. See yh_option |
out | Option value |
out_len | Length of option value |
Definition at line 3584 of file yubihsm.c.
yh_rc yh_util_get_pseudo_random | ( | yh_session * | session, |
size_t | len, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Get a fixed number of pseudo-random bytes from the device
session | Authenticated session to use |
len | Length of pseudo-random data to get |
out | Pseudo-random data out |
out_len | Length of pseudo-random data |
Definition at line 1560 of file yubihsm.c.
yh_rc yh_util_get_public_key | ( | yh_session * | session, |
uint16_t | id, | ||
uint8_t * | data, | ||
size_t * | data_len, | ||
yh_algorithm * | algorithm ) |
Get the value of the public key with the specified Object ID
session | Authenticated session to use |
id | Object ID of the public key |
data | Value of the public key |
data_len | Length of the public key in bytes |
algorithm | Algorithm of the key |
Definition at line 1216 of file yubihsm.c.
yh_rc yh_util_get_storage_info | ( | yh_session * | session, |
uint16_t * | total_records, | ||
uint16_t * | free_records, | ||
uint16_t * | total_pages, | ||
uint16_t * | free_pages, | ||
uint16_t * | page_size ) |
Report currently free storage. This is reported as free records, free pages and page size.
session | Authenticated session to use |
total_records | Total number of records |
free_records | Number of free records |
total_pages | Total number of pages |
free_pages | Number of free pages |
page_size | Page size in bytes |
Definition at line 3610 of file yubihsm.c.
yh_rc yh_util_get_template | ( | yh_session * | session, |
uint16_t | object_id, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Get a YH_TEMPLATE object from the device
session | Authenticated session to use |
object_id | Object ID of the Template to get |
out | The retrieved Template |
out_len | Length of the retrieved Template |
Definition at line 2805 of file yubihsm.c.
yh_rc yh_util_import_authentication_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
const yh_capabilities * | delegated_capabilities, | ||
const uint8_t * | key_enc, | ||
size_t | key_enc_len, | ||
const uint8_t * | key_mac, | ||
size_t | key_mac_len ) |
Import an YH_AUTHENTICATION_KEY into the device
session | Authenticated session to use |
key_id | Object ID of the imported key. 0 if the Object ID should be generated by the device |
label | Label of the key. Maximum length is YH_OBJ_LABEL_LEN |
domains | Domains to which the key belongs. See yh_string_to_domains() |
capabilities | Capabilities of the key. See yh_string_to_capabilities() |
delegated_capabilities | Delegated capabilities of the key. See yh_string_to_capabilities() |
key_enc | Long lived encryption key of the Authentication Key to import |
key_enc_len | Length of the encryption key. Must be YH_KEY_LEN |
key_mac | Long lived MAC key of the Authentication Key to import |
key_mac_len | Length of the MAC key. Must be YH_KEY_LEN |
key_enc_len
or key_mac_len
are not the expected values. See yh_rc for other possible errorsDefinition at line 2985 of file yubihsm.c.
yh_rc yh_util_import_authentication_key_derived | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
const yh_capabilities * | delegated_capabilities, | ||
const uint8_t * | password, | ||
size_t | password_len ) |
Import an YH_AUTHENTICATION_KEY with long lived keys derived from a password
session | Authenticated session to use |
key_id | Object ID of the key. 0 if the Object ID should be generated by the device |
label | Label of the key. Maximum length is YH_OBJ_LABEL_LEN |
domains | Domains to which the key belongs. See yh_string_to_domains() |
capabilities | Capabilities of the key. See yh_string_to_capabilities() |
delegated_capabilities | Delegated capabilities of the key. See yh_string_to_capabilities() |
password | Password used to derive the long lived encryption key and MAC key of the Athentication Key |
password_len | Length of password |
Definition at line 3064 of file yubihsm.c.
yh_rc yh_util_import_ec_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm, | ||
const uint8_t * | s ) |
Import an Elliptic Curve key into the device
session | Authenticated session to use |
key_id | Object ID of the key. 0 if the Object ID should be generated by the device |
label | Label of the key. Maximum length is YH_OBJ_LABEL_LEN |
domains | Domains to which the key belongs specified as an unsigned int. See yh_string_to_domains() |
capabilities | Capabilities of the key. See yh_string_to_capabilities() |
algorithm | Algorithm of the key to import. Must be one of: YH_ALGO_EC_P224, YH_ALGO_EC_P256, YH_ALGO_EC_K256, YH_ALGO_EC_BP256, YH_ALGO_EC_P384, YH_ALGO_EC_BP384, YH_ALGO_EC_BP512 or YH_ALGO_EC_P521 |
s | the EC key to import |
Definition at line 1689 of file yubihsm.c.
yh_rc yh_util_import_ed_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm, | ||
const uint8_t * | k ) |
Import an ED key into the device
session | Authenticated session to use |
key_id | Object ID of the key will have. 0 if the Object ID should be generated by the device |
label | Label of the key. Maximum length is YH_OBJ_LABEL_LEN |
domains | Domains to which the key belongs. See yh_string_to_domains() |
capabilities | Capabilities of the key. See yh_string_to_capabilities() |
algorithm | Algorithm of the key to import. Must be YH_ALGO_EC_ED25519 |
k | the ED key to import |
Definition at line 1727 of file yubihsm.c.
yh_rc yh_util_import_hmac_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm, | ||
const uint8_t * | key, | ||
size_t | key_len ) |
Import an HMAC key into the device
session | Authenticated session to use |
key_id | Object ID of the key. 0 if the Object ID should be generated by the device |
label | Label of the key. Maxium length is YH_OBJ_LABEL_LEN |
domains | Domains to which the key belongs. See yh_string_to_domains() |
capabilities | Capabilities of the key. See yh_string_to_capabilities() |
algorithm | Algorithm of the key to import. Must be one of: YH_ALGO_HMAC_SHA1, YH_ALGO_HMAC_SHA256, YH_ALGO_HMAC_SHA384 or YH_ALGO_HMAC_SHA512 |
key | The HMAC key to import |
key_len | Length of the HMAC key to import |
Definition at line 1750 of file yubihsm.c.
yh_rc yh_util_import_opaque | ( | yh_session * | session, |
uint16_t * | object_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm, | ||
const uint8_t * | in, | ||
size_t | in_len ) |
Import an YH_OPAQUE object into the device
session | Authenticated session to use |
object_id | Object ID of the Opaque object. 0 if the Object ID should be generated by the device |
label | Label of the Opaque object. Maximum length is YH_OBJ_LABEL_LEN |
domains | Domains the Opaque object will be operating within. See yh_string_to_domains() |
capabilities | Capabilities of the Opaque object. See yh_string_to_capabilities() |
algorithm | Algorithm of the Opaque object |
in | the Opaque object to import |
in_len | Length of the Opaque object to import |
in_len
is too big. See yh_rc for other possible errors Definition at line 2666 of file yubihsm.c.
yh_rc yh_util_import_otp_aead_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
uint32_t | nonce_id, | ||
const uint8_t * | in, | ||
size_t | in_len ) |
Import an YH_OTP_AEAD_KEY used for Yubico OTP Decryption
session | Authenticated session to use |
key_id | Object ID of the AEAD Key. 0 if the Object ID should be generated by the device |
label | Label of the AEAD Key. Maximum length is YH_OBJ_LABEL_LEN |
domains | Domains the AEAD Key will be operating within. See yh_string_to_domains() |
capabilities | Capabilities of the AEAD Key. See yh_string_to_capabilities() |
nonce_id | Nonce ID |
in | AEAD Key to import |
in_len | Length of AEAD Key to import. Must be 16, 24 or 32 |
in_len
is not one of 16, 24 or 32. See yh_rc for other possible errors Definition at line 3337 of file yubihsm.c.
yh_rc yh_util_import_rsa_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm, | ||
const uint8_t * | p, | ||
const uint8_t * | q ) |
Import an RSA key into the device
session | Authenticated session to use |
key_id | Object ID the key. 0 if Object ID should be generated by the device |
label | Label of the key. Maximum length is YH_OBJ_LABEL_LEN |
domains | Domains to which the key belongs specified as an unsigned int. See yh_string_to_domains() |
capabilities | Capabilities of the key. See yh_string_to_capabilities() |
algorithm | Algorithm of the key to import. Must be one of: YH_ALGO_RSA_2048, YH_ALGO_RSA_3072 or YH_ALGO_RSA_4096 |
p | P component of the RSA key to import |
q | Q component of the RSA key to import |
Definition at line 1655 of file yubihsm.c.
yh_rc yh_util_import_template | ( | yh_session * | session, |
uint16_t * | object_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm, | ||
const uint8_t * | in, | ||
size_t | in_len ) |
Import a YH_TEMPLATE object into the device
session | Authenticated session to use |
object_id | Object ID of the Template. 0 if the Object ID should be generated by the device |
label | Label of the Template. Maximum length is YH_OBJ_LABEL_LEN |
domains | Domains the Template will be operating within. See yh_string_to_domains() |
capabilities | Capabilities of the Template. See yh_string_to_capabilities |
algorithm | Algorithm of the Template |
in | Template to import |
in_len | Length of the Template to import |
in_len
is too big. See yh_rc for other possible errors Definition at line 2835 of file yubihsm.c.
yh_rc yh_util_import_wrap_key | ( | yh_session * | session, |
uint16_t * | key_id, | ||
const char * | label, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm, | ||
const yh_capabilities * | delegated_capabilities, | ||
const uint8_t * | in, | ||
size_t | in_len ) |
Import a Wrap Key into the device
session | Authenticated session to use |
key_id | Object ID the Wrap Key. 0 if the Object ID should be generated by the device |
label | Label of the Wrap Key. Maximum length is YH_OBJ_LABEL_LEN |
domains | Domains where the Wrap Key will be operating within. See yh_string_to_domains() |
capabilities | Capabilities of the Wrap Key. See yh_string_to_capabilities() |
algorithm | Algorithm of the Wrap Key. Supported algorithms: YH_ALGO_AES128_CCM_WRAP, YH_ALGO_AES192_CCM_WRAP and YH_ALGO_AES256_CCM_WRAP |
delegated_capabilities | Delegated capabilities of the Wrap Key. See yh_string_to_capabilities() |
in | the Wrap Key to import |
in_len | Length of the Wrap Key to import |
in_len
is not what expected based on the algorithm and if the algorithms is not one of YH_ALGO_AES128_CCM_WRAP, YH_ALGO_AES192_CCM_WRAP or YH_ALGO_AES256_CCM_WRAP. See yh_rc for other possible errors Definition at line 2363 of file yubihsm.c.
yh_rc yh_util_import_wrapped | ( | yh_session * | session, |
uint16_t | wrapping_key_id, | ||
const uint8_t * | in, | ||
size_t | in_len, | ||
yh_object_type * | target_type, | ||
uint16_t * | target_id ) |
Import a wrapped object into the device. The object should have been previously exported by yh_util_export_wrapped()
session | Authenticated session to use |
wrapping_key_id | Object ID of the Wrap Key to use to unwrap the object |
in | Wrapped data |
in_len | Length of wrapped data |
target_type | Type of the imported object |
target_id | Object ID of the imported object |
Definition at line 2309 of file yubihsm.c.
yh_rc yh_util_list_objects | ( | yh_session * | session, |
uint16_t | id, | ||
yh_object_type | type, | ||
uint16_t | domains, | ||
const yh_capabilities * | capabilities, | ||
yh_algorithm | algorithm, | ||
const char * | label, | ||
yh_object_descriptor * | objects, | ||
size_t * | n_objects ) |
List objects accessible from the session
session | Authenticated session to use |
id | Object ID to filter by (0 to not filter by ID) |
type | Object type to filter by (0 to not filter by type). See yh_object_type |
domains | Domains to filter by (0 to not filter by domain) |
capabilities | Capabilities to filter by (0 to not filter by capabilities). See yh_capabilities |
algorithm | Algorithm to filter by (0 to not filter by algorithm) |
label | Label to filter by |
objects | Array of objects returned |
n_objects | Max number of objects (will be set to number found on return) |
Definition at line 1030 of file yubihsm.c.
yh_rc yh_util_randomize_otp_aead | ( | yh_session * | session, |
uint16_t | key_id, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Create OTP AEAD from random data
session | Authenticated session to use |
key_id | Object ID of the Otp-aead Key to use |
out | The created AEAD |
out_len | Length of the created AEAD |
Definition at line 3223 of file yubihsm.c.
yh_rc yh_util_reset_device | ( | yh_session * | session | ) |
Factory reset the device. Resets and reboots the device, deletes all Objects and restores the default YH_AUTHENTICATION_KEY.
session | Authenticated session to use |
Definition at line 3796 of file yubihsm.c.
yh_rc yh_util_set_log_index | ( | yh_session * | session, |
uint16_t | index ) |
Set the index of the last extracted log entry.
This function should be called after yh_util_get_log_entries() to inform the device what the last extracted log entry is so new logs can be written. This is used when forced auditing is enabled.
session | Authenticated session to use |
index | index to set. Should be the same index as the last entry extracted using yh_util_get_log_entries() |
Definition at line 2606 of file yubihsm.c.
yh_rc yh_util_set_option | ( | yh_session * | session, |
yh_option | option, | ||
size_t | len, | ||
uint8_t * | val ) |
Set a device-global option
session | Authenticated session to use |
option | Option to set. See yh_option |
len | Length of option value |
val | Option value |
session
or val
are NULL or if len
is too long. See yh_rc for other possible errors Definition at line 3537 of file yubihsm.c.
yh_rc yh_util_sign_attestation_certificate | ( | yh_session * | session, |
uint16_t | key_id, | ||
uint16_t | attest_id, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Get attestation of an Asymmetric Key in the form of an X.509 certificate
session | Authenticated session to use |
key_id | Object ID of the Asymmetric Key to attest |
attest_id | Object ID for the key used to sign the attestation certificate |
out | The attestation certificate |
out_len | Length of the attestation certificate |
Definition at line 3495 of file yubihsm.c.
yh_rc yh_util_sign_ecdsa | ( | yh_session * | session, |
uint16_t | key_id, | ||
const uint8_t * | in, | ||
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Sign data using ECDSA
in
is a raw hashed message, a truncated hash to the curve length or a padded hash to the curve length
session | Authenticated session to use |
key_id | Object ID of the signing key |
in | Data to sign |
in_len | Length of data to sign |
out | Signed data |
out_len | Length of signed data |
in_len
is not 20, 28, 34, 48, 64 or 66. See yh_rc for other possible errors Definition at line 1411 of file yubihsm.c.
yh_rc yh_util_sign_eddsa | ( | yh_session * | session, |
uint16_t | key_id, | ||
const uint8_t * | in, | ||
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Sign data using EdDSA
session | Authenticated session to use |
key_id | Object ID of the signing key |
in | Data to sign |
in_len | Length of data to sign |
out | Signed data |
out_len | Length of signed data |
in_len
is bigger than YH_MSG_BUF_SIZE-2. See yh_rc for other possible errors Definition at line 1470 of file yubihsm.c.
yh_rc yh_util_sign_hmac | ( | yh_session * | session, |
uint16_t | key_id, | ||
const uint8_t * | in, | ||
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Sign data using HMAC
session | Authenticated session to use |
key_id | Object ID of the signing key |
in | Data to HMAC |
in_len | Length of data to hmac |
out | HMAC |
out_len | Length of HMAC |
in_len
is bigger than YH_MSG_BUF_SIZE-2. See yh_rc for other possible errors Definition at line 1520 of file yubihsm.c.
yh_rc yh_util_sign_pkcs1v1_5 | ( | yh_session * | session, |
uint16_t | key_id, | ||
bool | hashed, | ||
const uint8_t * | in, | ||
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Sign data using RSA-PKCS#1v1.5
in
is either a raw hashed message (sha1, sha256, sha384 or sha512) or that with correct digestinfo pre-pended
session | Authenticated session to use |
key_id | Object ID of the signing key |
hashed | true if data is only hashed |
in | data to sign |
in_len | length of data to sign |
out | signed data |
out_len | length of signed data |
in_len
is not 20, 34, 48 or 64. See yh_rc for other possible errors Definition at line 1287 of file yubihsm.c.
yh_rc yh_util_sign_pss | ( | yh_session * | session, |
uint16_t | key_id, | ||
const uint8_t * | in, | ||
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len, | ||
size_t | salt_len, | ||
yh_algorithm | mgf1Algo ) |
Sign data using RSA-PSS
in
is a raw hashed message (sha1, sha256, sha384 or sha512)
session | Authenticated session to use |
key_id | Object ID of the signing key |
in | Data to sign |
in_len | Length of data to sign |
out | Signed data |
out_len | Length of signed data |
salt_len | Length of salt |
mgf1Algo | Algorithm for mgf1 (mask generation function for PSS) |
in_len
is not 20, 34, 48 or 64. See yh_rc for other possible errorsDefinition at line 1346 of file yubihsm.c.
yh_rc yh_util_sign_ssh_certificate | ( | yh_session * | session, |
uint16_t | key_id, | ||
uint16_t | template_id, | ||
yh_algorithm | sig_algo, | ||
const uint8_t * | in, | ||
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Sign an SSH Certificate request. The function produces a signature that can then be used to produce the SSH Certificate
session | Authenticated session to use |
key_id | Object ID of the key used to sign the request |
template_id | Object ID of the template to use as a certificate template |
sig_algo | Signature algorithm to use to sign the certificate request |
in | Certificate request |
in_len | Length of the certificate request |
out | Signature |
out_len | Length of the signature |
in_len
is too big. See yh_rc for other possible errors Definition at line 2745 of file yubihsm.c.
yh_rc yh_util_unwrap_data | ( | yh_session * | session, |
uint16_t | key_id, | ||
const uint8_t * | in, | ||
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Decrypt (unwrap) data using a YH_WRAP_KEY.
session | Authenticated session to use |
key_id | Object ID of the Wrap Key to use |
in | Wrapped data |
in_len | Length of wrapped data |
out | Unwrapped data |
out_len | Length of unwrapped data |
in_len
is too big. See yh_rc for other possible errors Definition at line 3716 of file yubihsm.c.
yh_rc yh_util_verify_hmac | ( | yh_session * | session, |
uint16_t | key_id, | ||
const uint8_t * | signature, | ||
size_t | signature_len, | ||
const uint8_t * | data, | ||
size_t | data_len, | ||
bool * | verified ) |
Verify a generated HMAC
session | Authenticated session to use |
key_id | Object ID of the HMAC key |
signature | HMAC signature (20, 32, 48 or 64 bytes) |
signature_len | length of HMAC signature |
data | data to verify |
data_len | length of data to verify |
verified | true if verification succeeded |
signature_len
+ data_len
is too long. See yh_rc for other possible errors Definition at line 1939 of file yubihsm.c.
yh_rc yh_util_wrap_data | ( | yh_session * | session, |
uint16_t | key_id, | ||
const uint8_t * | in, | ||
size_t | in_len, | ||
uint8_t * | out, | ||
size_t * | out_len ) |
Encrypt (wrap) data using a YH_WRAP_KEY.
session | Authenticated session to use |
key_id | Object ID of the Wrap Key to use |
in | Data to wrap |
in_len | Length of data to wrap |
out | Wrapped data |
out_len | Length of the wrapped data |
in_len
is too big. See yh_rc for other possible errors Definition at line 3667 of file yubihsm.c.
bool yh_verify_logs | ( | yh_log_entry * | logs, |
size_t | n_items, | ||
yh_log_entry * | last_previous_log ) |
Verify an array of log entries
logs | Array of log entries |
n_items | number of log entries |
last_previous_log | Optional pointer to the entry before the first entry in logs |
Definition at line 4480 of file yubihsm.c.
FILE* _yh_output YH_INTERNAL = 0 |