1 /* 2 * Copyright (c) 2019 Yubico AB. All rights reserved. 3 * Use of this source code is governed by a BSD-style 4 * license that can be found in the LICENSE file. 5 */ 6 7 #ifndef _FIDO_CREDMAN_H 8 #define _FIDO_CREDMAN_H 9 10 #include <stdint.h> 11 #include <stdlib.h> 12 13 #ifdef _FIDO_INTERNAL 14 #include "blob.h" 15 #include "fido/err.h" 16 #include "fido/param.h" 17 #include "fido/types.h" 18 #else 19 #include <fido.h> 20 #include <fido/err.h> 21 #include <fido/param.h> 22 #endif 23 24 #ifdef _FIDO_INTERNAL 25 struct fido_credman_metadata { 26 uint64_t rk_existing; 27 uint64_t rk_remaining; 28 }; 29 30 struct fido_credman_single_rp { 31 fido_rp_t rp_entity; 32 fido_blob_t rp_id_hash; 33 }; 34 35 struct fido_credman_rp { 36 struct fido_credman_single_rp *ptr; 37 size_t n_alloc; /* number of allocated entries */ 38 size_t n_rx; /* number of populated entries */ 39 }; 40 41 struct fido_credman_rk { 42 fido_cred_t *ptr; 43 size_t n_alloc; /* number of allocated entries */ 44 size_t n_rx; /* number of populated entries */ 45 }; 46 #endif 47 48 typedef struct fido_credman_metadata fido_credman_metadata_t; 49 typedef struct fido_credman_rk fido_credman_rk_t; 50 typedef struct fido_credman_rp fido_credman_rp_t; 51 52 const char *fido_credman_rp_id(const fido_credman_rp_t *, size_t); 53 const char *fido_credman_rp_name(const fido_credman_rp_t *, size_t); 54 55 const fido_cred_t *fido_credman_rk(const fido_credman_rk_t *, size_t); 56 const unsigned char *fido_credman_rp_id_hash_ptr(const fido_credman_rp_t *, 57 size_t); 58 59 fido_credman_metadata_t *fido_credman_metadata_new(void); 60 fido_credman_rk_t *fido_credman_rk_new(void); 61 fido_credman_rp_t *fido_credman_rp_new(void); 62 63 int fido_credman_del_dev_rk(fido_dev_t *, const unsigned char *, size_t, 64 const char *); 65 int fido_credman_get_dev_metadata(fido_dev_t *, fido_credman_metadata_t *, 66 const char *); 67 int fido_credman_get_dev_rk(fido_dev_t *, const char *, fido_credman_rk_t *, 68 const char *); 69 int fido_credman_get_dev_rp(fido_dev_t *, fido_credman_rp_t *, const char *); 70 71 size_t fido_credman_rk_count(const fido_credman_rk_t *); 72 size_t fido_credman_rp_count(const fido_credman_rp_t *); 73 size_t fido_credman_rp_id_hash_len(const fido_credman_rp_t *, size_t); 74 75 uint64_t fido_credman_rk_existing(const fido_credman_metadata_t *); 76 uint64_t fido_credman_rk_remaining(const fido_credman_metadata_t *); 77 78 void fido_credman_metadata_free(fido_credman_metadata_t **); 79 void fido_credman_rk_free(fido_credman_rk_t **); 80 void fido_credman_rp_free(fido_credman_rp_t **); 81 82 #endif /* !_FIDO_CREDMAN_H */ 83