[FL-1958] U2F prototype (#879)

* U2F implementation prototype
* U2F data encryption and store, user confirmation request
* remove debug prints
* fix notification bug in chrome
* split u2f_alloc into u2f_init and u2f_alloc
* typo fix, furi-hal-trng -> furi-hal-random
* rand/srand redefinition
* SubGhz: a little bit of Dante.
* u2f_data naming fix

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Nikolay Minaylov
2021-12-22 23:04:08 +03:00
committed by GitHub
parent 9b62b557b4
commit 9e62f08e4d
51 changed files with 10985 additions and 123 deletions

View File

@@ -32,6 +32,10 @@ typedef struct {
*/
void furi_hal_crypto_init();
bool furi_hal_crypto_verify_enclave(uint8_t* keys_nb, uint8_t* valid_keys_nb);
bool furi_hal_crypto_verify_key(uint8_t key_slot);
/** Store key in crypto storage
*
* @param key FuriHalCryptoKey to store. Only Master, Simple or

View File

@@ -0,0 +1,24 @@
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Get random value
*
* @return random value
*/
uint32_t furi_hal_random_get();
/** Fill buffer with random data
*
* @param buf buffer pointer
* @param data buffer len
*/
void furi_hal_random_fill_buf(uint8_t* buf, uint32_t len);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,36 @@
#pragma once
#define HID_U2F_PACKET_LEN 64
typedef enum {
HidU2fDisconnected,
HidU2fConnected,
HidU2fRequest,
} HidU2fEvent;
typedef void (*HidU2fCallback)(HidU2fEvent ev, void* context);
/** Get HID U2F connection state
*
* @return true / false
*/
bool furi_hal_hid_u2f_is_connected();
/** Set HID U2F event callback
*
* @param cb callback
* @param ctx callback context
*/
void furi_hal_hid_u2f_set_callback(HidU2fCallback cb, void* ctx);
/** Get received U2F HID packet
*
*/
uint32_t furi_hal_hid_u2f_get_request(uint8_t* data);
/** Send U2F HID response packet
*
* @param data response data
* @param len packet length
*/
void furi_hal_hid_u2f_send_response(uint8_t* data, uint8_t len);

View File

@@ -23,6 +23,7 @@ struct UsbInterface {
extern UsbInterface usb_cdc_single;
extern UsbInterface usb_cdc_dual;
extern UsbInterface usb_hid;
extern UsbInterface usb_hid_u2f;
/** USB device low-level initialization
*/

View File

@@ -40,6 +40,7 @@ template <unsigned int N> struct STOP_EXTERNING_ME {};
#include "furi-hal-compress.h"
#include "furi-hal-uart.h"
#include "furi-hal-info.h"
#include "furi-hal-random.h"
/** Init furi-hal */
void furi_hal_init();