Path: blob/main/contrib/libfido2/src/fido/credman.h
39507 views
/*1* Copyright (c) 2019-2021 Yubico AB. All rights reserved.2* SPDX-License-Identifier: BSD-2-Clause3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions are6* met:7*8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in12* the documentation and/or other materials provided with the13* distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS16* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT17* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR18* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT19* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,20* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT21* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,22* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY23* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE25* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.26*/2728#ifndef _FIDO_CREDMAN_H29#define _FIDO_CREDMAN_H3031#include <stdint.h>32#include <stdlib.h>3334#ifdef _FIDO_INTERNAL35#include "blob.h"36#include "fido/err.h"37#include "fido/param.h"38#include "fido/types.h"39#else40#include <fido.h>41#include <fido/err.h>42#include <fido/param.h>43#endif4445#ifdef __cplusplus46extern "C" {47#endif /* __cplusplus */4849#ifdef _FIDO_INTERNAL50struct fido_credman_metadata {51uint64_t rk_existing;52uint64_t rk_remaining;53};5455struct fido_credman_single_rp {56fido_rp_t rp_entity;57fido_blob_t rp_id_hash;58};5960struct fido_credman_rp {61struct fido_credman_single_rp *ptr;62size_t n_alloc; /* number of allocated entries */63size_t n_rx; /* number of populated entries */64};6566struct fido_credman_rk {67fido_cred_t *ptr;68size_t n_alloc; /* number of allocated entries */69size_t n_rx; /* number of populated entries */70};71#endif7273typedef struct fido_credman_metadata fido_credman_metadata_t;74typedef struct fido_credman_rk fido_credman_rk_t;75typedef struct fido_credman_rp fido_credman_rp_t;7677const char *fido_credman_rp_id(const fido_credman_rp_t *, size_t);78const char *fido_credman_rp_name(const fido_credman_rp_t *, size_t);7980const fido_cred_t *fido_credman_rk(const fido_credman_rk_t *, size_t);81const unsigned char *fido_credman_rp_id_hash_ptr(const fido_credman_rp_t *,82size_t);8384fido_credman_metadata_t *fido_credman_metadata_new(void);85fido_credman_rk_t *fido_credman_rk_new(void);86fido_credman_rp_t *fido_credman_rp_new(void);8788int fido_credman_del_dev_rk(fido_dev_t *, const unsigned char *, size_t,89const char *);90int fido_credman_get_dev_metadata(fido_dev_t *, fido_credman_metadata_t *,91const char *);92int fido_credman_get_dev_rk(fido_dev_t *, const char *, fido_credman_rk_t *,93const char *);94int fido_credman_get_dev_rp(fido_dev_t *, fido_credman_rp_t *, const char *);95int fido_credman_set_dev_rk(fido_dev_t *, fido_cred_t *, const char *);9697size_t fido_credman_rk_count(const fido_credman_rk_t *);98size_t fido_credman_rp_count(const fido_credman_rp_t *);99size_t fido_credman_rp_id_hash_len(const fido_credman_rp_t *, size_t);100101uint64_t fido_credman_rk_existing(const fido_credman_metadata_t *);102uint64_t fido_credman_rk_remaining(const fido_credman_metadata_t *);103104void fido_credman_metadata_free(fido_credman_metadata_t **);105void fido_credman_rk_free(fido_credman_rk_t **);106void fido_credman_rp_free(fido_credman_rp_t **);107108#ifdef __cplusplus109} /* extern "C" */110#endif /* __cplusplus */111112#endif /* !_FIDO_CREDMAN_H */113114115