xref: /freebsd/contrib/libfido2/src/blob.h (revision f81cdf24ba5436367377f7c8e8f51f6df2a75ca7)
1 /*
2  * Copyright (c) 2018 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  * SPDX-License-Identifier: BSD-2-Clause
6  */
7 
8 #ifndef _BLOB_H
9 #define _BLOB_H
10 
11 #include <cbor.h>
12 #include <stdlib.h>
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif /* __cplusplus */
17 
18 typedef struct fido_blob {
19 	unsigned char	*ptr;
20 	size_t		 len;
21 } fido_blob_t;
22 
23 typedef struct fido_blob_array {
24 	fido_blob_t	*ptr;
25 	size_t		 len;
26 } fido_blob_array_t;
27 
28 cbor_item_t *fido_blob_encode(const fido_blob_t *);
29 fido_blob_t *fido_blob_new(void);
30 int fido_blob_decode(const cbor_item_t *, fido_blob_t *);
31 int fido_blob_is_empty(const fido_blob_t *);
32 int fido_blob_set(fido_blob_t *, const u_char *, size_t);
33 int fido_blob_append(fido_blob_t *, const u_char *, size_t);
34 void fido_blob_free(fido_blob_t **);
35 void fido_blob_reset(fido_blob_t *);
36 void fido_free_blob_array(fido_blob_array_t *);
37 
38 #ifdef __cplusplus
39 } /* extern "C" */
40 #endif /* __cplusplus */
41 
42 #endif /* !_BLOB_H */
43