27#ifndef DEFAULT_CONNECTOR_URL
28#define DEFAULT_CONNECTOR_URL "http://127.0.0.1:12345"
32const uint8_t data[] =
"sudo make me a sandwich";
38 const char *connector_url;
40 connector_url = getenv(
"DEFAULT_CONNECTOR_URL");
41 if (connector_url == NULL) {
47 fprintf(stderr,
"unable to initialize yubihsm: %s\n",
yh_strerror(
yrc));
63 printf(
"Send a plain (unencrypted, unauthenticated) echo command\n");
67 size_t response_len =
sizeof(response);
70 response, &response_len);
72 fprintf(stderr,
"Failed to send ECHO command): %s\n",
yh_strerror(
yrc));
77 fprintf(stderr,
"Unable to get echo data: %s (%x)\n",
82 printf(
"Response (%zu bytes): \"%s\"\n", response_len, response);
87 sizeof(password),
false, &
session);
97 printf(
"Successfully established session %02d\n", session_id);
99 printf(
"Send a secure echo command\n");
102 size_t response2_len =
sizeof(response);
105 response2, &response2_len);
107 fprintf(stderr,
"Failed to send ECHO command: %s\n",
yh_strerror(
yrc));
112 fprintf(stderr,
"Unable to get echo data: %s (%x)\n",
117 printf(
"Response (%zu bytes): \"%s\"\n", response_len, response);
119 assert(response_len == response2_len);
120 assert(memcmp(response, response2, response_len) == 0);
CK_SESSION_HANDLE session
#define DEFAULT_CONNECTOR_URL
const char * yh_strerror(yh_rc err)
yh_rc yh_destroy_session(yh_session **session)
yh_rc yh_set_verbosity(yh_connector *connector, uint8_t verbosity)
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_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)
yh_rc yh_util_close_session(yh_session *session)
yh_rc yh_authenticate_session(yh_session *session)
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)
yh_rc yh_init_connector(const char *url, yh_connector **connector)
yh_rc yh_connect(yh_connector *connector, int timeout)
yh_rc yh_disconnect(yh_connector *connector)
yh_rc yh_get_connector_address(yh_connector *connector, char **const address)
yh_rc yh_get_session_id(yh_session *session, uint8_t *sid)
#define YH_VERB_ALL
Debug level all. All previous options enabled.
@ YHR_GENERIC_ERROR
Return value when encountering an unknown error.
@ YHR_SUCCESS
Returned value when function was successful.