libyubihsm
yubihsm.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2018 Yubico AB
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
80 #ifndef YUBIHSM_H
81 #define YUBIHSM_H
82 
83 #include <stdint.h>
84 #include <stdbool.h>
85 #include <stddef.h>
86 #include <stdio.h>
87 
89 #define YH_CONTEXT_LEN 16
90 #define YH_HOST_CHAL_LEN 8
92 #define YH_MSG_BUF_SIZE 2048
94 #define YH_KEY_LEN 16
96 #define YH_VID 0x1050
98 #define YH_PID 0x0030
100 #define YH_CMD_RESP_FLAG 0x80
102 #define YH_MAX_ITEMS_COUNT 256
104 #define YH_MAX_SESSIONS 16
106 #define YH_DEFAULT_ENC_KEY \
108  "\x09\x0b\x47\xdb\xed\x59\x56\x54\x90\x1d\xee\x1c\xc6\x55\xe4\x20"
109 #define YH_DEFAULT_MAC_KEY \
111  "\x59\x2f\xd4\x83\xf7\x59\xe2\x99\x09\xa0\x4c\x45\x05\xd2\xce\x0a"
112 #define YH_DEFAULT_PASSWORD "password"
114 #define YH_DEFAULT_SALT "Yubico"
116 #define YH_DEFAULT_ITERS 10000
118 #define YH_CAPABILITIES_LEN 8
120 #define YH_MAX_LOG_ENTRIES 64
122 #define YH_OBJ_LABEL_LEN 40
124 #define YH_MAX_DOMAINS 16
126 #define YH_LOG_DIGEST_SIZE 16
128 #define YH_USB_URL_SCHEME "yhusb://"
130 
131 // Debug levels
133 #define YH_VERB_QUIET 0x00
134 #define YH_VERB_INTERMEDIATE 0x01
136 #define YH_VERB_CRYPTO 0x02
138 #define YH_VERB_RAW 0x04
140 #define YH_VERB_INFO 0x08
142 #define YH_VERB_ERR 0x10
144 #define YH_VERB_ALL 0xff
146 
149 #define YH_CCM_WRAP_OVERHEAD (1 + 13 + 16)
150 
151 #ifdef __cplusplus
152 extern "C" {
153 #endif
154 
156 typedef struct yh_connector yh_connector;
157 
159 typedef struct yh_session yh_session;
160 
162 typedef struct {
164  uint8_t capabilities[YH_CAPABILITIES_LEN];
166 
170 typedef enum {
235 } yh_rc;
236 
238 #define ADD_COMMAND(c, v) c = v, c##_R = v | YH_CMD_RESP_FLAG
239 
243 typedef enum {
348  YHC_ERROR = 0x7f,
349 } yh_cmd;
350 
351 #undef ADD_COMMAND
352 
359 typedef enum {
362  YH_OPAQUE = 0x01,
369  YH_WRAP_KEY = 0x04,
371  YH_HMAC_KEY = 0x05,
374  YH_TEMPLATE = 0x06,
381 
383 #define YH_MAX_ALGORITHM_COUNT 0xff
384 
390 typedef enum {
485 } yh_algorithm;
486 
490 typedef enum {
495 } yh_option;
496 
500 typedef enum {
508 
509 #pragma pack(push, 1)
510 
516 typedef struct {
518  uint16_t number;
520  uint8_t command;
522  uint16_t length;
524  uint16_t session_key;
526  uint16_t target_key;
528  uint16_t second_key;
530  uint8_t result;
532  uint32_t systick;
534  uint8_t digest[YH_LOG_DIGEST_SIZE];
535 } yh_log_entry;
536 
540 typedef struct {
544  uint16_t id;
546  uint16_t len;
548  uint16_t domains;
554  uint8_t sequence;
556  uint8_t origin;
558  char label[YH_OBJ_LABEL_LEN + 1];
562 #pragma pack(pop)
563 
564 static const struct {
565  const char *name;
566  int bit;
567 } yh_capability[] = {
568  {"change-authentication-key", 0x2e},
569  {"create-otp-aead", 0x1e},
570  {"decrypt-oaep", 0x0a},
571  {"decrypt-otp", 0x1d},
572  {"decrypt-pkcs", 0x09},
573  {"delete-asymmetric-key", 0x29},
574  {"delete-authentication-key", 0x28},
575  {"delete-hmac-key", 0x2b},
576  {"delete-opaque", 0x27},
577  {"delete-otp-aead-key", 0x2d},
578  {"delete-template", 0x2c},
579  {"delete-wrap-key", 0x2a},
580  {"derive-ecdh", 0x0b},
581  {"export-wrapped", 0x0c},
582  {"exportable-under-wrap", 0x10},
583  {"generate-asymmetric-key", 0x04},
584  {"generate-hmac-key", 0x15},
585  {"generate-otp-aead-key", 0x24},
586  {"generate-wrap-key", 0x0f},
587  {"get-log-entries", 0x18},
588  {"get-opaque", 0x00},
589  {"get-option", 0x12},
590  {"get-pseudo-random", 0x13},
591  {"get-template", 0x1a},
592  {"import-wrapped", 0x0d},
593  {"put-asymmetric-key", 0x03},
594  {"put-authentication-key", 0x02},
595  {"put-mac-key", 0x14},
596  {"put-opaque", 0x01},
597  {"put-otp-aead-key", 0x23},
598  {"put-template", 0x1b},
599  {"put-wrap-key", 0x0e},
600  {"randomize-otp-aead", 0x1f},
601  {"reset-device", 0x1c},
602  {"rewrap-from-otp-aead-key", 0x20},
603  {"rewrap-to-otp-aead-key", 0x21},
604  {"set-option", 0x11},
605  {"sign-attestation-certificate", 0x22},
606  {"sign-ecdsa", 0x07},
607  {"sign-eddsa", 0x08},
608  {"sign-hmac", 0x16},
609  {"sign-pkcs", 0x05},
610  {"sign-pss", 0x06},
611  {"sign-ssh-certificate", 0x19},
612  {"unwrap-data", 0x26},
613  {"verify-hmac", 0x17},
614  {"wrap-data", 0x25},
615 };
616 
617 static const struct {
618  const char *name;
619  yh_algorithm algorithm;
620 } yh_algorithms[] = {
621  {"aes128-ccm-wrap", YH_ALGO_AES128_CCM_WRAP},
622  {"aes128-yubico-authentication", YH_ALGO_AES128_YUBICO_AUTHENTICATION},
623  {"aes128-yubico-otp", YH_ALGO_AES128_YUBICO_OTP},
624  {"aes192-ccm-wrap", YH_ALGO_AES192_CCM_WRAP},
625  {"aes192-yubico-otp", YH_ALGO_AES192_YUBICO_OTP},
626  {"aes256-ccm-wrap", YH_ALGO_AES256_CCM_WRAP},
627  {"aes256-yubico-otp", YH_ALGO_AES256_YUBICO_OTP},
628  {"ecbp256", YH_ALGO_EC_BP256},
629  {"ecbp384", YH_ALGO_EC_BP384},
630  {"ecbp512", YH_ALGO_EC_BP512},
631  {"ecdh", YH_ALGO_EC_ECDH},
632  {"ecdsa-sha1", YH_ALGO_EC_ECDSA_SHA1},
633  {"ecdsa-sha256", YH_ALGO_EC_ECDSA_SHA256},
634  {"ecdsa-sha384", YH_ALGO_EC_ECDSA_SHA384},
635  {"ecdsa-sha512", YH_ALGO_EC_ECDSA_SHA512},
636  {"eck256", YH_ALGO_EC_K256},
637  {"ecp224", YH_ALGO_EC_P224},
638  {"ecp256", YH_ALGO_EC_P256},
639  {"ecp384", YH_ALGO_EC_P384},
640  {"ecp521", YH_ALGO_EC_P521},
641  {"ed25519", YH_ALGO_EC_ED25519},
642  {"hmac-sha1", YH_ALGO_HMAC_SHA1},
643  {"hmac-sha256", YH_ALGO_HMAC_SHA256},
644  {"hmac-sha384", YH_ALGO_HMAC_SHA384},
645  {"hmac-sha512", YH_ALGO_HMAC_SHA512},
646  {"mgf1-sha1", YH_ALGO_MGF1_SHA1},
647  {"mgf1-sha256", YH_ALGO_MGF1_SHA256},
648  {"mgf1-sha384", YH_ALGO_MGF1_SHA384},
649  {"mgf1-sha512", YH_ALGO_MGF1_SHA512},
650  {"opaque-data", YH_ALGO_OPAQUE_DATA},
651  {"opaque-x509-certificate", YH_ALGO_OPAQUE_X509_CERTIFICATE},
652  {"rsa-oaep-sha1", YH_ALGO_RSA_OAEP_SHA1},
653  {"rsa-oaep-sha256", YH_ALGO_RSA_OAEP_SHA256},
654  {"rsa-oaep-sha384", YH_ALGO_RSA_OAEP_SHA384},
655  {"rsa-oaep-sha512", YH_ALGO_RSA_OAEP_SHA512},
656  {"rsa-pkcs1-sha1", YH_ALGO_RSA_PKCS1_SHA1},
657  {"rsa-pkcs1-sha256", YH_ALGO_RSA_PKCS1_SHA256},
658  {"rsa-pkcs1-sha384", YH_ALGO_RSA_PKCS1_SHA384},
659  {"rsa-pkcs1-sha512", YH_ALGO_RSA_PKCS1_SHA512},
660  {"rsa-pss-sha1", YH_ALGO_RSA_PSS_SHA1},
661  {"rsa-pss-sha256", YH_ALGO_RSA_PSS_SHA256},
662  {"rsa-pss-sha384", YH_ALGO_RSA_PSS_SHA384},
663  {"rsa-pss-sha512", YH_ALGO_RSA_PSS_SHA512},
664  {"rsa2048", YH_ALGO_RSA_2048},
665  {"rsa3072", YH_ALGO_RSA_3072},
666  {"rsa4096", YH_ALGO_RSA_4096},
667  {"template-ssh", YH_ALGO_TEMPLATE_SSH},
668 };
669 
670 static const struct {
671  const char *name;
672  yh_object_type type;
673 } yh_types[] = {
674  {"authentication-key", YH_AUTHENTICATION_KEY},
675  {"asymmetric-key", YH_ASYMMETRIC_KEY},
676  {"hmac-key", YH_HMAC_KEY},
677  {"opaque", YH_OPAQUE},
678  {"otp-aead-key", YH_OTP_AEAD_KEY},
679  {"template", YH_TEMPLATE},
680  {"wrap-key", YH_WRAP_KEY},
681 };
682 
683 static const struct {
684  const char *name;
685  yh_option option;
686 } yh_options[] = {
687  {"command-audit", YH_OPTION_COMMAND_AUDIT},
688  {"force-audit", YH_OPTION_FORCE_AUDIT},
689 };
690 
692 #define YH_ORIGIN_GENERATED 0x01
693 #define YH_ORIGIN_IMPORTED 0x02
695 #define YH_ORIGIN_IMPORTED_WRAPPED 0x10
698 
706 const char *yh_strerror(yh_rc err);
707 
724 yh_rc yh_set_verbosity(yh_connector *connector, uint8_t verbosity);
725 
737 yh_rc yh_get_verbosity(uint8_t *verbosity);
738 
748 void yh_set_debug_output(yh_connector *connector, FILE *output);
749 
755 yh_rc yh_init(void);
756 
762 yh_rc yh_exit(void);
763 
776 yh_rc yh_init_connector(const char *url, yh_connector **connector);
777 
793  const void *val);
794 
805 yh_rc yh_connect(yh_connector *connector, int timeout);
806 
815 yh_rc yh_disconnect(yh_connector *connector);
816 
834  const uint8_t *data, size_t data_len,
835  yh_cmd *response_cmd, uint8_t *response,
836  size_t *response_len);
837 
852 yh_rc yh_send_secure_msg(yh_session *session, yh_cmd cmd, const uint8_t *data,
853  size_t data_len, yh_cmd *response_cmd,
854  uint8_t *response, size_t *response_len);
855 
880 yh_rc yh_create_session_derived(yh_connector *connector, uint16_t authkey_id,
881  const uint8_t *password, size_t password_len,
882  bool recreate_session, yh_session **session);
883 
909 yh_rc yh_create_session(yh_connector *connector, uint16_t authkey_id,
910  const uint8_t *key_enc, size_t key_enc_len,
911  const uint8_t *key_mac, size_t key_mac_len,
912  bool recreate_session, yh_session **session);
913 
937 yh_rc yh_begin_create_session_ext(yh_connector *connector, uint16_t authkey_id,
938  uint8_t **context, uint8_t *card_cryptogram,
939  size_t card_cryptogram_len,
940  yh_session **session);
941 
971  const uint8_t *key_senc, size_t key_senc_len,
972  const uint8_t *key_smac, size_t key_smac_len,
973  const uint8_t *key_srmac,
974  size_t key_srmac_len,
975  uint8_t *card_cryptogram,
976  size_t card_cryptogram_len);
977 
990 
1005 
1006 // Utility and convenience functions below
1007 
1030 yh_rc yh_util_get_device_info(yh_connector *connector, uint8_t *major,
1031  uint8_t *minor, uint8_t *patch, uint32_t *serial,
1032  uint8_t *log_total, uint8_t *log_used,
1033  yh_algorithm *algorithms, size_t *n_algorithms);
1034 
1067 yh_rc yh_util_list_objects(yh_session *session, uint16_t id,
1068  yh_object_type type, uint16_t domains,
1069  const yh_capabilities *capabilities,
1070  yh_algorithm algorithm, const char *label,
1071  yh_object_descriptor *objects, size_t *n_objects);
1072 
1088 yh_rc yh_util_get_object_info(yh_session *session, uint16_t id,
1089  yh_object_type type,
1090  yh_object_descriptor *object);
1091 
1106 yh_rc yh_util_get_public_key(yh_session *session, uint16_t id, uint8_t *data,
1107  size_t *data_len, yh_algorithm *algorithm);
1108 
1119 
1138 yh_rc yh_util_sign_pkcs1v1_5(yh_session *session, uint16_t key_id, bool hashed,
1139  const uint8_t *in, size_t in_len, uint8_t *out,
1140  size_t *out_len);
1141 
1163 yh_rc yh_util_sign_pss(yh_session *session, uint16_t key_id, const uint8_t *in,
1164  size_t in_len, uint8_t *out, size_t *out_len,
1165  size_t salt_len, yh_algorithm mgf1Algo);
1166 
1185 yh_rc yh_util_sign_ecdsa(yh_session *session, uint16_t key_id,
1186  const uint8_t *in, size_t in_len, uint8_t *out,
1187  size_t *out_len);
1188 
1204 yh_rc yh_util_sign_eddsa(yh_session *session, uint16_t key_id,
1205  const uint8_t *in, size_t in_len, uint8_t *out,
1206  size_t *out_len);
1207 
1223 yh_rc yh_util_sign_hmac(yh_session *session, uint16_t key_id, const uint8_t *in,
1224  size_t in_len, uint8_t *out, size_t *out_len);
1225 
1238 yh_rc yh_util_get_pseudo_random(yh_session *session, size_t len, uint8_t *out,
1239  size_t *out_len);
1240 
1262 yh_rc yh_util_import_rsa_key(yh_session *session, uint16_t *key_id,
1263  const char *label, uint16_t domains,
1264  const yh_capabilities *capabilities,
1265  yh_algorithm algorithm, const uint8_t *p,
1266  const uint8_t *q);
1267 
1291 yh_rc yh_util_import_ec_key(yh_session *session, uint16_t *key_id,
1292  const char *label, uint16_t domains,
1293  const yh_capabilities *capabilities,
1294  yh_algorithm algorithm, const uint8_t *s);
1295 
1313 yh_rc yh_util_import_ed_key(yh_session *session, uint16_t *key_id,
1314  const char *label, uint16_t domains,
1315  const yh_capabilities *capabilities,
1316  yh_algorithm algorithm, const uint8_t *k);
1317 
1338 yh_rc yh_util_import_hmac_key(yh_session *session, uint16_t *key_id,
1339  const char *label, uint16_t domains,
1340  const yh_capabilities *capabilities,
1341  yh_algorithm algorithm, const uint8_t *key,
1342  size_t key_len);
1343 
1362 yh_rc yh_util_generate_rsa_key(yh_session *session, uint16_t *key_id,
1363  const char *label, uint16_t domains,
1364  const yh_capabilities *capabilities,
1365  yh_algorithm algorithm);
1366 
1389 yh_rc yh_util_generate_ec_key(yh_session *session, uint16_t *key_id,
1390  const char *label, uint16_t domains,
1391  const yh_capabilities *capabilities,
1392  yh_algorithm algorithm);
1393 
1412 yh_rc yh_util_generate_ed_key(yh_session *session, uint16_t *key_id,
1413  const char *label, uint16_t domains,
1414  const yh_capabilities *capabilities,
1415  yh_algorithm algorithm);
1416 
1434 yh_rc yh_util_verify_hmac(yh_session *session, uint16_t key_id,
1435  const uint8_t *signature, size_t signature_len,
1436  const uint8_t *data, size_t data_len, bool *verified);
1437 
1457 yh_rc yh_util_generate_hmac_key(yh_session *session, uint16_t *key_id,
1458  const char *label, uint16_t domains,
1459  const yh_capabilities *capabilities,
1460  yh_algorithm algorithm);
1461 
1478 yh_rc yh_util_decrypt_pkcs1v1_5(yh_session *session, uint16_t key_id,
1479  const uint8_t *in, size_t in_len, uint8_t *out,
1480  size_t *out_len);
1481 
1502 yh_rc yh_util_decrypt_oaep(yh_session *session, uint16_t key_id,
1503  const uint8_t *in, size_t in_len, uint8_t *out,
1504  size_t *out_len, const uint8_t *label,
1505  size_t label_len, yh_algorithm mgf1Algo);
1506 
1524 yh_rc yh_util_derive_ecdh(yh_session *session, uint16_t key_id,
1525  const uint8_t *in, size_t in_len, uint8_t *out,
1526  size_t *out_len);
1527 
1540 yh_rc yh_util_delete_object(yh_session *session, uint16_t id,
1541  yh_object_type type);
1542 
1557 yh_rc yh_util_export_wrapped(yh_session *session, uint16_t wrapping_key_id,
1558  yh_object_type target_type, uint16_t target_id,
1559  uint8_t *out, size_t *out_len);
1560 
1576 yh_rc yh_util_import_wrapped(yh_session *session, uint16_t wrapping_key_id,
1577  const uint8_t *in, size_t in_len,
1578  yh_object_type *target_type, uint16_t *target_id);
1579 
1606 yh_rc yh_util_import_wrap_key(yh_session *session, uint16_t *key_id,
1607  const char *label, uint16_t domains,
1608  const yh_capabilities *capabilities,
1609  yh_algorithm algorithm,
1610  const yh_capabilities *delegated_capabilities,
1611  const uint8_t *in, size_t in_len);
1612 
1635 yh_rc yh_util_generate_wrap_key(yh_session *session, uint16_t *key_id,
1636  const char *label, uint16_t domains,
1637  const yh_capabilities *capabilities,
1638  yh_algorithm algorithm,
1639  const yh_capabilities *delegated_capabilities);
1640 
1663 yh_rc yh_util_get_log_entries(yh_session *session, uint16_t *unlogged_boot,
1664  uint16_t *unlogged_auth, yh_log_entry *out,
1665  size_t *n_items);
1666 
1682 yh_rc yh_util_set_log_index(yh_session *session, uint16_t index);
1683 
1696 yh_rc yh_util_get_opaque(yh_session *session, uint16_t object_id, uint8_t *out,
1697  size_t *out_len);
1698 
1719 yh_rc yh_util_import_opaque(yh_session *session, uint16_t *object_id,
1720  const char *label, uint16_t domains,
1721  const yh_capabilities *capabilities,
1722  yh_algorithm algorithm, const uint8_t *in,
1723  size_t in_len);
1724 
1743 yh_rc yh_util_sign_ssh_certificate(yh_session *session, uint16_t key_id,
1744  uint16_t template_id, yh_algorithm sig_algo,
1745  const uint8_t *in, size_t in_len,
1746  uint8_t *out, size_t *out_len);
1747 
1774  yh_session *session, uint16_t *key_id, const char *label, uint16_t domains,
1775  const yh_capabilities *capabilities,
1776  const yh_capabilities *delegated_capabilities, const uint8_t *key_enc,
1777  size_t key_enc_len, const uint8_t *key_mac, size_t key_mac_len);
1778 
1802  yh_session *session, uint16_t *key_id, const char *label, uint16_t domains,
1803  const yh_capabilities *capabilities,
1804  const yh_capabilities *delegated_capabilities, const uint8_t *password,
1805  size_t password_len);
1806 
1827 yh_rc yh_util_change_authentication_key(yh_session *session, uint16_t *key_id,
1828  const uint8_t *key_enc,
1829  size_t key_enc_len,
1830  const uint8_t *key_mac,
1831  size_t key_mac_len);
1832 
1852  uint16_t *key_id,
1853  const uint8_t *password,
1854  size_t password_len);
1855 
1868 yh_rc yh_util_get_template(yh_session *session, uint16_t object_id,
1869  uint8_t *out, size_t *out_len);
1870 
1891 yh_rc yh_util_import_template(yh_session *session, uint16_t *object_id,
1892  const char *label, uint16_t domains,
1893  const yh_capabilities *capabilities,
1894  yh_algorithm algorithm, const uint8_t *in,
1895  size_t in_len);
1896 
1911 yh_rc yh_util_create_otp_aead(yh_session *session, uint16_t key_id,
1912  const uint8_t *key, const uint8_t *private_id,
1913  uint8_t *out, size_t *out_len);
1914 
1927 yh_rc yh_util_randomize_otp_aead(yh_session *session, uint16_t key_id,
1928  uint8_t *out, size_t *out_len);
1929 
1948 yh_rc yh_util_decrypt_otp(yh_session *session, uint16_t key_id,
1949  const uint8_t *aead, size_t aead_len,
1950  const uint8_t *otp, uint16_t *useCtr,
1951  uint8_t *sessionCtr, uint8_t *tstph, uint16_t *tstpl);
1952 
1973 yh_rc yh_util_import_otp_aead_key(yh_session *session, uint16_t *key_id,
1974  const char *label, uint16_t domains,
1975  const yh_capabilities *capabilities,
1976  uint32_t nonce_id, const uint8_t *in,
1977  size_t in_len);
1978 
1999 yh_rc yh_util_generate_otp_aead_key(yh_session *session, uint16_t *key_id,
2000  const char *label, uint16_t domains,
2001  const yh_capabilities *capabilities,
2002  yh_algorithm algorithm, uint32_t nonce_id);
2003 
2018 yh_rc yh_util_sign_attestation_certificate(yh_session *session, uint16_t key_id,
2019  uint16_t attest_id, uint8_t *out,
2020  size_t *out_len);
2021 
2035 yh_rc yh_util_set_option(yh_session *session, yh_option option, size_t len,
2036  uint8_t *val);
2037 
2050 yh_rc yh_util_get_option(yh_session *session, yh_option option, uint8_t *out,
2051  size_t *out_len);
2052 
2068 yh_rc yh_util_get_storage_info(yh_session *session, uint16_t *total_records,
2069  uint16_t *free_records, uint16_t *total_pages,
2070  uint16_t *free_pages, uint16_t *page_size);
2071 
2087 yh_rc yh_util_wrap_data(yh_session *session, uint16_t key_id, const uint8_t *in,
2088  size_t in_len, uint8_t *out, size_t *out_len);
2089 
2105 yh_rc yh_util_unwrap_data(yh_session *session, uint16_t key_id,
2106  const uint8_t *in, size_t in_len, uint8_t *out,
2107  size_t *out_len);
2108 
2119 yh_rc yh_util_blink_device(yh_session *session, uint8_t seconds);
2120 
2132 
2142 yh_rc yh_get_session_id(yh_session *session, uint8_t *sid);
2143 
2152 bool yh_connector_has_device(yh_connector *connector);
2153 
2165 yh_rc yh_get_connector_version(yh_connector *connector, uint8_t *major,
2166  uint8_t *minor, uint8_t *patch);
2167 
2177 yh_rc yh_get_connector_address(yh_connector *connector, char **const address);
2178 
2201 yh_rc yh_string_to_capabilities(const char *capability,
2202  yh_capabilities *result);
2203 
2219  const char *result[], size_t *n_result);
2220 
2242 bool yh_check_capability(const yh_capabilities *capabilities,
2243  const char *capability);
2244 
2260  yh_capabilities *result);
2261 
2277 yh_rc yh_filter_capabilities(const yh_capabilities *capabilities,
2278  const yh_capabilities *filter,
2279  yh_capabilities *result);
2280 
2292 bool yh_is_rsa(yh_algorithm algorithm);
2293 
2306 bool yh_is_ec(yh_algorithm algorithm);
2307 
2317 bool yh_is_ed(yh_algorithm algorithm);
2318 
2330 bool yh_is_hmac(yh_algorithm algorithm);
2331 
2343 yh_rc yh_get_key_bitlength(yh_algorithm algorithm, size_t *result);
2344 
2358 yh_rc yh_algo_to_string(yh_algorithm algo, char const **result);
2359 
2383 yh_rc yh_string_to_algo(const char *string, yh_algorithm *algo);
2384 
2406 yh_rc yh_type_to_string(yh_object_type type, char const **result);
2407 
2431 yh_rc yh_string_to_type(const char *string, yh_object_type *type);
2432 
2455 yh_rc yh_string_to_option(const char *string, yh_option *option);
2456 
2470 bool yh_verify_logs(yh_log_entry *logs, size_t n_items,
2471  yh_log_entry *last_previous_log);
2472 
2505 yh_rc yh_string_to_domains(const char *domains, uint16_t *result);
2506 
2527 yh_rc yh_domains_to_string(uint16_t domains, char *string, size_t max_len);
2528 #ifdef __cplusplus
2529 }
2530 #endif
2531 
2532 #endif
opaque-data
Definition: yubihsm.h:450
yh_rc yh_algo_to_string(yh_algorithm algo, char const **result)
Convert an algorithm to its string representation.
Verify a generated HMAC.
Definition: yubihsm.h:313
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.
Generate an HMAC Key in the device.
Definition: yubihsm.h:309
mgf1-sha256
Definition: yubihsm.h:456
yh_rc yh_set_connector_option(yh_connector *connector, yh_connector_option opt, const void *val)
Set connector options.
Asymmetric Key is the private key of an asymmetric key-pair.
Definition: yubihsm.h:366
yh_rc yh_string_to_algo(const char *string, yh_algorithm *algo)
Convert a string to an algorithm&#39;s numeric value.
ecdh
Definition: yubihsm.h:438
uint8_t command
What command was executed.
Definition: yubihsm.h:520
Get a fixed number of pseudo-random bytes from the device.
Definition: yubihsm.h:291
Return value when encountering SSH CA constraint violation.
Definition: yubihsm.h:234
#define YH_LOG_DIGEST_SIZE
Size that the log digest is truncated to.
Definition: yubihsm.h:127
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.
void yh_set_debug_output(yh_connector *connector, FILE *output)
Set file for debug output.
mgf1-sha1
Definition: yubihsm.h:454
uint16_t length
Length of in-data.
Definition: yubihsm.h:522
yh_cmd
Command definitions.
Definition: yubihsm.h:243
Authenticate the session to the device.
Definition: yubihsm.h:249
Get all metadata about an Object.
Definition: yubihsm.h:285
aes128-yubico-otp
Definition: yubihsm.h:464
yh_rc yh_util_close_session(yh_session *session)
Close a 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)
Decrypt data that was encrypted using RSA-PKCS#1v1.5.
Returned value when there is not enough space to store data.
Definition: yubihsm.h:187
#define YH_CAPABILITIES_LEN
Length of capabilities array.
Definition: yubihsm.h:119
HMAC Key is a secret key used when computing and verifying HMAC signatures.
Definition: yubihsm.h:371
aes128-yubico-authentication
Definition: yubihsm.h:466
rsa-pkcs1-sha384
Definition: yubihsm.h:396
Re-encrypt a Yubico OTP AEAD from one OTP AEAD Key to another OTP AEAD Key.
Definition: yubihsm.h:327
Returned value when unable to allocate memory.
Definition: yubihsm.h:174
ecp256
Definition: yubihsm.h:414
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.
rsa-oaep-sha384
Definition: yubihsm.h:444
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.
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.
Import an Asymmetric Key into the device.
Definition: yubihsm.h:267
hmac-sha256
Definition: yubihsm.h:430
yh_option
Global options.
Definition: yubihsm.h:490
hmac-sha1
Definition: yubihsm.h:428
Returned value when a connection error was encountered.
Definition: yubihsm.h:178
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.
template-ssh
Definition: yubihsm.h:462
Replace the Authentication Key used to establish the current Session.
Definition: yubihsm.h:345
yh_rc yh_destroy_session(yh_session **session)
Free data associated with the session.
rsa3072
Definition: yubihsm.h:410
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.
Enable/Disable Forced Audit mode.
Definition: yubihsm.h:492
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.
yh_rc yh_get_connector_version(yh_connector *connector, uint8_t *major, uint8_t *minor, uint8_t *patch)
Get the connector version.
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.
Echo data back from the device.
Definition: yubihsm.h:245
Enable/Disable logging of specific commands.
Definition: yubihsm.h:494
Sign data using RSA-PKCS#1v1.5.
Definition: yubihsm.h:271
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...
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.
Delete object in the device.
Definition: yubihsm.h:305
Import an Opaque Object into the device.
Definition: yubihsm.h:261
ecdsa-sha384
Definition: yubihsm.h:478
yh_rc yh_filter_capabilities(const yh_capabilities *capabilities, const yh_capabilities *filter, yh_capabilities *result)
Filter one set of capabilities with another.
yh_object_type type
Object type.
Definition: yubihsm.h:550
Import an Authentication Key into the device.
Definition: yubihsm.h:265
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.
Logging struct as returned by device.
Definition: yubihsm.h:516
Get a device-global option.
Definition: yubihsm.h:289
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.
Create a session with the device.
Definition: yubihsm.h:247
uint8_t result
Command result.
Definition: yubihsm.h:530
aes256-ccm-wrap
Definition: yubihsm.h:474
Perform an HMAC operation in the device.
Definition: yubihsm.h:295
ecdsa-sha512
Definition: yubihsm.h:480
uint8_t origin
Object origin.
Definition: yubihsm.h:556
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 dev...
Returned value when failing to initialize libyubihsm.
Definition: yubihsm.h:176
Opaque Object is an unchecked kind of Object, normally used to store raw data in the device...
Definition: yubihsm.h:362
bool yh_check_capability(const yh_capabilities *capabilities, const char *capability)
Check if a capability is set.
Generate an OTP AEAD Key in the device.
Definition: yubihsm.h:333
Get attestation of an Asymmetric Key.
Definition: yubihsm.h:329
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.
struct yh_session yh_session
Reference to a session.
Definition: yubihsm.h:159
ecdsa-sha1
Definition: yubihsm.h:436
ecp521
Definition: yubihsm.h:418
Return value when the device fails to encrypt or verify the message.
Definition: yubihsm.h:203
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.
rsa2048
Definition: yubihsm.h:408
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.
yh_rc yh_util_blink_device(yh_session *session, uint8_t seconds)
Blink the LED of the device to identify it.
#define ADD_COMMAND(c, v)
Macro to define command and response command.
Definition: yubihsm.h:238
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.
Sign data using ECDSA.
Definition: yubihsm.h:301
uint8_t sequence
Object sequence.
Definition: yubihsm.h:554
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.
hmac-sha384
Definition: yubihsm.h:432
rsa-pss-sha1
Definition: yubihsm.h:400
yh_rc yh_domains_to_string(uint16_t domains, char *string, size_t max_len)
Convert domains parameter to its String representation.
Get an Opaque Object from device.
Definition: yubihsm.h:263
yh_capabilities delegated_capabilities
Object delegated capabilities.
Definition: yubihsm.h:560
Return value when failing to create a device session.
Definition: yubihsm.h:207
yh_rc yh_disconnect(yh_connector *connector)
Disconnect from a connector.
List objects in the device.
Definition: yubihsm.h:273
Get a template from the device.
Definition: yubihsm.h:319
aes256-yubico-otp
Definition: yubihsm.h:470
rsa-pkcs1-sha1
Definition: yubihsm.h:392
Sign data using RSA-PSS.
Definition: yubihsm.h:299
Generate an OTP AEAD from random data.
Definition: yubihsm.h:325
hmac-sha512
Definition: yubihsm.h:434
Set the last extracted audit log entry.
Definition: yubihsm.h:335
yh_rc yh_util_get_option(yh_session *session, yh_option option, uint8_t *out, size_t *out_len)
Get a device-global option.
Return value when an invalid OTP is submitted.
Definition: yubihsm.h:222
Return value when the permissions to perform the operation are wrong.
Definition: yubihsm.h:214
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 dev...
Return value when there is a mismatch between expected and received length of an argument to a functi...
Definition: yubihsm.h:212
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.
Generate an Asymmetric Key in the device.
Definition: yubihsm.h:269
Returned value when an argument to a function is invalid.
Definition: yubihsm.h:182
Import a Wrap Key into the device.
Definition: yubihsm.h:281
Returned value when failing to verify cryptogram.
Definition: yubihsm.h:189
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.
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.
bool yh_is_rsa(yh_algorithm algorithm)
Check if an algorithm is a supported RSA algorithm.
yh_rc yh_set_verbosity(yh_connector *connector, uint8_t verbosity)
Set verbosity level when executing commands.
yh_rc yh_string_to_option(const char *string, yh_option *option)
Convert a string to an option&#39;s numeric value.
yh_rc yh_get_session_id(yh_session *session, uint8_t *sid)
Get the session ID.
mgf1-sha512
Definition: yubihsm.h:460
yh_rc yh_string_to_type(const char *string, yh_object_type *type)
Convert a string to a type&#39;s numeric value.
yh_rc yh_merge_capabilities(const yh_capabilities *a, const yh_capabilities *b, yh_capabilities *result)
Merge two sets of capabilities.
Returned value when function was successful.
Definition: yubihsm.h:172
yh_rc yh_authenticate_session(yh_session *session)
Authenticate session.
Template is a binary object used for example to validate SSH certificate requests.
Definition: yubihsm.h:374
yh_algorithm algorithm
Object algorithm.
Definition: yubihsm.h:552
bool yh_is_hmac(yh_algorithm algorithm)
Check if algorithm is a supported HMAC algorithm.
ed25519
Definition: yubihsm.h:482
Set a device-global options that affect general behavior.
Definition: yubihsm.h:287
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.
yh_rc yh_util_set_option(yh_session *session, yh_option option, size_t len, uint8_t *val)
Set a device-global option.
ecbp256
Definition: yubihsm.h:422
uint16_t session_key
ID of Authentication Key used.
Definition: yubihsm.h:524
Decrypt data using RSA-OAEP.
Definition: yubihsm.h:307
Returned value when the device receives and invalid command.
Definition: yubihsm.h:197
rsa-pss-sha512
Definition: yubihsm.h:406
yh_rc yh_util_delete_object(yh_session *session, uint16_t id, yh_object_type type)
Delete an object in the device.
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.
yh_rc yh_string_to_domains(const char *domains, uint16_t *result)
Convert a string to a domain&#39;s numeric value.
uint16_t domains
Object domains.
Definition: yubihsm.h:548
bool yh_is_ed(yh_algorithm algorithm)
Check if an algorithm is a supported ED algorithm.
rsa-pkcs1-sha512
Definition: yubihsm.h:398
opaque-x509-certificate
Definition: yubihsm.h:452
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...
ecp384
Definition: yubihsm.h:416
yh_rc yh_init_connector(const char *url, yh_connector **connector)
Instantiate a new connector.
rsa-pkcs1-sha256
Definition: yubihsm.h:394
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.
Perform an ECDH key exchange operation with a private key in the device.
Definition: yubihsm.h:303
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.
ecbp384
Definition: yubihsm.h:424
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.
rsa-oaep-sha256
Definition: yubihsm.h:442
Get storage information.
Definition: yubihsm.h:259
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.
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.
yh_object_type
Object types.
Definition: yubihsm.h:359
Capabilities representation.
Definition: yubihsm.h:162
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.
rsa-pss-sha384
Definition: yubihsm.h:404
Import a template into the device.
Definition: yubihsm.h:317
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.
Blink the LED of the device.
Definition: yubihsm.h:343
Get an Object under wrap from the device.
Definition: yubihsm.h:277
bool yh_is_ec(yh_algorithm algorithm)
Check if an algorithm is a supported Elliptic Curve algorithm.
Decrypt data that was encrypted using RSA-PKCS#1v1.5.
Definition: yubihsm.h:275
ecbp512
Definition: yubihsm.h:426
OTP AEAD Key is a secret key used to decrypt Yubico OTP values.
Definition: yubihsm.h:376
Authentication Key is used to establish Sessions with a device.
Definition: yubihsm.h:364
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.
Returned value when there is a mismatch between expected and received length of an argument to a func...
Definition: yubihsm.h:185
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.
rsa-pss-sha256
Definition: yubihsm.h:402
Create a Yubico OTP AEAD.
Definition: yubihsm.h:323
ecp224
Definition: yubihsm.h:484
Public Key is the public key of an asymmetric key-pair.
Definition: yubihsm.h:379
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.
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.
bool yh_connector_has_device(yh_connector *connector)
Check if the connector has a device connected.
Returned value when the device session is invalid.
Definition: yubihsm.h:201
yh_rc yh_util_reset_device(yh_session *session)
Factory reset the device.
Import a HMAC key into the device.
Definition: yubihsm.h:293
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.
Sign SSH certificate request.
Definition: yubihsm.h:315
yh_rc yh_type_to_string(yh_object_type type, char const **result)
Convert a yh_object_type to its string representation.
yh_rc
Return codes.
Definition: yubihsm.h:170
yh_rc yh_get_verbosity(uint8_t *verbosity)
Get verbosity level when executing commands.
Encrypt (wrap) data using a Wrap Key.
Definition: yubihsm.h:337
Returned value when the device returned no error.
Definition: yubihsm.h:195
struct yh_connector yh_connector
Reference to a connector.
Definition: yubihsm.h:156
Return value when the command execution has not terminated.
Definition: yubihsm.h:226
yh_rc yh_get_connector_address(yh_connector *connector, char **const address)
Get connector address.
Get the public key of an Asymmetric Key in the device.
Definition: yubihsm.h:297
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.
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.
uint16_t len
Object length.
Definition: yubihsm.h:546
Returned value when failing to authenticate the session.
Definition: yubihsm.h:191
yh_algorithm
Algorithms.
Definition: yubihsm.h:390
uint16_t second_key
ID of second Object used.
Definition: yubihsm.h:528
uint32_t systick
Systick at time of execution.
Definition: yubihsm.h:532
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.
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.
The response byte returned from the device if the command resulted in an error.
Definition: yubihsm.h:348
Decrypt (unwrap) data using a Wrap Key.
Definition: yubihsm.h:339
Generate a Wrap Key in the device.
Definition: yubihsm.h:311
Return value when trying to add an object with an ID that already exists.
Definition: yubihsm.h:230
uint16_t target_key
ID of first Object used.
Definition: yubihsm.h:526
Import an OTP AEAD Key into the device.
Definition: yubihsm.h:331
aes192-ccm-wrap
Definition: yubihsm.h:472
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.
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.
yh_rc yh_init(void)
Global library initialization.
yh_rc yh_string_to_capabilities(const char *capability, yh_capabilities *result)
Convert capability string to byte array.
uint16_t number
Monotonically increasing index.
Definition: yubihsm.h:518
Get all current audit log entries from the device Log Store.
Definition: yubihsm.h:283
Factory reset a device.
Definition: yubihsm.h:255
Return value when connector operation failed.
Definition: yubihsm.h:232
Sign data using EdDSA.
Definition: yubihsm.h:341
rsa-oaep-sha512
Definition: yubihsm.h:446
uint16_t id
Object ID.
Definition: yubihsm.h:544
Close session.
Definition: yubihsm.h:257
yh_rc yh_exit(void)
Global library clean up.
Decrypt a Yubico OTP.
Definition: yubihsm.h:321
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 &#39;,&#39;.
yh_rc yh_connect(yh_connector *connector, int timeout)
Connect to the device through the specified connector.
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.
mgf1-sha384
Definition: yubihsm.h:458
File with CA certificate to validate the connector with (const char *).
Definition: yubihsm.h:503
#define YH_OBJ_LABEL_LEN
Max length of object labels.
Definition: yubihsm.h:123
bool yh_verify_logs(yh_log_entry *logs, size_t n_items, yh_log_entry *last_previous_log)
Verify an array of log entries.
Return value when no more sessions can be opened on the device.
Definition: yubihsm.h:205
rsa-oaep-sha1
Definition: yubihsm.h:440
aes128-ccm-wrap
Definition: yubihsm.h:448
yh_capabilities capabilities
Object capabilities.
Definition: yubihsm.h:542
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.
Object descriptor.
Definition: yubihsm.h:540
Proxy server to use for connecting to the connector (const char *).
Definition: yubihsm.h:506
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.
yh_connector_option
Options for the connector, set with yh_set_connector_option()
Definition: yubihsm.h:500
Return value when an invalid Object ID is used.
Definition: yubihsm.h:220
eck256
Definition: yubihsm.h:420
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.
Return value when encountering a storage failure on the device.
Definition: yubihsm.h:209
ecdsa-sha256
Definition: yubihsm.h:476
Return value when the device is in demo mode and has to be power cycled.
Definition: yubihsm.h:224
Import a wrapped Object into the device.
Definition: yubihsm.h:279
Return value when encountering an unknown error.
Definition: yubihsm.h:228
Get device metadata.
Definition: yubihsm.h:253
Returned value when the device receives a malformed command invalid data.
Definition: yubihsm.h:199
aes192-yubico-otp
Definition: yubihsm.h:468
Return value when the log buffer is full and forced audit is set.
Definition: yubihsm.h:216
const char * yh_strerror(yh_rc err)
Return a string describing an error condition.
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.
Wrap Key is a secret key used to wrap and unwrap Objects during the export and import process...
Definition: yubihsm.h:369
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.
Return value when the object not found on the device.
Definition: yubihsm.h:218
Returned value when failing to verify MAC.
Definition: yubihsm.h:193
yh_rc yh_util_set_log_index(yh_session *session, uint16_t index)
Set the index of the last extracted log entry.
Send a command over an established session.
Definition: yubihsm.h:251
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.
Returned value when failing to find a suitable connector.
Definition: yubihsm.h:180
rsa4096
Definition: yubihsm.h:412