1 /*
2 Copyright (C) 2011-2013 Yubico AB.  All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are
6 met:
7 
8    1. Redistributions of source code must retain the above copyright
9       notice, this list of conditions and the following disclaimer.
10 
11    2. Redistributions in binary form must reproduce the above
12       copyright notice, this list of conditions and the following
13       disclaimer in the documentation and/or other materials provided
14       with the distribution.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef COMMON_H
30 #define COMMON_H
31 
32 #include "otpdef.h"
33 
34 #define YK_VERSION(MAJOR, MINOR, BUILD) (MAJOR * 10000 + MINOR * 100 + BUILD)
35 
36 //typedef std::vector<int>::size_type size_t;
37 
38 enum AccMode {
39   Acc_None,
40   Acc_Serial,
41   Acc_Random,
42 };
43 
44 #define MAX_SIZE                    256
45 
46 #define SCHEME_INCR_ID_RAND_SECRET  0
47 #define SCHEME_RAND_SECRET          0
48 #define SCHEME_RAND_ALL             1
49 #define SCHEME_ID_FROM_SERIAL_RAND_SECRET 2
50 #define SCHEME_FIXED                2
51 
52 #define GEN_SCHEME_FIXED            0
53 #define GEN_SCHEME_INCR             1
54 #define GEN_SCHEME_RAND             2
55 #define GEN_SCHEME_SERIAL           3
56 
57 #define WRITE_CONFIG                0
58 #define EXPORT_CONFIG               1
59 
60 #define SUPPORT_LINK                "https://yubi.co/forum"
61 #define UPLOAD_URL                  "<!doctype html><html><head><title>upload</title></head><body><form action='https://upload.yubico.com/' method='post' id='upload'>serial:<input name='serial' value='%1'/><br/>prefix:<input name='prefix' value='%2'/><br/>uid:<input name='uid' value='%3'/><br/>aeskey:<input name='aeskey' value='%4'/><br/><input type='submit'/><br/></form><script type='text/javascript'>window.onload=function(){document.getElementById('upload').submit();}</script></body></html>"
62 
63 #define ERR_NOERROR                 0
64 #define ERR_OTHER                   1
65 #define ERR_NOKEY                   2
66 #define ERR_MORETHANONE             3
67 #define ERR_UNKNOWN_FIRMWARE        4
68 
69 #define KEYMAP_NONE                 0
70 #define KEYMAP_US                   1
71 #define KEYMAP_DE                   2
72 #define KEYMAP_BEPO                 3
73 #define KEYMAP_FR                   4
74 
75 //Timeouts
76 
77 #define TIMEOUT_STATUS              10000
78 #define TIMEOUT_FINDER              1000
79 
80 
81 //Stylesheets
82 
83 #define SS_MENU_CHECKED             "color:rgb(0,0,0);border:2px groove rgb(255,255,255);"
84 #define SS_MENU_UNCHECKED           "color:rgb(122,171,32);border:2px groove rgb(255,255,255);"
85 #define SS_MENU_DISABLED            "color:rgb(118,116,108);border:2px groove rgb(255,255,255);"
86 
87 #define SS_STATUS_SUCCESS           "font:12px \"Verdana\";color:green;"
88 #define SS_STATUS_ERROR             "font:12px \"Verdana\";color:rgb(221,97,99);"
89 
90 #define SS_YKSTATUS_SUCCESS         "font:11px \"Verdana\";font-weight:bold;color:rgb(122,171,32);"
91 #define SS_YKSTATUS_ERROR           "font:11px \"Verdana\";font-weight:bold;color:rgb(221, 97, 99);"
92 
93 #define SS_COPY_BTN                 "background-image: url(:/res/images/clipboard.png); border-radius: 2px;"
94 #define SS_BLANK_BTN                "background-image: url(:/res/images/blank.png); border-radius: 2px;"
95 
96 #define SS_LINK_ENABLED             "font: 12px \"Verdana\"; text-decoration: underline; text-align: left; color: rgb(5, 67, 168);"
97 #define SS_LINK_DISABLED            "font: 12px \"Verdana\"; text-decoration: underline; text-align: left; color: rgb(118,116,108);"
98 
99 
100 //Messages
101 
102 #define ERR                         "Error"
103 #define NA                          "N/A"
104 #define TOVERFLOW                   "Overflow"
105 
106 #define KEY_FOUND                   "YubiKey is inserted"
107 #define NO_KEY_FOUND                "No YubiKey inserted"
108 #define MORE_THAN_ONE               "More than one\nYubiKey inserted"
109 #define OTHER_ERROR                 "Unknown error occurred"
110 #define UNKNOWN_FIRMWARE            "Unknown firmware"
111 
112 #define KEY_CONFIGURED              "YubiKey%1 has been successfully configured"
113 #define KEY_EXPORTED                "YubiKey configuration has been successfully exported"
114 #define REMOVE_KEY                  "Please remove this YubiKey"
115 #define SETTINGS_SAVED              "Settings have been successfully saved"
116 #define SETTINGS_RESTORED           "Default settings have been restored"
117 #define VALUE_COPIED                "Value copied to clipboard"
118 
119 #define ERR_KEY_NOT_FOUND           "YubiKey not found. Please insert YubiKey in USB port"
120 #define ERR_FEATURE_NOT_SUPPORTED   "Selected configuration is not supported by the YubiKey being programmed"
121 #define ERR_FIRMWARE_NOT_SUPPORTED  "This YubiKey firmware version is not supported"
122 #define ERR_PROCESSING              "YubiKey could not be configured. Perhaps protected with configuration protection access code?"
123 #define ERR_PROCESSING_CHALRESP     "Challenge response could not be performed. Perhaps the YubiKey is not configured for challenge-response?"
124 #define ERR_CONF_SLOT_NOT_SELECTED  "No configuration slot selected. Please select the configuration slot to be programmed"
125 #define ERR_CHAL_TYPE_NOT_SELECTED  "No Challenge-Response Type selected. Please select the one to use"
126 
127 //Warnings
128 
129 #define OVERWRITE_CONF_SLOT1        "Overwrite configuration slot 1?"
130 #define WARN_OVERWRITE_CONF_SLOT1   "If you have a YubiKey VIP, this slot should contain a Symantec VIP credential by default. You should refrain from rewriting this Slot as a Symantec VIP credential can only be programmed during manufacture - you will thus not be able to get a new one.\n\nIf you have any other YubiKey, this slot should contain a Yubico OTP credential by default. This credential is required for using the YubiKey with many of our services and that of our partners. If you overwrite this and want to use it again later, you will need to reprogram it and upload the new one to our YubiCloud validation service.\n\nAre you sure you want to overwrite the configuration slot 1?"
131 
132 #define RESTORE_SETTING             "Restore default settings?"
133 #define WARN_RESTORE_SETTING        "Are you sure you want to restore the default settings?"
134 
135 #define WARN_EMPTY_PASS             "No password set. Please set the password"
136 
137 #define DIFF_PUBLIC_ID_LEN          "Change Public Identity length?"
138 #define WARN_DIFF_PUBLIC_ID_LEN     "Yubico OTP validation server requires Public Identity to be of 12 characters (6 bytes) in order to correctly extract the Secret Key. If you change the Public Identity to any other length, the Yubico OTP validation server won't be able to extract the Secret Key and the OTP validation will fail.\n\nAre you sure you want to change the default Public Idenity length?"
139 
140 #define ENABLE_CONF_PROTECTION      "Enable configuration protection?"
141 #define WARN_ENABLE_CONF_PROTECTION "YubiKey Personalization Tool logging is currently disabled. It is not possible to retrieve the configuration protection access code from the YubiKey. If protection access code is forgotten, you may not be able to program the YubiKey again. Yubico highly recommends to enable logging and archive the relevant log records. \n\nAre you sure you still want to enable the configuration protection?"
142 
143 #define NDEF_WITHOUT_HTTP           "Write NDEF without HTTP?"
144 #define WARN_NDEF_WITHOUT_HTTP      "The NDEF URI entered does not start with http, are you sure that is what you want?"
145 
146 //Settings
147 
148 #define SG_CUSTOMER_PREFIX_USED     "Customer/Used"
149 #define SG_CUSTOMER_PREFIX          "Customer/Prefix"
150 
151 #define SG_LOG_DISABLED             "Log/Disabled"
152 #define SG_LOG_FILENAME             "Log/Filename"
153 #define SG_LOG_FORMAT               "Log/Format"
154 #define SG_LOG_FLEXIBLE             "Log/Flexible"
155 
156 #define SG_EXPORT_FILENAME          "Export/Filename"
157 #define SG_IMPORT_FILENAME          "Import/Filename"
158 
159 #define SG_TAB_FIRST                "Flag/TabTirst"
160 #define SG_APPEND_TAB1              "Flag/AppendTab1"
161 #define SG_APPEND_TAB2              "Flag/AppendTab2"
162 #define SG_APPEND_CR                "Flag/AppendCr"
163 #define SG_APPEND_DELAY1            "Flag/AppendDelay1"
164 #define SG_APPEND_DELAY2            "Flag/AppendDelay2"
165 
166 #define SG_SR_BTN_VISIBLE           "Flag/SerialBtnVisible"
167 #define SG_SR_USB_VISIBLE           "Flag/serialUsbVisible"
168 #define SG_SR_API_VISIBLE           "Flag/serialApiVisible"
169 
170 #define SG_PACING_10MS              "Flag/Pacing10ms"
171 #define SG_PACING_20MS              "Flag/Pacing20ms"
172 
173 #define SG_MAN_UPDATE               "Flag/ManUpdate"
174 
175 #define SG_ALLOW_UPDATE             "Flag/AllowUpdate"
176 #define SG_FAST_TRIG                "Flag/FastTrig"
177 #define SG_USE_NUMERIC_KEYPAD       "Flag/UseNumericKeypad"
178 #define SG_LED_INVERT               "Flag/LedInvert"
179 
180 #define SG_OATH_HOTP8               "Flag/OathHotp8"
181 #define SG_REQUIRE_INPUT            "Flag/RequireInput"
182 #define SG_HMAC_LT64                "Flag/HmacLt64"
183 
184 #define SG_STRONG_PW1               "Flag/StrongPw1"
185 #define SG_STRONG_PW2               "Flag/StrongPw2"
186 #define SG_STRONG_PW3               "Flag/StrongPw3"
187 
188 #define SG_OVERWRITE_CONF_SLOT1     "DontAsk/Slot1Overwriting"
189 #define SG_DIFF_PUBLIC_ID_LEN       "DontAsk/PublicIdLen"
190 #define SG_ENABLE_CONF_PROTECTION   "DontAsk/ConfProtection"
191 #define SG_NDEF_WITHOUT_HTTP        "DontAsk/NdefWithoutHttp"
192 
193 #define SG_ANIMATIONS_PREFERENCE    "Preference/Animations"
194 #define SG_EXPORT_PREFERENCE        "Preference/Export"
195 
196 #endif // COMMON_H
197