libcoap 4.3.5-develop-146e0bb
Loading...
Searching...
No Matches
oscore_cbor.h
Go to the documentation of this file.
1/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
3/*
4 * Copyright (c) 2018, SICS, RISE AB
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the Institute nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 */
32
47#ifndef _OSCORE_CBOR_H
48#define _OSCORE_CBOR_H
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
61/* CBOR major types */
62#define CBOR_UNSIGNED_INTEGER 0
63#define CBOR_NEGATIVE_INTEGER 1
64#define CBOR_BYTE_STRING 2
65#define CBOR_TEXT_STRING 3
66#define CBOR_ARRAY 4
67#define CBOR_MAP 5
68#define CBOR_TAG 6
69#define CBOR_SIMPLE_VALUE 7
70#define CBOR_FLOATING_POINT 7
71
72#define CBOR_FALSE 20
73#define CBOR_TRUE 21
74#define CBOR_NULL 22
75
76size_t oscore_cbor_put_nil(uint8_t **buffer, size_t *buf_size);
77
78size_t oscore_cbor_put_true(uint8_t **buffer, size_t *buf_size);
79
80size_t oscore_cbor_put_false(uint8_t **buffer, size_t *buf_size);
81
82size_t oscore_cbor_put_text(uint8_t **buffer,
83 size_t *buf_size,
84 const char *text,
85 size_t text_len);
86
87size_t oscore_cbor_put_array(uint8_t **buffer, size_t *buf_size, size_t elements);
88
89size_t oscore_cbor_put_bytes(uint8_t **buffer,
90 size_t *buf_size,
91 const uint8_t *bytes,
92 size_t bytes_len);
93
94size_t oscore_cbor_put_map(uint8_t **buffer, size_t *buf_size, size_t elements);
95
96size_t oscore_cbor_put_number(uint8_t **buffer, size_t *buf_size, int64_t value);
97
98size_t oscore_cbor_put_simple_value(uint8_t **buffer, size_t *buf_size, uint8_t value);
99
100size_t oscore_cbor_put_unsigned(uint8_t **buffer, size_t *buf_size, uint64_t value);
101
102size_t oscore_cbor_put_tag(uint8_t **buffer, size_t *buf_size, uint64_t value);
103
104size_t oscore_cbor_put_negative(uint8_t **buffer, size_t *buf_size, int64_t value);
105
106uint8_t oscore_cbor_get_next_element(const uint8_t **buffer, size_t *buf_size);
107
108size_t oscore_cbor_get_element_size(const uint8_t **buffer, size_t *buf_size);
109
110uint8_t oscore_cbor_elem_contained(const uint8_t *data, size_t *buf_size,
111 uint8_t *end);
112
113uint8_t oscore_cbor_get_number(const uint8_t **data, size_t *buf_size,
114 int64_t *value);
115
116uint8_t oscore_cbor_get_simple_value(const uint8_t **data, size_t *buf_size,
117 uint8_t *value);
118
119int64_t oscore_cbor_get_negative_integer(const uint8_t **buffer,
120 size_t *buf_size);
121
122uint64_t oscore_cbor_get_unsigned_integer(const uint8_t **buffer,
123 size_t *buf_size);
124
125void oscore_cbor_get_string(const uint8_t **buffer, size_t *buf_size,
126 char *str, size_t size);
127
128void oscore_cbor_get_array(const uint8_t **buffer, size_t *buf_size,
129 uint8_t *arr, size_t size);
130
131/* oscore_cbor_get_string_array
132 * fills the the size and the array from the cbor element
133 */
134uint8_t oscore_cbor_get_string_array(const uint8_t **data, size_t *buf_size,
135 uint8_t **result, size_t *len);
136
137/* oscore_cbor_strip value
138 * strips the value of the cbor element into result
139 * and returns size
140 */
141uint8_t oscore_cbor_strip_value(const uint8_t **data, size_t *buf_size,
142 uint8_t **result, size_t *len);
143
146#ifdef __cplusplus
147}
148#endif
149
150#endif /* _OSCORE_CBOR_H */
size_t oscore_cbor_put_text(uint8_t **buffer, size_t *buf_size, const char *text, size_t text_len)
size_t oscore_cbor_get_element_size(const uint8_t **buffer, size_t *buf_size)
int64_t oscore_cbor_get_negative_integer(const uint8_t **buffer, size_t *buf_size)
size_t oscore_cbor_put_number(uint8_t **buffer, size_t *buf_size, int64_t value)
size_t oscore_cbor_put_simple_value(uint8_t **buffer, size_t *buf_size, uint8_t value)
uint8_t oscore_cbor_get_string_array(const uint8_t **data, size_t *buf_size, uint8_t **result, size_t *len)
uint8_t oscore_cbor_strip_value(const uint8_t **data, size_t *buf_size, uint8_t **result, size_t *len)
size_t oscore_cbor_put_nil(uint8_t **buffer, size_t *buf_size)
void oscore_cbor_get_string(const uint8_t **buffer, size_t *buf_size, char *str, size_t size)
uint8_t oscore_cbor_get_simple_value(const uint8_t **data, size_t *buf_size, uint8_t *value)
size_t oscore_cbor_put_false(uint8_t **buffer, size_t *buf_size)
uint8_t oscore_cbor_get_next_element(const uint8_t **buffer, size_t *buf_size)
size_t oscore_cbor_put_negative(uint8_t **buffer, size_t *buf_size, int64_t value)
size_t oscore_cbor_put_true(uint8_t **buffer, size_t *buf_size)
size_t oscore_cbor_put_unsigned(uint8_t **buffer, size_t *buf_size, uint64_t value)
size_t oscore_cbor_put_bytes(uint8_t **buffer, size_t *buf_size, const uint8_t *bytes, size_t bytes_len)
void oscore_cbor_get_array(const uint8_t **buffer, size_t *buf_size, uint8_t *arr, size_t size)
uint64_t oscore_cbor_get_unsigned_integer(const uint8_t **buffer, size_t *buf_size)
uint8_t oscore_cbor_elem_contained(const uint8_t *data, size_t *buf_size, uint8_t *end)
uint8_t oscore_cbor_get_number(const uint8_t **data, size_t *buf_size, int64_t *value)
size_t oscore_cbor_put_array(uint8_t **buffer, size_t *buf_size, size_t elements)
size_t oscore_cbor_put_map(uint8_t **buffer, size_t *buf_size, size_t elements)
size_t oscore_cbor_put_tag(uint8_t **buffer, size_t *buf_size, uint64_t value)