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 
9 #pragma once
10 
24 #include <stdint.h>
25 #include "fido2/ctap/ctap.h"
26 #include "periph/gpio.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
36 
43 
52 
65 static inline int fido2_ctap_utils_cred_cmp(const void *k1, const void *k2)
66 {
69 
70  /* multiply by -1 because we want descending order. */
71  return (_k1->id - _k2->id) * -1;
72 }
73 
82 static inline bool fido2_ctap_utils_ks_equal(const ctap_resident_key_t *k1,
83  const ctap_resident_key_t *k2)
84 {
85  return memcmp(k1->rp_id_hash, k2->rp_id_hash, sizeof(k1->rp_id_hash)) == 0 &&
86  memcmp(k1->user_id, k2->user_id, sizeof(k1->user_id)) == 0;
87 }
88 
89 #ifdef __cplusplus
90 }
91 #endif
gpio_flank_t
Definition: periph_cpu.h:179
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:91
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:65
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:82
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:46
CTAP resident key struct.
Definition: ctap.h:485
uint8_t user_id[CTAP_USER_ID_MAX_SIZE]
id of user
Definition: ctap.h:487
uint16_t id
internal id of key
Definition: ctap.h:490
uint8_t rp_id_hash[SHA256_DIGEST_LENGTH]
hash of rp domain string
Definition: ctap.h:486