29#ifndef DEFAULT_CONNECTOR_URL
30#define DEFAULT_CONNECTOR_URL "http://127.0.0.1:12345"
35const uint8_t data[] =
"sudo make me a sandwich";
44 const char *connector_url;
46 connector_url = getenv(
"DEFAULT_CONNECTOR_URL");
47 if (connector_url == NULL) {
61 sizeof(password),
false, &
session);
71 printf(
"Successfully established session %02d using Authentication Key "
88 printf(
"Generated HMAC-SHA256 key with ID %04x\n",
key_id);
91 size_t hmac_data_len =
sizeof(hmac_data);
96 printf(
"HMAC of data (%zu bytes) is:", hmac_data_len);
97 for (
uint16_t i = 0; i < hmac_data_len; i++) {
98 printf(
" %02x", hmac_data[i]);
104 sizeof(data) - 1, &verified);
107 if (verified ==
true) {
108 printf(
"Successfully verified HMAC\n");
110 printf(
"Unable to verify HMAC\n");
115 sizeof(data) - 1, &verified);
118 if (verified ==
true) {
119 printf(
"Successfully verified HMAC\n");
121 printf(
"Unable to verify HMAC\n");
CK_SESSION_HANDLE session
#define DEFAULT_CONNECTOR_URL
Capabilities representation.
yh_rc yh_destroy_session(yh_session **session)
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)
yh_rc yh_create_session_derived(yh_connector *connector, uint16_t authkey_id, const uint8_t *password, size_t password_len, bool recreate, yh_session **session)
yh_rc yh_util_close_session(yh_session *session)
yh_rc yh_authenticate_session(yh_session *session)
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)
yh_rc yh_string_to_domains(const char *domains, uint16_t *result)
yh_rc yh_init_connector(const char *url, yh_connector **connector)
yh_rc yh_connect(yh_connector *connector, int timeout)
yh_rc yh_string_to_capabilities(const char *capability, yh_capabilities *result)
yh_rc yh_disconnect(yh_connector *connector)
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)
yh_rc yh_get_session_id(yh_session *session, uint8_t *sid)
@ YH_ALGO_HMAC_SHA256
hmac-sha256
@ YHR_GENERIC_ERROR
Return value when encountering an unknown error.
@ YHR_SUCCESS
Returned value when function was successful.
yh_capabilities capabilities