37 {
41
43
44 const char *connector_url;
45
46 connector_url = getenv("DEFAULT_CONNECTOR_URL");
47 if (connector_url == NULL) {
49 }
50
53
56
59
61 sizeof(password),
false, &
session);
63
66
70
71 printf(
"Successfully established session %02d\n", session_id);
72
76
78
81
84
90
91 printf(
"Generated wrapping key with ID %04x\n", wrapping_key_id);
92
94 size_t data_len = sizeof(data);
95
97 &data_len);
99
100 printf(
"Data wrapped to length %zu\n", data_len);
101
103 assert(memcmp(data,
clear,
sizeof(
clear)) != 0);
104
106 &data_len);
108
109 assert(data_len ==
sizeof(
clear));
110 assert(memcmp(data,
clear,
sizeof(
clear)) == 0);
111
112 printf(
"Data unwrapped successfully\n");
113
116
119
122
125
126 return 0;
127}
CK_SESSION_HANDLE session
LOGGING_API void printf(Category category, const char *format,...)
Capabilities representation.
#define DEFAULT_CONNECTOR_URL
yh_rc yh_destroy_session(yh_session **session)
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)
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_unwrap_data(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_util_close_session(yh_session *session)
yh_rc yh_authenticate_session(yh_session *session)
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)
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_get_session_id(yh_session *session, uint8_t *sid)
@ YH_ALGO_AES256_CCM_WRAP
aes256-ccm-wrap
#define YH_CCM_WRAP_OVERHEAD
@ YHR_GENERIC_ERROR
Return value when encountering an unknown error.
@ YHR_SUCCESS
Returned value when function was successful.
yh_capabilities capabilities
yh_capabilities delegated_capabilities