forked from Nitrokey/nitrokey-hotp-verification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice.h
54 lines (45 loc) · 1.84 KB
/
device.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
/*
* Copyright (c) 2018 Nitrokey UG
*
* This file is part of Nitrokey HOTP verification project.
*
* Nitrokey HOTP verification is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Nitrokey HOTP verification is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Nitrokey App. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0
*/
#ifndef NITROKEY_HOTP_VERIFICATION_DEVICE_H
#define NITROKEY_HOTP_VERIFICATION_DEVICE_H
#include <stdint.h>
#include <hidapi/hidapi.h>
#include "structs.h"
#define nullptr (NULL)
#define TEMPORARY_PASSWORD_LENGTH (25)
struct Device {
hid_device * mp_devhandle;
struct DeviceQuery packet_query;
struct DeviceResponse packet_response;
uint8_t user_temporary_password[TEMPORARY_PASSWORD_LENGTH];
uint8_t admin_temporary_password[TEMPORARY_PASSWORD_LENGTH];
};
int device_connect(struct Device* dev, char *key_brand);
int device_disconnect(struct Device* dev);
struct ResponseStatus device_get_status(struct Device *dev);
int device_send(struct Device *dev, uint8_t *in_data, size_t data_size, uint8_t command_ID);
int device_receive(struct Device *dev, uint8_t *out_data, size_t out_buffer_size);
int device_send_buf(struct Device *dev, uint8_t command_ID);
int device_receive_buf(struct Device *dev);
const char * command_status_to_string(uint8_t status_code);
//private
void _device_clear_buffers(struct Device *dev);
#endif //NITROKEY_HOTP_VERIFICATION_DEVICE_H