1ba9bdd8bSchristos /* 2ba9bdd8bSchristos * Copyright (c) 2018 Yubico AB. All rights reserved. 3ba9bdd8bSchristos * Use of this source code is governed by a BSD-style 4ba9bdd8bSchristos * license that can be found in the LICENSE file. 5*2d40c451Schristos * SPDX-License-Identifier: BSD-2-Clause 6ba9bdd8bSchristos */ 7ba9bdd8bSchristos 8ba9bdd8bSchristos #ifndef _BLOB_H 9ba9bdd8bSchristos #define _BLOB_H 10ba9bdd8bSchristos 11ba9bdd8bSchristos #include <cbor.h> 12ba9bdd8bSchristos #include <stdlib.h> 13ba9bdd8bSchristos 14ba9bdd8bSchristos #ifdef __cplusplus 15ba9bdd8bSchristos extern "C" { 16ba9bdd8bSchristos #endif /* __cplusplus */ 17ba9bdd8bSchristos 18ba9bdd8bSchristos typedef struct fido_blob { 19ba9bdd8bSchristos unsigned char *ptr; 20ba9bdd8bSchristos size_t len; 21ba9bdd8bSchristos } fido_blob_t; 22ba9bdd8bSchristos 23ba9bdd8bSchristos typedef struct fido_blob_array { 24ba9bdd8bSchristos fido_blob_t *ptr; 25ba9bdd8bSchristos size_t len; 26ba9bdd8bSchristos } fido_blob_array_t; 27ba9bdd8bSchristos 28ba9bdd8bSchristos cbor_item_t *fido_blob_encode(const fido_blob_t *); 29ba9bdd8bSchristos fido_blob_t *fido_blob_new(void); 30ba9bdd8bSchristos int fido_blob_decode(const cbor_item_t *, fido_blob_t *); 31ba9bdd8bSchristos int fido_blob_is_empty(const fido_blob_t *); 3295dbdf32Schristos int fido_blob_set(fido_blob_t *, const u_char *, size_t); 3395dbdf32Schristos int fido_blob_append(fido_blob_t *, const u_char *, size_t); 34ba9bdd8bSchristos void fido_blob_free(fido_blob_t **); 3595dbdf32Schristos void fido_blob_reset(fido_blob_t *); 36ba9bdd8bSchristos void fido_free_blob_array(fido_blob_array_t *); 37ba9bdd8bSchristos 38ba9bdd8bSchristos #ifdef __cplusplus 39ba9bdd8bSchristos } /* extern "C" */ 40ba9bdd8bSchristos #endif /* __cplusplus */ 41ba9bdd8bSchristos 42ba9bdd8bSchristos #endif /* !_BLOB_H */ 43