38#include <openssl/rand.h>
39#include <openssl/pem.h>
40#include <openssl/x509.h>
69 size_t n_items =
sizeof(logs);
77 "The selected output format is not supported for this operation. "
78 "Supported format are \"ASCII\", \"hex\" and \"default\"\n");
96 fprintf(ctx->
out,
"%04x%04x", unlogged_boot, unlogged_auth);
97 for (
uint16_t i = 0; i < n_items; i++) {
99 fprintf(ctx->
out,
"%04x%02x%04x%04x%04x%04x%02x%08lx%s", logs[i].
number,
102 (
unsigned long) logs[i].
systick, digest_buf);
104 fprintf(ctx->
out,
"\n");
109 fprintf(ctx->
out,
"%d unlogged boots found\n", unlogged_boot);
110 fprintf(ctx->
out,
"%d unlogged authentications found\n", unlogged_auth);
113 fprintf(ctx->
out,
"No logs to extract\n");
115 }
else if (n_items == 1) {
116 fprintf(ctx->
out,
"Found 1 item\n");
118 fprintf(ctx->
out,
"Found %zu items\n", n_items);
121 for (
uint16_t i = 0; i < n_items; i++) {
124 "item: %5u -- cmd: 0x%02x -- length: %4u -- session key: "
125 "0x%04x -- target key: 0x%04x -- second key: 0x%04x -- "
126 "result: 0x%02x -- tick: %lu -- hash: %s\n",
129 logs[i].
result, (
unsigned long) logs[i].
systick, digest_buf);
148 fprintf(stderr,
"Failed to set log index: %s\n",
yh_strerror(
yrc));
166 fprintf(stderr,
"Failed to blink the device: %s\n",
yh_strerror(
yrc));
183 fprintf(stderr,
"Failed to get session id: %s\n",
yh_strerror(
yrc));
189 fprintf(stderr,
"Failed to close session: %s\n",
yh_strerror(
yrc));
195 fprintf(stderr,
"Failed to destroy session: %s\n",
yh_strerror(
yrc));
214 if (connectors == NULL) {
215 fprintf(stderr,
"Failed allocating memory\n");
223 fprintf(stderr,
"Failed initializing connector\n");
229 fprintf(stderr,
"Failed setting HTTPS CA\n");
236 fprintf(stderr,
"Failed setting proxy server\n");
241 fprintf(stderr,
"Failed connecting '%s'\n", ctx->
connector_list[i]);
277 fprintf(stderr,
"Debug messages enabled\n");
296 fprintf(stderr,
"Error messages on\n");
298 fprintf(stderr,
"Error messages off\n");
319 fprintf(stderr,
"Info messages on\n");
321 fprintf(stderr,
"Info messages off\n");
343 fprintf(stderr,
"Intermediate messages on\n");
345 fprintf(stderr,
"Intermediate messages off\n");
361 fprintf(stderr,
"Debug messages disabled\n");
380 fprintf(stderr,
"Raw messages on\n");
382 fprintf(stderr,
"Raw messages off\n");
403 fprintf(stderr,
"Crypto messages on\n");
405 fprintf(stderr,
"Crypto messages off\n");
425 size_t response_len =
sizeof(response);
428 response, &response_len);
430 fprintf(stderr,
"Failed to decrypt data: %s\n",
yh_strerror(
yrc));
434 write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt));
448 BIO *bio = BIO_new(BIO_s_mem());
455 EVP_PKEY *
pubkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL);
458 fprintf(stderr,
"Failed to load public key\n");
461 if (EVP_PKEY_base_id(
pubkey) != EVP_PKEY_EC) {
463 fprintf(stderr,
"Key is not an EC key.\n");
467 EC_KEY *ec = EVP_PKEY_get1_EC_KEY(
pubkey);
470 fprintf(stderr,
"Failed to retrive key.\n");
476 size_t data_len = i2o_ECPublicKey(ec, &ptr);
482 size_t response_len =
sizeof(response);
487 fprintf(stderr,
"Failed to do key exchange: %s\n",
yh_strerror(
yrc));
491 write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt));
508 size_t response_len =
sizeof(response);
511 response, &response_len);
513 fprintf(stderr,
"Failed to decrypt data: %s\n",
yh_strerror(
yrc));
517 write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt));
534 size_t response_len =
sizeof(response);
537 response, &response_len);
539 fprintf(stderr,
"Failed to encrypt data: %s\n",
yh_strerror(
yrc));
543 write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt));
561 fprintf(stderr,
"Failed to destroy session: %s\n",
yh_strerror(
yrc));
607 response_len =
sizeof(response);
610 response, &response_len);
612 fprintf(stderr,
"Failed to send ECHO command: %s\n",
yh_strerror(
yrc));
617 fprintf(stderr,
"Unable to get echo data: %s (%x)\n",
622 fprintf(ctx->
out,
"Response (%zu bytes):\n", response_len);
623 for (
uint32_t i = 0; i < response_len; i++) {
625 fprintf(ctx->
out,
"\n");
626 else if (i && !(i % 8))
627 fprintf(ctx->
out,
" ");
628 fprintf(ctx->
out,
"%02x", response[i]);
631 fprintf(ctx->
out,
"\n");
662 fprintf(stderr,
"Invalid algorithm %d\n",
argv[5].
a);
667 fprintf(stderr,
"Failed to generate asymmetric key: %s\n",
672 fprintf(stderr,
"Generated Asymmetric key 0x%04x\n",
argv[1].w);
693 fprintf(stderr,
"Invalid algorithm: %d\n",
argv[5].
a);
701 fprintf(stderr,
"Failed to generate HMAC key: %s\n",
yh_strerror(
yrc));
705 fprintf(stderr,
"Generated HMAC key 0x%04x\n",
argv[1].w);
729 fprintf(stderr,
"Failed to generate wrapping key: %s\n",
yh_strerror(
yrc));
733 fprintf(stderr,
"Generated Wrap key 0x%04x\n",
argv[1].w);
748 size_t response_len =
sizeof(response);
752 fprintf(stderr,
"Failed to get opaque object: %s\n",
yh_strerror(
yrc));
756 if (
write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt))) {
775 size_t response_len =
sizeof(response);
784 fprintf(ctx->
out,
"Option value is: ");
785 for (
uint16_t i = 0; i < response_len; i++) {
786 fprintf(ctx->
out,
"%02x", response[i]);
788 fprintf(ctx->
out,
"\n");
800 size_t response_len =
sizeof(response);
805 fprintf(stderr,
"Failed to get pseudo random bytes: %s\n",
810 if (response_len !=
argv[1].w) {
811 fprintf(stderr,
"Wrong response length\n");
815 write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt));
829 uint16_t total_records, free_records, free_pages, total_pages, page_size;
830 total_records = free_records = free_pages = total_pages = page_size = 0;
833 &total_pages, &free_pages, &page_size);
836 fprintf(stderr,
"Failed to get storage stats: %s\n",
yh_strerror(
yrc));
840 "free records: %d/%d, free pages: %d/%d page size: %d bytes\n",
841 free_records, total_records, free_pages, total_pages, page_size);
855 size_t response_len =
sizeof(response);
858 EVP_PKEY *public_key = NULL;
863 fprintf(stderr,
"Failed to get public key: %s\n",
yh_strerror(
yrc));
867 public_key = EVP_PKEY_new();
870 RSA *rsa = RSA_new();
872 BIGNUM *n = BN_bin2bn(response, response_len, NULL);
873 BN_hex2bn(&e,
"10001");
875 EVP_PKEY_set1_RSA(public_key, rsa);
878 EC_KEY *eckey = EC_KEY_new();
881 EC_GROUP *group = EC_GROUP_new_by_curve_name(nid);
883 EC_GROUP_set_asn1_flag(group, nid);
884 EC_KEY_set_group(eckey, group);
885 point = EC_POINT_new(group);
887 memmove(response + 1, response, response_len);
891 EC_POINT_oct2point(group,
point, response, response_len, NULL);
893 EC_KEY_set_public_key(eckey,
point);
895 EVP_PKEY_set1_EC_KEY(public_key, eckey);
897 EC_POINT_free(
point);
899 EC_GROUP_free(group);
903 EVP_PKEY_free(public_key);
910 PEM_write_PUBKEY(ctx->
out, public_key);
912 i2d_PUBKEY_fp(ctx->
out, public_key);
914 EVP_PKEY_free(public_key);
934 fprintf(stderr,
"Failed to get object info: %s\n",
yh_strerror(
yrc));
939 const char *cap[
sizeof(yh_capability) /
sizeof(yh_capability[0])];
940 size_t n_cap =
sizeof(yh_capability) /
sizeof(yh_capability[0]);
943 const char *extra_algo =
"";
947 extra_algo =
", algorithm: ";
952 "id: 0x%04x, type: %s%s%s, label: \"%s\", length: %d, "
953 "domains: %s, sequence: %hhu, origin: ",
954 object.id, type, extra_algo,
algorithm,
object.label,
object.len,
958 fprintf(ctx->
out,
"generated");
961 fprintf(ctx->
out,
"imported");
964 fprintf(ctx->
out,
":imported_wrapped");
967 fprintf(ctx->
out,
", capabilities: ");
971 fprintf(ctx->
out,
"0x%02x%s",
object.capabilities.capabilities[i],
975 for (
size_t i = 0; i < n_cap; i++) {
976 fprintf(ctx->
out,
"%s%s", cap[i], i < n_cap - 1 ?
":" :
"");
980 fprintf(ctx->
out,
", delegated_capabilities: ");
981 n_cap =
sizeof(yh_capability) /
sizeof(yh_capability[0]);
985 fprintf(ctx->
out,
"0x%02x%s",
986 object.delegated_capabilities.capabilities[i],
990 for (
size_t i = 0; i < n_cap; i++) {
991 fprintf(ctx->
out,
"%s%s", cap[i], i < n_cap - 1 ?
":" :
"");
995 fprintf(ctx->
out,
"\n");
1009 size_t response_len =
sizeof(response);
1013 response, &response_len);
1016 fprintf(stderr,
"Failed to get wrapped object: %s\n",
yh_strerror(
yrc));
1020 if (
write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt))) {
1034 size_t response_len =
sizeof(response);
1039 fprintf(stderr,
"Failed to get template object: %s\n",
yh_strerror(
yrc));
1043 write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt));
1068 for (
uint16_t i = 0; i <
sizeof(yh_capability) /
sizeof(yh_capability[0]);
1070 fprintf(ctx->
out,
"%-30s (%016llx)\n", yh_capability[i].name,
1071 1ULL << yh_capability[i].bit);
1086 for (
uint16_t i = 0; i <
sizeof(yh_algorithms) /
sizeof(yh_algorithms[0]);
1088 fprintf(ctx->
out,
"%s\n", yh_algorithms[i].name);
1102 for (
uint16_t i = 0; i <
sizeof(yh_types) /
sizeof(yh_types[0]); i++) {
1103 fprintf(ctx->
out,
"%s\n", yh_types[i].name);
1117 fprintf(stderr,
"Not connected\n");
1123 fprintf(stderr,
"Session %d\n", i);
1130static int compare_objects(
const void *p1,
const void *p2) {
1134 return a->
id - b->
id;
1150 const char *label_arg;
1158 label_arg =
argv[6].s;
1163 argv[5].
a, label_arg, objects, &num_objects);
1165 fprintf(stderr,
"Failed to list objects: %s\n",
yh_strerror(
yrc));
1171 fprintf(ctx->
out,
"Found %zu object(s)\n", num_objects);
1172 for (
size_t i = 0; i < num_objects; i++) {
1173 const char *type =
"";
1175 fprintf(ctx->
out,
"id: 0x%04x, type: %s, sequence: %hhu\n", objects[i].
id,
1182static int parse_yk_password(
char *line,
char **
name,
char **pw) {
1184 int len = strlen(line);
1187 for (
int i = 0; i <
len; i++) {
1188 if (line[i] ==
':') {
1216 fprintf(stderr,
"Not connected\n");
1226 if (strncmp(
"yk:", (
char *)
argv[1].x, 3) == 0) {
1232 size_t key_s_enc_len =
sizeof(key_s_enc);
1233 size_t key_s_mac_len =
sizeof(key_s_mac);
1234 size_t key_s_rmac_len =
sizeof(key_s_rmac);
1239 fprintf(stderr,
"Failed to connect to the YubiKey: %s\n",
1245 card_cryptogram,
sizeof(card_cryptogram),
1248 fprintf(stderr,
"Failed to create session: %s\n",
yh_strerror(
yrc));
1254 if (parse_yk_password((
char *) (
argv[1].x + 3), &
name, &pw) == -1) {
1256 "Failed to decode password, format must be "
1257 "yk:NAME[%d-%d]:PASSWORD[%d]\n",
1264 key_s_enc,
sizeof(key_s_enc), key_s_mac,
sizeof(key_s_mac),
1265 key_s_rmac,
sizeof(key_s_rmac), &retries);
1267 fprintf(stderr,
"Failed to get session keys from the YubiKey: %s",
1270 fprintf(stderr,
", %d attempts remaining", retries);
1272 fprintf(stderr,
"\n");
1279 key_s_enc_len, key_s_mac, key_s_mac_len,
1280 key_s_rmac, key_s_rmac_len, card_cryptogram,
1281 sizeof(card_cryptogram));
1283 fprintf(stderr,
"Failed to create session: %s\n",
yh_strerror(
yrc));
1292 fprintf(stderr,
"Failed to create session: %s\n",
yh_strerror(
yrc));
1301 fprintf(stderr,
"Failed to authenticate session: %s\n",
yh_strerror(
yrc));
1307 fprintf(stderr,
"Failed to create session: %s\n",
yh_strerror(
yrc));
1311 if (ctx->
sessions[session_id] != NULL) {
1314 fprintf(stderr,
"Failed to destroy old session with same id (%d): %s\n",
1321 fprintf(stderr,
"Created session %d\n", session_id);
1340 size_t response_len;
1344 fprintf(stderr,
"Not connected\n");
1359 response_len =
sizeof(response);
1362 &response_cmd, response, &response_len);
1364 fprintf(stderr,
"Failed to send ECHO command): %s\n",
yh_strerror(
yrc));
1369 fprintf(stderr,
"Unable to get echo data: %s (%x)\n",
1374 fprintf(ctx->
out,
"Response (%zu bytes):\n", response_len);
1375 for (
uint32_t i = 0; i < response_len; i++) {
1377 fprintf(ctx->
out,
"\n");
1378 else if (i && !(i % 8))
1379 fprintf(ctx->
out,
" ");
1380 fprintf(ctx->
out,
"%02x", response[i]);
1383 fprintf(ctx->
out,
"\n");
1403 size_t key_material_len =
sizeof(
key);
1409 &key_material_len,
false);
1411 fprintf(stderr,
"Unable to read asymmetric key\n");
1421 key + key_material_len / 2);
1440 fprintf(stderr,
"Unsupported algorithm\n");
1445 fprintf(stderr,
"Failed to store asymmetric key: %s\n",
yh_strerror(
yrc));
1449 fprintf(stderr,
"Stored Asymmetric key 0x%04x\n",
argv[1].w);
1477 fprintf(stderr,
"Failed to store authkey: %s\n",
yh_strerror(
yrc));
1481 fprintf(stderr,
"Stored Authentication key 0x%04x\n",
argv[1].w);
1505 fprintf(stderr,
"Failed to store opaque object: %s\n",
yh_strerror(
yrc));
1509 fprintf(stderr,
"Stored Opaque object 0x%04x\n",
argv[1].w);
1528 fprintf(stderr,
"Failed to store option: %s\n",
yh_strerror(
yrc));
1552 fprintf(stderr,
"Too long key supplied, max 128 bytes allowed\n");
1559 fprintf(stderr,
"Failed to store HMAC key: %s\n",
yh_strerror(
yrc));
1563 fprintf(stderr,
"Stored HMAC key 0x%04x\n",
argv[1].w);
1586 }
else if (
argv[6].
len == 24) {
1588 }
else if (
argv[6].
len == 32) {
1591 fprintf(stderr,
"Key length not matching, should be 16, 24 or 32\n");
1599 fprintf(stderr,
"Failed to store wrapkey: %s\n",
yh_strerror(
yrc));
1603 fprintf(stderr,
"Stored Wrap key 0x%04x\n",
argv[1].w);
1617 const char *type =
"";
1623 &object_type, &object_id);
1625 fprintf(stderr,
"Failed to store wrapped object: %s\n",
yh_strerror(
yrc));
1631 fprintf(stderr,
"Object imported as 0x%04x of type %s\n", object_id, type);
1655 fprintf(stderr,
"Failed to store template object: %s\n",
yh_strerror(
yrc));
1659 fprintf(stderr,
"Stored Template object 0x%04x\n",
argv[1].w);
1678 size_t response_len =
sizeof(response);
1682 switch (
argv[2].
a) {
1700 fprintf(stderr,
"Invalid hash algorithm\n");
1705 fprintf(stderr,
"Unable to hash file\n");
1712 fprintf(stderr,
"Failed to sign data with ecdsa: %s\n",
yh_strerror(
yrc));
1716 write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt));
1732 size_t response_len =
sizeof(response);
1735 fprintf(stderr,
"Invalid algorithm\n");
1740 response, &response_len);
1742 fprintf(stderr,
"Failed to sign data with eddsa: %s\n",
yh_strerror(
yrc));
1746 write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt));
1766 size_t response_len =
sizeof(response);
1770 switch (
argv[2].
a) {
1788 fprintf(stderr,
"Invalid hash algorithm\n");
1793 fprintf(stderr,
"Unable to hash file\n");
1798 response, &response_len);
1800 fprintf(stderr,
"Failed to sign data with PKCS#1v1.5: %s\n",
1805 write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt));
1824 size_t response_len =
sizeof(response);
1829 switch (
argv[2].
a) {
1851 fprintf(stderr,
"Invalid hash algorithm\n");
1856 fprintf(stderr,
"Unable to hash file\n");
1862 &response_len, data_len, mgf);
1864 fprintf(stderr,
"Failed to sign data with PSS: %s\n",
yh_strerror(
yrc));
1868 write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt));
1883 fprintf(stderr,
"Not connected\n");
1896 size_t n_algorithms =
sizeof(algorithms);
1900 &log_total, &log_used, algorithms, &n_algorithms);
1902 fprintf(stderr,
"Failed to get device info: %s\n",
yh_strerror(
yrc));
1907 fprintf(ctx->
out,
"Serial number:\t\t%u\n",
serial);
1908 fprintf(ctx->
out,
"Log used:\t\t%d/%d\n", log_used, log_total);
1910 fprintf(ctx->
out,
"Supported algorithms:\t");
1911 for (
size_t i = 0; i < n_algorithms; i++) {
1912 const char *algo_str;
1914 fprintf(ctx->
out,
"%s, ", algo_str);
1915 if ((i + 1) % 3 == 0 && i != 0) {
1916 fprintf(ctx->
out,
"\n\t\t\t");
1919 fprintf(ctx->
out,
"\n");
1936 size_t response_len =
sizeof(response);
1939 response, &response_len);
1945 write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt));
1961 fprintf(stderr,
"Failed to reset device: %s\n",
yh_strerror(
yrc));
1965 fprintf(ctx->
out,
"Device successfully reset\n");
1981 fprintf(stderr,
"Failed to delete object: %s\n",
yh_strerror(
yrc));
2003 size_t response_len =
sizeof(data);
2006 response_len -=
argv[4].len;
2012 fprintf(stderr,
"Failed to get certificate signature: %s\n",
2021 b64 = BIO_new(BIO_f_base64());
2022 bio = BIO_new(BIO_s_mem());
2023 bio = BIO_push(b64, bio);
2025 (void) BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
2026 (void) BIO_write(bio, data + 4 + 256,
2027 argv[4].
len + response_len - 4 -
2029 (void) BIO_flush(bio);
2030 (void) BIO_get_mem_ptr(bio, &bufferPtr);
2032 const char *ssh_cert_str =
2033 "ssh-rsa-cert-v01@openssh.com ";
2035 if (fwrite(ssh_cert_str, 1, strlen(ssh_cert_str), ctx->
out) !=
2036 strlen(ssh_cert_str) ||
2038 fprintf(stderr,
"Unable to write data to file\n");
2042 if (fwrite(bufferPtr->data, 1, bufferPtr->length, ctx->
out) !=
2043 bufferPtr->length ||
2045 fprintf(stderr,
"Unable to write data to file\n");
2049 if (fwrite(
"\n", 1, 1, ctx->
out) != 1 || ferror(ctx->
out)) {
2050 fprintf(stderr,
"Unable to write data to file\n");
2054 (void) BIO_free_all(bio);
2059static void time_elapsed(
struct timeval *after,
struct timeval *before,
2060 struct timeval *result) {
2061 result->tv_sec = after->tv_sec - before->tv_sec;
2062 result->tv_usec = after->tv_usec - before->tv_usec;
2063 if (result->tv_usec < 0) {
2065 result->tv_usec += 1000000;
2069static void time_add(
struct timeval *
a,
struct timeval *b,
2070 struct timeval *result) {
2071 result->tv_sec =
a->tv_sec + b->tv_sec;
2072 result->tv_usec =
a->tv_usec + b->tv_usec;
2073 if (result->tv_usec >= 1000000) {
2075 result->tv_usec -= 1000000;
2079static void time_average(
struct timeval *in,
size_t num,
2080 struct timeval *result) {
2081 time_t remains = in->tv_sec %
num;
2082 result->tv_sec = in->tv_sec /
num;
2083 result->tv_usec = in->tv_usec /
num;
2086 result->tv_usec += remains /
num;
2090static double time_tps(
struct timeval *in,
size_t num) {
2091 double time = in->tv_sec + (double) in->tv_usec / 1000000;
2095static bool time_less(
struct timeval *
a,
struct timeval *b) {
2096 if (
a->tv_sec < b->tv_sec) {
2098 }
else if (
a->tv_sec == b->tv_sec &&
a->tv_usec < b->tv_usec) {
2120 const char *special;
2160 {0, 0, 8,
"Random 8 bytes"},
2161 {0, 0, 16,
"Random 16 bytes"},
2162 {0, 0, 32,
"Random 32 bytes"},
2163 {0, 0, 64,
"Random 64 bytes"},
2164 {0, 0, 128,
"Random 128 bytes"},
2165 {0, 0, 256,
"Random 256 bytes"},
2166 {0, 0, 512,
"Random 512 bytes"},
2167 {0, 0, 1024,
"Random 1024 bytes"},
2173 "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f";
2174 const uint8_t otp_id[] =
"\x01\x02\x03\x04\x05\x06";
2176 "\x2f\x5d\x71\xa4\x91\x5d\xec\x30\x4a\xa1\x3c\xcf\x97\xbb\x0d\xbb";
2177 const uint8_t password[] =
"benchmark";
2179 if (
argv[1].
d == 0) {
2180 fprintf(stderr,
"Benchmark with 0 rounds seems pointless\n");
2184 for (
size_t i = 0; i <
sizeof(benchmarks) /
sizeof(benchmarks[0]); i++) {
2185 struct timeval total = {0, 0};
2186 struct timeval avg = {0, 0};
2187 struct timeval max = {0, 0};
2192 size_t algo_len =
sizeof(algo_data);
2193 const char *str1 = NULL, *str2 =
"", *str3 =
"";
2201 if (
argv[3].
a != 0) {
2202 if (
argv[3].
a != benchmarks[i].algo &&
argv[3].
a != benchmarks[i].algo2) {
2206 if (benchmarks[i].algo) {
2209 if (benchmarks[i].algo2) {
2221 fprintf(stderr,
"Doing benchmark setup for %s%s%s...", str1, str2,
2235 fprintf(stderr,
"Unknown benchmark algorithms\n");
2241 }
else if (
yh_is_ec(benchmarks[i].algo)) {
2253 fprintf(stderr,
"Failed ECDH setup\n");
2260 fprintf(stderr,
"Failed to get ECDH pubkey (%zu)\n", algo_len);
2263 algo_data[0] = 0x04;
2267 fprintf(stderr,
"Failed deleting temporary ec key\n");
2271 fprintf(stderr,
"Unknown benchmark algorithms\n");
2283 str3 = benchmarks[i].special;
2310 }
else if (strncmp(benchmarks[i].special,
"Random ", 7) == 0) {
2311 str1 = benchmarks[i].special;
2318 password,
sizeof(password));
2320 fprintf(stderr,
"Unknown benchmark algorithms\n");
2325 fprintf(stderr,
"Failed benchmark setup for %s%s%s\n", str1, str2, str3);
2329 memset(&min, 0x7f,
sizeof(min));
2334 struct timeval before, after, result;
2336 memset(data,
j,
sizeof(data));
2337 gettimeofday(&before, NULL);
2343 benchmarks[i].bytes, out, &
out_len);
2344 }
else if (
yh_is_rsa(benchmarks[i].algo) &&
2351 }
else if (
yh_is_ec(benchmarks[i].algo) &&
2358 }
else if (
yh_is_ec(benchmarks[i].algo) &&
2378 }
else if (strncmp(benchmarks[i].special,
"Random ", 7) == 0) {
2384 sizeof(password),
false, &
ses);
2392 fprintf(stderr,
"Unknown benchmark algorithm\n");
2396 gettimeofday(&after, NULL);
2399 fprintf(stderr,
"Failed running benchmark %u for %s%s%s\n",
j, str1,
2404 time_elapsed(&after, &before, &result);
2405 if (time_less(&result, &min)) {
2408 if (time_less(&max, &result)) {
2411 time_add(&result, &total, &total);
2412 time_average(&total,
j + 1, &avg);
2415 ioctl(fileno(stderr), TIOCGWINSZ, &w);
2417 if (chars > w.ws_col) {
2419 fprintf(stderr,
"\33[%zuF", chars / w.ws_col);
2422 fprintf(stderr,
"\33[1G");
2425 fprintf(stderr,
"\33[J");
2426 chars = fprintf(stderr,
2427 "%s%s%s (%u/%d times) total: %ld.%06ld avg: %ld.%06ld "
2428 "min: %ld.%06ld max: %ld.%06ld tps: %.06f",
2429 str1, str2, str3,
j + 1,
argv[1].w, total.tv_sec,
2430 (
long) total.tv_usec, avg.tv_sec, (
long) avg.tv_usec,
2431 min.tv_sec, (
long) min.tv_usec, max.tv_sec,
2432 (
long) max.tv_usec, time_tps(&total,
j + 1));
2438 "%s%s%s (%d times) total: %ld.%06ld avg: %ld.%06ld "
2439 "min: %ld.%06ld max: %ld.%06ld tps: %.06f",
2440 str1, str2, str3,
argv[1].w, total.tv_sec, (
long) total.tv_usec,
2441 avg.tv_sec, (
long) avg.tv_usec, min.tv_sec, (
long) min.tv_usec,
2442 max.tv_sec, (
long) max.tv_usec, time_tps(&total,
argv[1].w));
2445 fprintf(stderr,
"\n");
2465 size_t response_len =
sizeof(response);
2469 fprintf(stderr,
"Wrong length key supplied, has to be 16 bytes\n");
2474 fprintf(stderr,
"Wrong length id supplied, has to be 6 bytes\n");
2479 response, &response_len);
2482 fprintf(stderr,
"Failed to create OTP AEAD: %s\n",
yh_strerror(
yrc));
2486 if (
write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt))) {
2502 size_t response_len =
sizeof(response);
2509 fprintf(stderr,
"Failed to create OTP AEAD: %s\n",
yh_strerror(
yrc));
2513 if (
write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt))) {
2533 size_t otp_len =
sizeof(
otp);
2539 fprintf(stderr,
"Wrong length OTP supplied, has to be 16 bytes in hex\n");
2544 fprintf(stderr,
"Failed to decode OTP\n");
2549 &useCtr, &sessionCtr, &tstph, &tstpl);
2552 fprintf(stderr,
"Failed to decrypt OTP: %s\n",
yh_strerror(
yrc));
2556 fprintf(stderr,
"OTP decoded, useCtr:%d, sessionCtr:%d, tstph:%d, tstpl:%d\n",
2557 useCtr, sessionCtr, tstph, tstpl);
2570 size_t data_len =
sizeof(data);
2577 fprintf(stderr,
"Failed to attest asymmetric key: %s\n",
yh_strerror(
yrc));
2581 X509 *x509 = X509_new();
2582 const unsigned char *ptr = data;
2584 fprintf(stderr,
"Failed allocating x509 structure\n");
2587 x509 = d2i_X509(NULL, &ptr, data_len);
2589 fprintf(stderr,
"Failed parsing x509 information\n");
2592 PEM_write_X509(ctx->
out, x509);
2594 i2d_X509_fp(ctx->
out, x509);
2621 fprintf(stderr,
"Key length (%zu) not matching, should be 16, 24 or 32\n",
2630 fprintf(stderr,
"Failed to store OTP AEAD key: %s\n",
yh_strerror(
yrc));
2634 fprintf(stderr,
"Stored OTP AEAD key 0x%04x\n",
argv[1].w);
2660 fprintf(stderr,
"Failed to generate OTP AEAD key: %s\n",
yh_strerror(
yrc));
2664 fprintf(stderr,
"Generated OTP AEAD key 0x%04x\n",
argv[1].w);
2681 size_t response_len =
sizeof(response);
2689 switch (
argv[2].
a) {
2711 fprintf(stderr,
"Invalid hash algorithm\n");
2716 fprintf(stderr,
"Unable to hash data\n");
2723 fprintf(stderr,
"Failed to decrypt data with OAEP: %s\n",
yh_strerror(
yrc));
2727 write_file(response, response_len, ctx->
out, fmt_to_fmt(fmt));
2778 fprintf(stderr,
"Failed to change authentication key: %s\n",
2783 fprintf(stderr,
"Changed Authentication key 0x%04x\n",
argv[1].w);
int yh_com_sign_ssh_certificate(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_change_authentication_key(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_put_asymmetric(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_derive_ecdh(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_encrypt_aesccm(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_generate_otp_aead_key(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_blink(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_sign_pss(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_open_session(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_set_proxy(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_list_objects(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_generate_hmac(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_put_opaque(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_decrypt_oaep(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_noop(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_put_authentication(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_audit(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_get_storage(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_generate_wrap(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_decrypt_aesccm(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_otp_aead_random(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_reset(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_list_types(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_put_wrapped(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_debug_info(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_put_otp_aead_key(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_hmac(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_connect(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_pecho(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_sign_ecdsa(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_sign_pkcs1v1_5(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_generate_asymmetric(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_get_pubkey(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_get_option(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_close_session(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_put_wrapkey(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_list_capabilities(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_list_sessions(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_get_wrapped(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_disconnect(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_debug_raw(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_debug_none(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_sign_eddsa(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_get_template(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_list_algorithms(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_get_device_info(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_put_template(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_delete(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_debug_intermediate(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_otp_decrypt(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_get_opaque(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_debug_all(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_set_cacert(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_benchmark(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_put_option(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_otp_aead_create(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_decrypt_pkcs1v1_5(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_set_log_index(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_put_hmac(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_debug_error(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_sign_attestation_certificate(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_get_random(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_debug_crypto(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_echo(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_get_object_info(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
int yh_com_keepalive_on(yubihsm_context *ctx, Argument *argv, cmd_format fmt)
bool hash_bytes(const uint8_t *in, size_t len, hash_t hash, uint8_t *out, size_t *out_len)
#define insecure_memzero(buf, len)
const char * yh_strerror(yh_rc err)
int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Capabilities representation.
uint16_t second_key
ID of second Object used.
uint8_t result
Command result.
uint32_t systick
Systick at time of execution.
uint16_t session_key
ID of Authentication Key used.
uint16_t target_key
ID of first Object used.
uint16_t length
Length of in-data.
uint8_t command
What command was executed.
uint16_t number
Monotonically increasing index.
uint8_t sequence
Object sequence.
yh_session * sessions[YH_MAX_SESSIONS]
int algo2nid(yh_algorithm algo)
bool write_ed25519_key(uint8_t *buf, size_t buf_len, FILE *fp, bool b64_encode)
void format_digest(uint8_t *digest, char *str, uint16_t len)
bool write_file(const uint8_t *buf, size_t buf_len, FILE *fp, format_t format)
bool read_private_key(uint8_t *buf, size_t len, yh_algorithm *algo, uint8_t *bytes, size_t *bytes_len, bool internal_repr)
bool hex_decode(const char *in, uint8_t *out, size_t *len)
const char * ykyh_strerror(ykyh_rc err)
ykyh_rc ykyh_connect(ykyh_state *state, const char *wanted)
ykyh_rc ykyh_calculate(ykyh_state *state, const char *name, uint8_t *context, size_t context_len, const char *pw, uint8_t *key_s_enc, size_t key_s_enc_len, uint8_t *key_s_mac, size_t key_s_mac_len, uint8_t *key_s_rmac, size_t key_s_rmac_len, uint8_t *retries)
#define YKYH_MAX_NAME_LEN
#define YKYH_MIN_NAME_LEN
yh_rc yh_domains_to_string(uint16_t domains, char *string, size_t max_len)
bool yh_is_rsa(yh_algorithm algorithm)
yh_rc yh_util_get_option(yh_session *session, yh_option option, uint8_t *out, size_t *out_len)
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)
bool yh_is_ed(yh_algorithm algorithm)
yh_rc yh_get_verbosity(uint8_t *verbosity)
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)
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_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_set_verbosity(yh_connector *connector, uint8_t verbosity)
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)
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)
yh_rc yh_algo_to_string(yh_algorithm algo, char const **result)
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)
bool yh_is_ec(yh_algorithm algorithm)
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)
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)
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_generate_ed_key(yh_session *session, uint16_t *key_id, const char *label, uint16_t domains, const yh_capabilities *capabilities, yh_algorithm algorithm)
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)
yh_rc yh_util_get_template(yh_session *session, uint16_t object_id, uint8_t *out, size_t *out_len)
yh_rc yh_util_randomize_otp_aead(yh_session *session, uint16_t key_id, uint8_t *out, size_t *out_len)
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_sign_ecdsa(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_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_get_opaque(yh_session *session, uint16_t object_id, uint8_t *out, size_t *out_len)
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)
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)
yh_rc yh_util_reset_device(yh_session *session)
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)
yh_rc yh_util_close_session(yh_session *session)
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)
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)
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_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)
yh_rc yh_util_get_object_info(yh_session *session, uint16_t id, yh_object_type type, yh_object_descriptor *object)
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_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)
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)
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)
yh_rc yh_util_set_option(yh_session *session, yh_option option, size_t len, uint8_t *val)
yh_rc yh_util_change_authentication_key_derived(yh_session *session, uint16_t *key_id, const uint8_t *password, size_t password_len)
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_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)
yh_rc yh_set_connector_option(yh_connector *connector, yh_connector_option opt, const void *val)
yh_rc yh_init_connector(const char *url, yh_connector **connector)
yh_rc yh_util_set_log_index(yh_session *session, uint16_t index)
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)
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)
yh_rc yh_connect(yh_connector *connector, int timeout)
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)
yh_rc yh_util_get_public_key(yh_session *session, uint16_t id, uint8_t *data, size_t *data_len, yh_algorithm *algorithm)
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)
yh_rc yh_string_to_capabilities(const char *capability, yh_capabilities *result)
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)
yh_rc yh_disconnect(yh_connector *connector)
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)
yh_rc yh_capabilities_to_strings(const yh_capabilities *num, const char *result[], size_t *n_result)
bool yh_is_hmac(yh_algorithm algorithm)
yh_rc yh_util_blink_device(yh_session *session, uint8_t seconds)
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)
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)
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)
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)
yh_rc yh_util_delete_object(yh_session *session, uint16_t id, yh_object_type type)
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)
yh_rc yh_get_session_id(yh_session *session, uint8_t *sid)
yh_rc yh_util_get_pseudo_random(yh_session *session, size_t len, uint8_t *out, size_t *out_len)
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)
yh_rc yh_type_to_string(yh_object_type type, char const **result)
#define YH_ORIGIN_IMPORTED_WRAPPED
#define YH_VERB_ALL
Debug level all. All previous options enabled.
#define YH_ORIGIN_GENERATED
The object was generated on the device.
#define YH_ORIGIN_IMPORTED
The object was imported into the device.
#define YH_LOG_DIGEST_SIZE
Size that the log digest is truncated to.
#define YH_VERB_INFO
Debug level info. General information messages printed out.
@ YH_OTP_AEAD_KEY
OTP AEAD Key is a secret key used to decrypt Yubico OTP values.
@ YH_HMAC_KEY
HMAC Key is a secret key used when computing and verifying HMAC signatures.
@ YH_ASYMMETRIC_KEY
Asymmetric Key is the private key of an asymmetric key-pair.
@ YH_AUTHENTICATION_KEY
Authentication Key is used to establish Sessions with a device.
#define YH_MAX_ITEMS_COUNT
Max items the device may hold.
#define YH_OBJ_LABEL_LEN
Max length of object labels.
@ YH_ALGO_MGF1_SHA512
mgf1-sha512
@ YH_ALGO_RSA_PSS_SHA384
rsa-pss-sha384
@ YH_ALGO_RSA_PKCS1_SHA256
rsa-pkcs1-sha256
@ YH_ALGO_RSA_PKCS1_SHA1
rsa-pkcs1-sha1
@ YH_ALGO_RSA_PSS_SHA512
rsa-pss-sha512
@ YH_ALGO_EC_BP384
ecbp384
@ YH_ALGO_RSA_PSS_SHA1
rsa-pss-sha1
@ YH_ALGO_EC_ECDSA_SHA256
ecdsa-sha256
@ YH_ALGO_EC_ECDSA_SHA512
ecdsa-sha512
@ YH_ALGO_AES128_YUBICO_AUTHENTICATION
aes128-yubico-authentication
@ YH_ALGO_RSA_OAEP_SHA256
rsa-oaep-sha256
@ YH_ALGO_AES192_YUBICO_OTP
aes192-yubico-otp
@ YH_ALGO_AES128_YUBICO_OTP
aes128-yubico-otp
@ YH_ALGO_EC_ECDSA_SHA384
ecdsa-sha384
@ YH_ALGO_EC_ED25519
ed25519
@ YH_ALGO_HMAC_SHA512
hmac-sha512
@ YH_ALGO_HMAC_SHA384
hmac-sha384
@ YH_ALGO_MGF1_SHA384
mgf1-sha384
@ YH_ALGO_RSA_PKCS1_SHA512
rsa-pkcs1-sha512
@ YH_ALGO_AES256_CCM_WRAP
aes256-ccm-wrap
@ YH_ALGO_HMAC_SHA1
hmac-sha1
@ YH_ALGO_RSA_OAEP_SHA512
rsa-oaep-sha512
@ YH_ALGO_RSA_2048
rsa2048
@ YH_ALGO_HMAC_SHA256
hmac-sha256
@ YH_ALGO_RSA_OAEP_SHA384
rsa-oaep-sha384
@ YH_ALGO_AES192_CCM_WRAP
aes192-ccm-wrap
@ YH_ALGO_EC_BP512
ecbp512
@ YH_ALGO_EC_BP256
ecbp256
@ YH_ALGO_RSA_PSS_SHA256
rsa-pss-sha256
@ YH_ALGO_AES256_YUBICO_OTP
aes256-yubico-otp
@ YH_ALGO_MGF1_SHA1
mgf1-sha1
@ YH_ALGO_AES128_CCM_WRAP
aes128-ccm-wrap
@ YH_ALGO_MGF1_SHA256
mgf1-sha256
@ YH_ALGO_RSA_4096
rsa4096
@ YH_ALGO_EC_ECDSA_SHA1
ecdsa-sha1
@ YH_ALGO_RSA_OAEP_SHA1
rsa-oaep-sha1
@ YH_ALGO_RSA_PKCS1_SHA384
rsa-pkcs1-sha384
@ YH_ALGO_RSA_3072
rsa3072
#define YH_VERB_RAW
Debug level raw. Raw messages printed out.
@ YH_CONNECTOR_PROXY_SERVER
#define YH_MAX_ALGORITHM_COUNT
Max number of algorithms defined here.
#define YH_MSG_BUF_SIZE
Maximum length of message buffer.
#define YH_VERB_CRYPTO
Debug level crypto. Crypto results printed out.
#define YH_VERB_ERR
Debug level error. Error messages printed out.
#define YH_VERB_QUIET
Debug level quiet. No messages printed out.
#define YH_KEY_LEN
Length of authentication keys.
#define YH_CAPABILITIES_LEN
Length of capabilities array.
#define YH_MAX_SESSIONS
Max sessions the device may hold.
#define YH_MAX_LOG_ENTRIES
Max log entries the device may hold.
@ YHR_SUCCESS
Returned value when function was successful.
@ YHR_CONNECTION_ERROR
Returned value when a connection error was encountered.
#define YH_VERB_INTERMEDIATE
Debug level intermediate. Intermediate results printed out.
#define YH_CONTEXT_LEN
Length of context array for authentication.
yh_capabilities capabilities
yh_object_descriptor object
memset(pInfo->slotDescription, ' ', 64)
memcpy((char *) pInfo->slotDescription, s, l)
yh_capabilities delegated_capabilities