Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
fido2_storage.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 Siratul Islam <email@sirat.me>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_AUTHENTICATION_FIDO2_FIDO2_STORAGE_H_
14#define ZEPHYR_INCLUDE_AUTHENTICATION_FIDO2_FIDO2_STORAGE_H_
15
17#include <stddef.h>
18
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
36typedef int (*fido2_storage_iterate_cb_t)(const struct fido2_credential *cred, void *user_data);
37
41 int (*init)(void);
43 int (*store)(const struct fido2_credential *cred);
45 int (*load)(const uint8_t *cred_id, size_t cred_id_len, struct fido2_credential *cred);
47 int (*remove)(const uint8_t *cred_id, size_t cred_id_len, struct fido2_credential *cred);
49 int (*find_by_rp)(const uint8_t rp_id_hash[FIDO2_SHA256_SIZE],
50 struct fido2_credential *creds, size_t max_creds, size_t *count);
52 int (*enumerate_rps)(size_t offset, struct fido2_credential *creds, size_t max_creds,
53 size_t *count);
55 int (*iterate)(fido2_storage_iterate_cb_t cb, void *user_data);
57 int (*sign_count_increment)(const uint8_t *cred_id, size_t cred_id_len,
58 uint32_t *new_count);
60 int (*update_user_info)(const uint8_t *cred_id, size_t cred_id_len, const char *user_name,
61 const char *user_display_name);
63 int (*credential_count)(size_t *count);
65 int (*wipe_all)(void);
67 int (*pin_set)(const uint8_t pin_hash[FIDO2_PIN_HASH_SIZE]);
71 int (*pin_retries_get)(uint8_t *retries);
75 int (*pin_retries_reset)(void);
76};
77
85
89
95int fido2_storage_init(void);
96
103int fido2_storage_store(const struct fido2_credential *cred);
104
113int fido2_storage_load(const uint8_t *cred_id, size_t cred_id_len, struct fido2_credential *cred);
114
122int fido2_storage_remove(const uint8_t *cred_id, size_t cred_id_len);
123
132int fido2_storage_find_by_rp(const uint8_t rp_id_hash[FIDO2_SHA256_SIZE],
133 struct fido2_credential *creds, size_t max_creds, size_t *count);
134
144int fido2_storage_enumerate_rps(size_t offset, struct fido2_credential *creds, size_t max_creds,
145 size_t *count);
146
155int fido2_storage_sign_count_increment(const uint8_t *cred_id, size_t cred_id_len,
156 uint32_t *new_count);
157
163int fido2_storage_pin_retries_get(uint8_t *retries);
164
169int fido2_storage_pin_retries_decrement(void);
170
175int fido2_storage_pin_retries_reset(void);
176
182int fido2_storage_pin_set(uint8_t pin_hash[FIDO2_PIN_HASH_SIZE]);
183
189int fido2_storage_pin_get(uint8_t pin_hash[FIDO2_PIN_HASH_SIZE]);
190
194
195#ifdef __cplusplus
196}
197#endif
198
200
201#endif /* ZEPHYR_INCLUDE_AUTHENTICATION_FIDO2_FIDO2_STORAGE_H_ */
FIDO2 shared type definitions.
const struct fido2_storage_api fido2_storage_backend
FIDO2 storage backend instance.
#define FIDO2_PIN_HASH_SIZE
PIN hash size.
Definition fido2_types.h:56
int(* fido2_storage_iterate_cb_t)(const struct fido2_credential *cred, void *user_data)
FIDO2 credential storage.
Definition fido2_storage.h:36
#define FIDO2_SHA256_SIZE
SHA-256 hash size.
Definition fido2_types.h:53
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
A stored FIDO2 credential.
Definition fido2_types.h:200
Storage backend API.
Definition fido2_storage.h:39
int(* enumerate_rps)(size_t offset, struct fido2_credential *creds, size_t max_creds, size_t *count)
Enumerate unique Relying Party IDs from stored credentials.
Definition fido2_storage.h:52
int(* update_user_info)(const uint8_t *cred_id, size_t cred_id_len, const char *user_name, const char *user_display_name)
Update user information for an existing credential.
Definition fido2_storage.h:60
int(* wipe_all)(void)
Wipe all stored credentials and PIN state.
Definition fido2_storage.h:65
int(* iterate)(fido2_storage_iterate_cb_t cb, void *user_data)
Iterate all stored credentials.
Definition fido2_storage.h:55
int(* remove)(const uint8_t *cred_id, size_t cred_id_len, struct fido2_credential *cred)
Remove a credential by ID.
Definition fido2_storage.h:47
int(* load)(const uint8_t *cred_id, size_t cred_id_len, struct fido2_credential *cred)
Load a credential by ID.
Definition fido2_storage.h:45
int(* init)(void)
Initialize the storage backend.
Definition fido2_storage.h:41
int(* store)(const struct fido2_credential *cred)
Store a credential.
Definition fido2_storage.h:43
int(* pin_retries_get)(uint8_t *retries)
Get remaining PIN retry count.
Definition fido2_storage.h:71
int(* pin_retries_reset)(void)
Reset PIN retry counter to maximum.
Definition fido2_storage.h:75
int(* sign_count_increment)(const uint8_t *cred_id, size_t cred_id_len, uint32_t *new_count)
Increment and return the signature counter.
Definition fido2_storage.h:57
int(* find_by_rp)(const uint8_t rp_id_hash[FIDO2_SHA256_SIZE], struct fido2_credential *creds, size_t max_creds, size_t *count)
Find credentials by relying party ID hash.
Definition fido2_storage.h:49
int(* pin_get)(uint8_t pin_hash[FIDO2_PIN_HASH_SIZE])
Load stored PIN hash.
Definition fido2_storage.h:69
int(* pin_retries_decrement)(void)
Decrement PIN retry counter.
Definition fido2_storage.h:73
int(* credential_count)(size_t *count)
Get the total number of discoverable credentials stored.
Definition fido2_storage.h:63
int(* pin_set)(const uint8_t pin_hash[FIDO2_PIN_HASH_SIZE])
Store PIN hash.
Definition fido2_storage.h:67