ctap_utils.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2021 Freie Universität Berlin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
21 #include <stdint.h>
22 #include "fido2/ctap/ctap.h"
23 #include "periph/gpio.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
33 
40 
49 
62 static inline int fido2_ctap_utils_cred_cmp(const void *k1, const void *k2)
63 {
66 
67  /* multiply by -1 because we want descending order. */
68  return (_k1->id - _k2->id) * -1;
69 }
70 
79 static inline bool fido2_ctap_utils_ks_equal(const ctap_resident_key_t *k1,
80  const ctap_resident_key_t *k2)
81 {
82  return memcmp(k1->rp_id_hash, k2->rp_id_hash, sizeof(k1->rp_id_hash)) == 0 &&
83  memcmp(k1->user_id, k2->user_id, sizeof(k1->user_id)) == 0;
84 }
85 
86 #ifdef __cplusplus
87 }
88 #endif
gpio_flank_t
Definition: periph_cpu.h:176
Internal FIDO2 CTAP defines, structures and function declarations.
Low-level GPIO peripheral driver interface definitions.
gpio_mode_t
Available pin modes.
Definition: periph_cpu.h:96
ctap_status_code_t 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.
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:62
ctap_status_code_t fido2_ctap_utils_user_presence_test(void)
Test user presence.
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:79
void fido2_ctap_utils_wait_for_user_presence(void)
LED animation to indicate that user action is required.
ctap_status_code_t
CTAP status codes.
Definition: ctap.h:43
CTAP resident key struct.
Definition: ctap.h:482
uint8_t user_id[CTAP_USER_ID_MAX_SIZE]
id of user
Definition: ctap.h:484
uint16_t id
internal id of key
Definition: ctap.h:487
uint8_t rp_id_hash[SHA256_DIGEST_LENGTH]
hash of rp domain string
Definition: ctap.h:483