Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/libfido2/src/fido/credman.h
39507 views
1
/*
2
* Copyright (c) 2019-2021 Yubico AB. All rights reserved.
3
* SPDX-License-Identifier: BSD-2-Clause
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are
7
* met:
8
*
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in
13
* the documentation and/or other materials provided with the
14
* distribution.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
28
29
#ifndef _FIDO_CREDMAN_H
30
#define _FIDO_CREDMAN_H
31
32
#include <stdint.h>
33
#include <stdlib.h>
34
35
#ifdef _FIDO_INTERNAL
36
#include "blob.h"
37
#include "fido/err.h"
38
#include "fido/param.h"
39
#include "fido/types.h"
40
#else
41
#include <fido.h>
42
#include <fido/err.h>
43
#include <fido/param.h>
44
#endif
45
46
#ifdef __cplusplus
47
extern "C" {
48
#endif /* __cplusplus */
49
50
#ifdef _FIDO_INTERNAL
51
struct fido_credman_metadata {
52
uint64_t rk_existing;
53
uint64_t rk_remaining;
54
};
55
56
struct fido_credman_single_rp {
57
fido_rp_t rp_entity;
58
fido_blob_t rp_id_hash;
59
};
60
61
struct fido_credman_rp {
62
struct fido_credman_single_rp *ptr;
63
size_t n_alloc; /* number of allocated entries */
64
size_t n_rx; /* number of populated entries */
65
};
66
67
struct fido_credman_rk {
68
fido_cred_t *ptr;
69
size_t n_alloc; /* number of allocated entries */
70
size_t n_rx; /* number of populated entries */
71
};
72
#endif
73
74
typedef struct fido_credman_metadata fido_credman_metadata_t;
75
typedef struct fido_credman_rk fido_credman_rk_t;
76
typedef struct fido_credman_rp fido_credman_rp_t;
77
78
const char *fido_credman_rp_id(const fido_credman_rp_t *, size_t);
79
const char *fido_credman_rp_name(const fido_credman_rp_t *, size_t);
80
81
const fido_cred_t *fido_credman_rk(const fido_credman_rk_t *, size_t);
82
const unsigned char *fido_credman_rp_id_hash_ptr(const fido_credman_rp_t *,
83
size_t);
84
85
fido_credman_metadata_t *fido_credman_metadata_new(void);
86
fido_credman_rk_t *fido_credman_rk_new(void);
87
fido_credman_rp_t *fido_credman_rp_new(void);
88
89
int fido_credman_del_dev_rk(fido_dev_t *, const unsigned char *, size_t,
90
const char *);
91
int fido_credman_get_dev_metadata(fido_dev_t *, fido_credman_metadata_t *,
92
const char *);
93
int fido_credman_get_dev_rk(fido_dev_t *, const char *, fido_credman_rk_t *,
94
const char *);
95
int fido_credman_get_dev_rp(fido_dev_t *, fido_credman_rp_t *, const char *);
96
int fido_credman_set_dev_rk(fido_dev_t *, fido_cred_t *, const char *);
97
98
size_t fido_credman_rk_count(const fido_credman_rk_t *);
99
size_t fido_credman_rp_count(const fido_credman_rp_t *);
100
size_t fido_credman_rp_id_hash_len(const fido_credman_rp_t *, size_t);
101
102
uint64_t fido_credman_rk_existing(const fido_credman_metadata_t *);
103
uint64_t fido_credman_rk_remaining(const fido_credman_metadata_t *);
104
105
void fido_credman_metadata_free(fido_credman_metadata_t **);
106
void fido_credman_rk_free(fido_credman_rk_t **);
107
void fido_credman_rp_free(fido_credman_rp_t **);
108
109
#ifdef __cplusplus
110
} /* extern "C" */
111
#endif /* __cplusplus */
112
113
#endif /* !_FIDO_CREDMAN_H */
114
115