Loading...
Searching...
No Matches
ctap_utils.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Freie Universität Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
22#ifndef FIDO2_CTAP_CTAP_UTILS_H
23#define FIDO2_CTAP_CTAP_UTILS_H
24
25#include <stdint.h>
26#include "fido2/ctap/ctap.h"
27#include "periph/gpio.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
37
44
53
66static inline int fido2_ctap_utils_cred_cmp(const void *k1, const void *k2)
67{
70
71 /* multiply by -1 because we want descending order. */
72 return (_k1->id - _k2->id) * -1;
73}
74
84 const ctap_resident_key_t *k2)
85{
86 return memcmp(k1->rp_id_hash, k2->rp_id_hash, sizeof(k1->rp_id_hash)) == 0 &&
87 memcmp(k1->user_id, k2->user_id, sizeof(k1->user_id)) == 0;
88}
89
90#ifdef __cplusplus
91}
92#endif
93#endif /* FIDO2_CTAP_CTAP_UTILS_H */
gpio_flank_t
Definition periph_cpu.h:180
Internal FIDO2 CTAP defines, structures and function declarations.
Low-level GPIO peripheral driver interface definitions.
static int fido2_ctap_utils_cred_cmp(const void *k1, const void *k2)
Compare fido2 credentials based on id to find more recent one.
Definition ctap_utils.h:66
int fido2_ctap_utils_user_presence_test(void)
Test user presence.
void fido2_ctap_utils_led_animation(void)
LED animation to indicate that user action is required.
static bool fido2_ctap_utils_ks_equal(const ctap_resident_key_t *k1, const ctap_resident_key_t *k2)
Check equality of resident keys based on rp_id_hash and user_id.
Definition ctap_utils.h:83
int fido2_ctap_utils_init_gpio_pin(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank)
Initialize button to be used for user presence test.
gpio_mode_t
Available pin modes.
Definition periph_cpu.h:82
CTAP resident key struct.
Definition ctap.h:497
uint8_t user_id[CTAP_USER_ID_MAX_SIZE]
id of user
Definition ctap.h:499
uint16_t id
internal id of key
Definition ctap.h:502
uint8_t rp_id_hash[SHA256_DIGEST_LENGTH]
hash of rp domain string
Definition ctap.h:498