forked from Yubico/yubikey-personalization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ykpers.h
144 lines (124 loc) · 5.97 KB
/
ykpers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* -*- mode:C; c-file-style: "bsd" -*- */
/*
* Copyright (c) 2008-2012 Yubico AB
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __YKPERS_H_INCLUDED__
#define __YKPERS_H_INCLUDED__
#include <stddef.h>
#include <stdbool.h>
#include <ykstatus.h>
#include <ykdef.h>
# ifdef __cplusplus
extern "C" {
# endif
typedef struct ykp_config_t YKP_CONFIG;
/* This only works with Yubikey 1 unless it's fed with a YK_STATUS using
ykp_configure_for(). */
YKP_CONFIG *ykp_create_config(void);
int ykp_free_config(YKP_CONFIG *cfg);
/* allocate an empty YKP_CONFIG, use ykp_configure_version() to set
version information. */
YKP_CONFIG *ykp_alloc(void);
/* Set the version information in st in cfg. */
void ykp_configure_version(YKP_CONFIG *cfg, YK_STATUS *st);
/* This is used to tell what YubiKey version we're working with and what
command we want to send to it. If this isn't used YubiKey 1 only will
be assumed. */
int ykp_configure_command(YKP_CONFIG *cfg, uint8_t command);
/* wrapper function for ykp_configure_command */
int ykp_configure_for(YKP_CONFIG *cfg, int confnum, YK_STATUS *st);
int ykp_AES_key_from_hex(YKP_CONFIG *cfg, const char *hexkey);
int ykp_AES_key_from_passphrase(YKP_CONFIG *cfg, const char *passphrase,
const char *salt);
int ykp_HMAC_key_from_hex(YKP_CONFIG *cfg, const char *hexkey);
/* Functions for constructing the YKNDEF struct before writing it to a neo */
int ykp_construct_ndef_uri(YKNDEF *ndef, const char *uri);
int ykp_construct_ndef_text(YKNDEF *ndef, const char *text, const char *lang, bool isutf16);
int ykp_set_access_code(YKP_CONFIG *cfg, unsigned char *access_code, size_t len);
int ykp_set_fixed(YKP_CONFIG *cfg, unsigned char *fixed, size_t len);
int ykp_set_uid(YKP_CONFIG *cfg, unsigned char *uid, size_t len);
int ykp_set_oath_imf(YKP_CONFIG *cfg, unsigned long imf);
unsigned long ykp_get_oath_imf(const YKP_CONFIG *cfg);
int ykp_set_tktflag_TAB_FIRST(YKP_CONFIG *cfg, bool state);
int ykp_set_tktflag_APPEND_TAB1(YKP_CONFIG *cfg, bool state);
int ykp_set_tktflag_APPEND_TAB2(YKP_CONFIG *cfg, bool state);
int ykp_set_tktflag_APPEND_DELAY1(YKP_CONFIG *cfg, bool state);
int ykp_set_tktflag_APPEND_DELAY2(YKP_CONFIG *cfg, bool state);
int ykp_set_tktflag_APPEND_CR(YKP_CONFIG *cfg, bool state);
int ykp_set_tktflag_PROTECT_CFG2(YKP_CONFIG *cfg, bool state);
int ykp_set_tktflag_OATH_HOTP(YKP_CONFIG *cfg, bool state);
int ykp_set_tktflag_CHAL_RESP(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_SEND_REF(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_TICKET_FIRST(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_PACING_10MS(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_PACING_20MS(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_ALLOW_HIDTRIG(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_STATIC_TICKET(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_SHORT_TICKET(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_STRONG_PW1(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_STRONG_PW2(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_MAN_UPDATE(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_OATH_HOTP8(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_OATH_FIXED_MODHEX1(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_OATH_FIXED_MODHEX2(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_OATH_FIXED_MODHEX(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_CHAL_YUBICO(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_CHAL_HMAC(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_HMAC_LT64(YKP_CONFIG *cfg, bool state);
int ykp_set_cfgflag_CHAL_BTN_TRIG(YKP_CONFIG *cfg, bool state);
int ykp_set_extflag_SERIAL_BTN_VISIBLE(YKP_CONFIG *cfg, bool state);
int ykp_set_extflag_SERIAL_USB_VISIBLE(YKP_CONFIG *cfg, bool state);
int ykp_set_extflag_SERIAL_API_VISIBLE (YKP_CONFIG *cfg, bool state);
int ykp_set_extflag_USE_NUMERIC_KEYPAD (YKP_CONFIG *cfg, bool state);
int ykp_set_extflag_FAST_TRIG (YKP_CONFIG *cfg, bool state);
int ykp_set_extflag_ALLOW_UPDATE (YKP_CONFIG *cfg, bool state);
int ykp_set_extflag_DORMANT (YKP_CONFIG *cfg, bool state);
int ykp_write_config(const YKP_CONFIG *cfg,
int (*writer)(const char *buf, size_t count,
void *userdata),
void *userdata);
int ykp_read_config(YKP_CONFIG *cfg,
int (*reader)(char *buf, size_t count,
void *userdata),
void *userdata);
YK_CONFIG *ykp_core_config(YKP_CONFIG *cfg);
int ykp_command(YKP_CONFIG *cfg);
int ykp_config_num(YKP_CONFIG *cfg);
extern int * const _ykp_errno_location(void);
#define ykp_errno (*_ykp_errno_location())
const char *ykp_strerror(int errnum);
#define YKP_ENOTYETIMPL 0x01
#define YKP_ENOCFG 0x02
#define YKP_EYUBIKEYVER 0x03
#define YKP_EOLDYUBIKEY 0x04
#define YKP_EINVCONFNUM 0x05
#define YKP_EINVAL 0x06
# ifdef __cplusplus
}
# endif
#endif /* __YKPERS_H_INCLUDED__ */