Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
ykyh.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
17#ifndef YKYH_H
18#define YKYH_H
19
20#include <stdint.h>
21#include <stddef.h>
22
23//#include <ykyh-version.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29// INS codes
30#define YKYH_INS_PUT 0x01
31#define YKYH_INS_DELETE 0x02
32#define YKYH_INS_CALCULATE 0x03
33#define YKYH_INS_GET_CHALLENGE 0x04
34#define YKYH_INS_LIST 0x05
35#define YKYH_INS_RESET 0x06
36#define YKYH_INS_GET_VERSION 0x07
37
38// P1 bytes
39#define YKYH_P1_RESET 0xde
40
41// P2 bytes
42#define YKYH_P2_RESET 0xad
43
44// Tag codes
45#define YKYH_TAG_NAME 0x71
46#define YKYH_TAG_NAME_LIST 0x72
47#define YKYH_TAG_PW 0x73
48#define YKYH_TAG_ALGO 0x74
49#define YKYH_TAG_KEY_ENC 0x75
50#define YKYH_TAG_KEY_MAC 0x76
51#define YKYH_TAG_CONTEXT 0x77
52#define YKYH_TAG_RESPONSE 0x78
53#define YKYH_TAG_VERSION 0x79
54#define YKYH_TAG_TOUCH 0x7a
55
56// Algos
57#define YKYH_SCP03_ALGO 38
58#define YKYH_SCP11_ALGO 39
59
60#define SW_SUCCESS 0x9000
61#define SW_ERR_AUTHENTICATION_FAILED 0x63c0
62
63// Lengths
64#define YKYH_MIN_NAME_LEN 1
65#define YKYH_MAX_NAME_LEN 64
66#define YKYH_KEY_LEN 16
67#define YKYH_PW_LEN 16
68#define YKYH_CONTEXT_LEN 16
69
70// PBKDF2 derivation parameters
71#define YKYH_DEFAULT_SALT "Yubico"
72#define YKYH_DEFAULT_ITERS 10000
73
74typedef struct ykyh_state ykyh_state;
75
85
91
92const char *ykyh_strerror(ykyh_rc err);
93const char *ykyh_strerror_name(ykyh_rc err);
94
95ykyh_rc ykyh_init(ykyh_state **state, int verbose);
97ykyh_rc ykyh_connect(ykyh_state *state, const char *wanted);
98ykyh_rc ykyh_list_readers(ykyh_state *state, char *readers, size_t *len);
100
101ykyh_rc ykyh_get_version(ykyh_state *state, char *version, size_t len);
102
103ykyh_rc ykyh_put(ykyh_state *state, const char *name, const uint8_t *key_enc,
104 size_t key_enc_len, const uint8_t *key_mac, size_t key_mac_len,
105 const char *pw, const uint8_t touch_policy);
106
109 size_t context_len, const char *pw, uint8_t *key_s_enc,
110 size_t key_s_enc_len, uint8_t *key_s_mac,
111 size_t key_s_mac_len, uint8_t *key_s_rmac,
112 size_t key_s_rmac_len, uint8_t *retries);
115 size_t *list_items);
117
118#ifdef __cplusplus
119}
120#endif
121
122#endif
std::string name
unsigned char uint8_t
Definition stdint.h:124
Definition ykyh.h:86
uint8_t ctr
Definition ykyh.h:89
uint8_t algo
Definition ykyh.h:87
ykyh_rc ykyh_put(ykyh_state *state, const char *name, const uint8_t *key_enc, size_t key_enc_len, const uint8_t *key_mac, size_t key_mac_len, const char *pw, const uint8_t touch_policy)
Definition ykyh.c:289
ykyh_rc ykyh_get_version(ykyh_state *state, char *version, size_t len)
Definition ykyh.c:260
const char * ykyh_strerror(ykyh_rc err)
Definition error.c:40
ykyh_rc ykyh_get_challenge(ykyh_state *state)
Definition ykyh.c:566
ykyh_rc ykyh_done(ykyh_state *state)
Definition ykyh.c:64
ykyh_rc ykyh_connect(ykyh_state *state, const char *wanted)
Definition ykyh.c:92
ykyh_rc ykyh_list_keys(ykyh_state *state, ykyh_list_entry *list, size_t *list_items)
Definition ykyh.c:510
ykyh_rc
Definition ykyh.h:76
@ YKYHR_INVALID_PARAMS
Definition ykyh.h:82
@ YKYHR_GENERIC_ERROR
Definition ykyh.h:80
@ YKYHR_SUCCESS
Definition ykyh.h:77
@ YKYHR_MEMORY_ERROR
Definition ykyh.h:78
@ YKYHR_PCSC_ERROR
Definition ykyh.h:79
@ YKYHR_ENTRY_NOT_FOUND
Definition ykyh.h:83
@ YKYHR_WRONG_PW
Definition ykyh.h:81
ykyh_rc ykyh_reset(ykyh_state *state)
Definition ykyh.c:483
ykyh_rc ykyh_list_readers(ykyh_state *state, char *readers, size_t *len)
Definition ykyh.c:180
ykyh_rc ykyh_init(ykyh_state **state, int verbose)
Definition ykyh.c:35
#define YKYH_MAX_NAME_LEN
Definition ykyh.h:65
ykyh_rc ykyh_delete(ykyh_state *state, char *name)
Definition ykyh.c:364
const char * ykyh_strerror_name(ykyh_rc err)
Definition error.c:56
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)
Definition ykyh.c:403
ykyh_rc ykyh_disconnect(ykyh_state *state)
Definition ykyh.c:74
size_t len