1"""
2Copyright (c) 2015-2018 Nitrokey UG
3
4This file is part of libnitrokey.
5
6libnitrokey is free software: you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9any later version.
10
11libnitrokey is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License
17along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.
18
19SPDX-License-Identifier: LGPL-3.0
20"""
21from misc import to_hex, bb
22
23RFC_SECRET_HR = '12345678901234567890'
24RFC_SECRET = to_hex(RFC_SECRET_HR)  # '31323334353637383930...'
25bbRFC_SECRET = bb(RFC_SECRET)
26
27
28# print( repr((RFC_SECRET, RFC_SECRET_, len(RFC_SECRET))) )
29
30class DefaultPasswords:
31    ADMIN = b'12345678'
32    USER = b'123456'
33    ADMIN_TEMP = b'123123123'
34    USER_TEMP = b'234234234'
35    UPDATE = b'12345678'
36    UPDATE_TEMP = b'123update123'
37    UPDATE_LONG = b'1234567890'*2
38    UPDATE_TOO_LONG = UPDATE_LONG + b'x'
39    UPDATE_TOO_SHORT = UPDATE_LONG[:7]
40
41
42class DeviceErrorCode:
43    STATUS_OK = 0
44    BUSY = 1 # busy or busy progressbar in place of wrong_CRC status
45    NOT_PROGRAMMED = 3
46    WRONG_PASSWORD = 4
47    STATUS_NOT_AUTHORIZED = 5
48    STATUS_AES_DEC_FAILED = 0xa
49    STATUS_UNKNOWN_ERROR = 100
50    STATUS_DISCONNECTED = 255
51
52
53class LibraryErrors:
54    TOO_LONG_STRING = 200
55    INVALID_SLOT = 201
56    INVALID_HEX_STRING = 202
57    TARGET_BUFFER_SIZE_SMALLER_THAN_SOURCE = 203
58
59
60HOTP_slot_count = 3
61TOTP_slot_count = 15
62PWS_SLOT_COUNT = 16
63