1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-01 04:49:31 +00:00
trezor-firmware/legacy/firmware/u2f.h

63 lines
2.0 KiB
C
Raw Normal View History

2015-11-02 23:08:18 +00:00
/*
* This file is part of the Trezor project, https://trezor.io/
2015-11-02 23:08:18 +00:00
*
* Copyright (C) 2015 Mark Bryars <mbryars@google.com>
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __U2F_H__
#define __U2F_H__
#include <stdbool.h>
#include <stdint.h>
2015-11-02 23:08:18 +00:00
#include "trezor.h"
#include "u2f/u2f_hid.h"
2015-11-02 23:08:18 +00:00
#define U2F_KEY_PATH 0x80553246
2015-11-02 23:08:18 +00:00
typedef struct {
uint8_t cla, ins, p1, p2;
uint8_t lc1, lc2, lc3;
uint8_t data[];
2015-11-02 23:08:18 +00:00
} APDU;
#define APDU_LEN(A) (uint32_t)(((A).lc1 << 16) + ((A).lc2 << 8) + ((A).lc3))
2016-05-07 20:12:27 +00:00
void u2fhid_read(char tiny, const U2FHID_FRAME *buf);
void u2fhid_init_cmd(const U2FHID_FRAME *f);
void u2fhid_read_start(const U2FHID_FRAME *f);
2015-11-02 23:08:18 +00:00
bool u2fhid_write(uint8_t *buf);
void u2fhid_init(const U2FHID_FRAME *in);
2015-11-02 23:08:18 +00:00
void u2fhid_ping(const uint8_t *buf, uint32_t len);
void u2fhid_wink(const uint8_t *buf, uint32_t len);
void u2fhid_sync(const uint8_t *buf, uint32_t len);
void u2fhid_lock(const uint8_t *buf, uint32_t len);
void u2fhid_msg(const APDU *a, uint32_t len);
void queue_u2f_pkt(const U2FHID_FRAME *u2f_pkt);
uint8_t *u2f_out_data(void);
void u2f_register(const APDU *a);
void u2f_version(const APDU *a);
void u2f_authenticate(const APDU *a);
2016-05-07 20:12:27 +00:00
void send_u2f_msg(const uint8_t *data, uint32_t len);
void send_u2f_error(uint16_t err);
2015-11-02 23:08:18 +00:00
void send_u2fhid_msg(const uint8_t cmd, const uint8_t *data,
const uint32_t len);
2016-05-07 20:12:27 +00:00
void send_u2fhid_error(uint32_t fcid, uint8_t err);
2015-11-02 23:08:18 +00:00
#endif