BSL v0.0.0
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
AbsSecBlock.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 The Johns Hopkins University Applied Physics
3 * Laboratory LLC.
4 *
5 * This file is part of the Bundle Protocol Security Library (BSL).
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * This work was performed for the Jet Propulsion Laboratory, California
18 * Institute of Technology, sponsored by the United States Government under
19 * the prime contract 80NM0018D0004 between the Caltech and NASA under
20 * subcontract 1700763.
21 */
26#include <qcbor/qcbor_encode.h>
27#include <qcbor/qcbor_spiffy_decode.h>
28
29#include <BPSecLib_Private.h>
30
31#include "AbsSecBlock.h"
32
33size_t BSL_AbsSecBlock_Sizeof(void)
34{
35 return sizeof(BSL_AbsSecBlock_t);
36}
37
39{
40 // NOLINTBEGIN
41 CHK_AS_BOOL(self != NULL);
42 CHK_AS_BOOL(self->sec_context_id > 0);
43 CHK_AS_BOOL(self->source_eid.handle != NULL);
44 CHK_AS_BOOL(BSLB_SecParamList_size(self->params) < 10000);
45
46 // Invariant: Must have at least one result
47 CHK_AS_BOOL(BSLB_SecResultList_size(self->results) < 10000);
48
49 // Invariant: Must have at least one target
50 CHK_AS_BOOL(uint64_list_size(self->targets) < 10000);
51 // NOLINTEND
52 return true;
53}
54
56{
57 BSL_StaticString_t str;
58 BSL_LOG_INFO("ASB context id: %lu", self->sec_context_id);
59 for (size_t index = 0; index < uint64_list_size(self->targets); index++)
60 {
61 BSL_LOG_INFO("ASB target[%lu]: %lu", index, *uint64_list_get(self->targets, index));
62 }
63
64 for (size_t index = 0; index < BSLB_SecParamList_size(self->params); index++)
65 {
66 BSL_SecParam_t *param = BSLB_SecParamList_get(self->params, index);
67 BSL_LOG_INFO("ASB Param[%lu]: id=%lu val=%lu", index, param->param_id, param->_uint_value);
68 }
69
70 for (size_t index = 0; index < BSLB_SecResultList_size(self->results); index++)
71 {
72 BSL_SecResult_t *sec_result = BSLB_SecResultList_get(self->results, index);
73 BSL_Log_DumpAsHexString((uint8_t*)str, sizeof(str), sec_result->_bytes, sec_result->_bytelen);
74 BSL_LOG_INFO("ASB Result[%lu]: tgt=%lu, id=%lu %s", index, sec_result->target_block_num, sec_result->result_id, str);
75 }
76}
77
79{
80 ASSERT_ARG_NONNULL(self);
81
82 memset(self, 0, sizeof(*self));
83 BSLB_SecParamList_init(self->params);
84 BSLB_SecResultList_init(self->results);
85 uint64_list_init(self->targets);
86}
87
88void BSL_AbsSecBlock_Init(BSL_AbsSecBlock_t *self, uint64_t sec_context_id, BSL_HostEID_t source_eid)
89{
90 ASSERT_ARG_NONNULL(self);
91 memset(self, 0, sizeof(*self));
92 self->sec_context_id = sec_context_id;
93 self->source_eid = source_eid;
94 BSLB_SecParamList_init(self->params);
95 BSLB_SecResultList_init(self->results);
96 uint64_list_init(self->targets);
97 ASSERT_POSTCONDITION(BSL_AbsSecBlock_IsConsistent(self));
98}
99
101{
102 ASSERT_PRECONDITION(BSL_AbsSecBlock_IsConsistent(self));
103
104 BSLB_SecParamList_clear(self->params);
105 BSLB_SecResultList_clear(self->results);
106 uint64_list_clear(self->targets);
107 BSL_HostEID_Deinit(&self->source_eid);
108 memset(self, 0, sizeof(*self));
109}
110
112{
113 ASSERT_ARG_NONNULL(self);
114 bool is_empty = (uint64_list_size(self->targets) == 0) && (BSLB_SecResultList_size(self->results) == 0);
115 return is_empty;
116}
117
118bool BSL_AbsSecBlock_ContainsTarget(const BSL_AbsSecBlock_t *self, uint64_t target_block_num)
119{
120 ASSERT_PRECONDITION(BSL_AbsSecBlock_IsConsistent(self));
121 for
122 M_EACH(target_num, self->targets, LIST_OPLIST(uint64_list))
123 {
124 if (*target_num == target_block_num)
125 {
126 return true;
127 }
128 }
129 return false;
130}
131
132void BSL_AbsSecBlock_AddTarget(BSL_AbsSecBlock_t *self, uint64_t target_block_id)
133{
134 ASSERT_PRECONDITION(BSL_AbsSecBlock_IsConsistent(self));
135
136 uint64_list_push_back(self->targets, target_block_id);
137
138 ASSERT_POSTCONDITION(BSL_AbsSecBlock_IsConsistent(self));
139}
140
142{
143 ASSERT_ARG_NONNULL(param);
144 ASSERT_PRECONDITION(BSL_AbsSecBlock_IsConsistent(self));
145
146 BSLB_SecParamList_push_back(self->params, *param);
147
148 ASSERT_POSTCONDITION(BSL_AbsSecBlock_IsConsistent(self));
149}
150
152{
153 ASSERT_ARG_NONNULL(result);
154 ASSERT_PRECONDITION(BSL_AbsSecBlock_IsConsistent(self));
155
156 BSLB_SecResultList_push_back(self->results, *result);
157
158 ASSERT_POSTCONDITION(BSL_AbsSecBlock_IsConsistent(self));
159}
160
161static size_t BSL_AbsSecBlock_GetResultCnt(const BSL_AbsSecBlock_t *self, uint64_t target_block_id)
162{
163 ASSERT_PRECONDITION(BSL_AbsSecBlock_IsConsistent(self));
164
165 size_t match_count = 0;
166 for (size_t index = 0; index < BSLB_SecResultList_size(self->results); index++)
167 {
168 BSL_SecResult_t *result = BSLB_SecResultList_get(self->results, index);
169 if (result->target_block_num == target_block_id)
170 {
171 match_count++;
172 }
173 }
174 return match_count;
175}
176
177int BSL_AbsSecBlock_StripResults(BSL_AbsSecBlock_t *self, uint64_t target_block_num)
178{
179 CHK_PRECONDITION(BSL_AbsSecBlock_IsConsistent(self));
180
181 size_t things_removed = 0;
182
183 // Remove target uint64 from target list
184 // TODO - The m-list is not ideal. We should just use an array.
185 uint64_list_it_t target_iter;
186 uint64_list_it(target_iter, self->targets);
187 for (size_t i = 0; i < uint64_list_size(self->targets); i++)
188 {
189 uint64_t *curr_target = uint64_list_ref(target_iter);
190 if (*curr_target == target_block_num)
191 {
192 break;
193 }
194 uint64_list_next(target_iter);
195 }
196 ASSERT_PROPERTY(!uint64_list_end_p(target_iter));
197
198 uint64_list_remove(self->targets, target_iter);
199 things_removed++;
200
201 while (BSL_AbsSecBlock_GetResultCnt(self, target_block_num) > 0)
202 {
203 BSLB_SecResultList_it_t result_iter;
204 BSLB_SecResultList_it(result_iter, self->results);
205 size_t index = 0;
206 for (index = 0; index < BSLB_SecResultList_size(self->results); index++)
207 {
208 BSL_SecResult_t *sec_result = BSLB_SecResultList_ref(result_iter);
209 if (sec_result->target_block_num == target_block_num)
210 {
211 break;
212 }
213 BSLB_SecResultList_next(result_iter);
214 }
215
216 if (!BSLB_SecResultList_end_p(result_iter) && index < BSLB_SecResultList_size(self->results))
217 {
218 BSLB_SecResultList_remove(self->results, result_iter);
219 things_removed++;
220 }
221 else
222 {
223 // It should have always found one.
224 BSL_LOG_ERR("Expected to have result to remove");
226 }
227 }
228
229 CHK_POSTCONDITION(BSL_AbsSecBlock_IsConsistent(self));
230 return (int)things_removed;
231}
232
233int BSL_AbsSecBlock_EncodeToCBOR(const BSL_AbsSecBlock_t *self, BSL_Data_t allocated_target)
234{
235 CHK_ARG_NONNULL(allocated_target.ptr);
236 CHK_ARG_EXPR(allocated_target.len > 0);
237
238 CHK_PRECONDITION(BSL_AbsSecBlock_IsConsistent(self));
239
240 QCBOREncodeContext encoder;
241 UsefulBuf allocated_buf = { .ptr = allocated_target.ptr, .len = allocated_target.len };
242 QCBOREncode_Init(&encoder, allocated_buf);
243
244 {
245 QCBOREncode_OpenArray(&encoder);
246 for (size_t target_index = 0; target_index < uint64_list_size(self->targets); target_index++)
247 {
248 QCBOREncode_AddUInt64(&encoder, *uint64_list_get(self->targets, target_index));
249 }
250 QCBOREncode_CloseArray(&encoder);
251 }
252
253 {
254 QCBOREncode_AddUInt64(&encoder, self->sec_context_id);
255 }
256
257 {
258 // TODO - Maybe this should be generated on-the-fly
259 uint64_t flags = BSLB_SecParamList_size(self->params) > 0 ? true : false;
260 QCBOREncode_AddUInt64(&encoder, flags);
261 }
262
263 BSL_HostEID_EncodeToCBOR(&self->source_eid, (void *)&encoder);
264
265 {
266 QCBOREncode_OpenArray(&encoder);
267 for (size_t param_index = 0; param_index < BSLB_SecParamList_size(self->params); param_index++)
268 {
269 const BSL_SecParam_t *param = BSLB_SecParamList_cget(self->params, param_index);
270 QCBOREncode_OpenArray(&encoder);
271 QCBOREncode_AddUInt64(&encoder, param->param_id);
272 if (BSL_SecParam_IsInt64(param))
273 {
274 QCBOREncode_AddUInt64(&encoder, BSL_SecParam_GetAsUInt64(param));
275 }
276 else
277 {
278 BSL_Data_t bytestr;
279 BSL_SecParam_GetAsBytestr(param, &bytestr);
280 UsefulBufC bytestr_buf = { .ptr = bytestr.ptr, .len = bytestr.len };
281 QCBOREncode_AddBytes(&encoder, bytestr_buf);
282 }
283 QCBOREncode_CloseArray(&encoder);
284 }
285 QCBOREncode_CloseArray(&encoder);
286 }
287
288 {
289 // Encode results for each target.
290 QCBOREncode_OpenArray(&encoder);
291 for (size_t target_index = 0; target_index < uint64_list_size(self->targets); target_index++)
292 {
293 QCBOREncode_OpenArray(&encoder);
294 const uint64_t *target_block_num = uint64_list_cget(self->targets, target_index);
295 for (size_t result_index = 0; result_index < BSLB_SecResultList_size(self->results); result_index++)
296 {
297 const BSL_SecResult_t *sec_result = BSLB_SecResultList_cget(self->results, result_index);
298 if (sec_result->target_block_num != *target_block_num)
299 {
300 continue;
301 }
302 QCBOREncode_OpenArray(&encoder);
303 QCBOREncode_AddUInt64(&encoder, sec_result->result_id);
304 UsefulBufC result_buf = { .ptr = sec_result->_bytes, .len = sec_result->_bytelen };
305 QCBOREncode_AddBytes(&encoder, result_buf);
306 QCBOREncode_CloseArray(&encoder);
307 }
308 QCBOREncode_CloseArray(&encoder);
309 }
310
311 QCBOREncode_CloseArray(&encoder);
312 }
313
314 UsefulBufC output_buf;
315 QCBORError qcbor_err = QCBOREncode_Finish(&encoder, &output_buf);
316 if (qcbor_err != QCBOR_SUCCESS)
317 {
318 BSL_LOG_ERR("Encoding ASB into BTSD failed: %s", qcbor_err_to_str(qcbor_err));
319 return BSL_ERR_ENCODING;
320 }
321 return (int)output_buf.len;
322}
323
325{
326 CHK_ARG_NONNULL(self);
327 CHK_ARG_EXPR(encoded_cbor.len > 0);
328 CHK_ARG_EXPR(encoded_cbor.ptr != NULL);
329
331
332 QCBORDecodeContext asbdec;
333 UsefulBufC useful_encoded_cbor = { .ptr = encoded_cbor.ptr, .len = encoded_cbor.len };
334 QCBORDecode_Init(&asbdec, useful_encoded_cbor, QCBOR_DECODE_MODE_NORMAL);
335 QCBORItem asbitem;
336
337 size_t quit = 0;
338 QCBORDecode_EnterArray(&asbdec, NULL);
339 while (QCBOR_SUCCESS == QCBORDecode_PeekNext(&asbdec, &asbitem))
340 {
341 // WARNING - This loop is liable to enter infinite loops.
342 uint64_t tgt_num = 0;
343 QCBORDecode_GetUInt64(&asbdec, &tgt_num);
344 BSL_LOG_DEBUG("got tgt %" PRIu64 "", tgt_num);
345 uint64_list_push_back(self->targets, tgt_num);
346 assert(quit++ < 20);
347 }
348 QCBORDecode_ExitArray(&asbdec);
349
350 {
351 int64_t ctx_id = 0;
352 QCBORDecode_GetInt64(&asbdec, &ctx_id);
353 if ((ctx_id < INT16_MIN) || (ctx_id > INT16_MAX))
354 {
355 BSL_LOG_WARNING("Invalid context id: %" PRId64, ctx_id);
356 }
357 else
358 {
359 self->sec_context_id = ctx_id;
360 }
361 BSL_LOG_DEBUG("got ctx_id %" PRId64, ctx_id);
362 }
363
364 uint64_t flags = 0;
365 QCBORDecode_GetUInt64(&asbdec, &flags);
366 BSL_LOG_DEBUG("got flags %" PRId64, flags);
367
368 // Host-specific parsing of EID
369 BSL_HostEID_Init(&self->source_eid);
370 BSL_HostEID_DecodeFromCBOR(&self->source_eid, &asbdec);
371
372 // A zero value for flags means there are NO paramers, a value of 1 indicates there are parameters to parse.
373 if (flags != 0)
374 {
375 // variable length array of parameters
376 QCBORDecode_EnterArray(&asbdec, NULL);
377 while (QCBOR_SUCCESS == QCBORDecode_PeekNext(&asbdec, &asbitem))
378 {
379 // each parameter is a 2-item array
380 QCBORDecode_EnterArray(&asbdec, NULL);
381
382 uint64_t item_id = 0;
383 QCBORDecode_GetUInt64(&asbdec, &item_id);
384
385 const size_t item_begin = QCBORDecode_Tell(&asbdec);
386 // QCBORDecode_VGetNextConsume(&asbdec, &asbitem);
387 QCBORDecode_PeekNext(&asbdec, &asbitem);
388 if (asbitem.uDataType == QCBOR_TYPE_INT64)
389 {
390 uint64_t param_u64_value = 0;
391 QCBORDecode_GetUInt64(&asbdec, &param_u64_value);
392 BSL_LOG_DEBUG("ASB: Parsed Param[%lu] = %lu", item_id, param_u64_value);
393 BSL_SecParam_t param;
394 BSL_SecParam_InitInt64(&param, item_id, param_u64_value);
395 BSLB_SecParamList_push_back(self->params, param);
396 }
397 else if (asbitem.uDataType == QCBOR_TYPE_BYTE_STRING)
398 {
399 UsefulBufC target_buf;
400 QCBORDecode_GetByteString(&asbdec, &target_buf);
401 BSL_LOG_DEBUG("ASB: Parsed Param[%lu] (ByteStr) = %lu bytes", item_id, target_buf.len);
402 BSL_SecParam_t param;
403 BSL_Data_t data_view = { .owned = 0, .ptr = (uint8_t *)target_buf.ptr, .len = target_buf.len };
404 BSL_SecParam_InitBytestr(&param, item_id, data_view);
405 BSLB_SecParamList_push_back(self->params, param);
406 }
407 else
408 {
409 // This is a failure case - should more clearly return?
410 BSL_LOG_ERR("Unhandled case");
411 // NOLINTNEXTLINE
412 exit(1);
413 }
414
415 const size_t item_end = QCBORDecode_Tell(&asbdec);
416 BSL_LOG_DEBUG("param %" PRIu64 " between %" PRId64 " and %" PRId64, item_id, item_begin, item_end);
417
418 QCBORDecode_ExitArray(&asbdec);
419 }
420 QCBORDecode_ExitArray(&asbdec);
421 }
422
423 QCBORDecode_EnterArray(&asbdec, NULL);
424 size_t result_index = 0;
425 while (QCBOR_SUCCESS == QCBORDecode_PeekNext(&asbdec, &asbitem))
426 {
427 // Now get the target_id at that index
428 size_t target_id = 0;
429 for (size_t i = 0; i < uint64_list_size(self->targets); i++)
430 {
431 if (i == result_index)
432 {
433 target_id = *uint64_list_get(self->targets, i);
434 break;
435 }
436 }
437 result_index++;
438
439 BSL_LOG_DEBUG("Parsing ASB results for target[index=%lu, block#=%lu]", result_index, target_id);
440
441 // variable length array of results
442 QCBORDecode_EnterArray(&asbdec, NULL);
443 while (QCBOR_SUCCESS == QCBORDecode_PeekNext(&asbdec, &asbitem))
444 {
445 // each parameter is a 2-item array
446 QCBORDecode_EnterArray(&asbdec, NULL);
447
448 uint64_t item_id = 0;
449 QCBORDecode_GetUInt64(&asbdec, &item_id);
450
451 const size_t item_begin = QCBORDecode_Tell(&asbdec);
452 // QCBORDecode_VGetNextConsume(&asbdec, &asbitem);
453 QCBORError is_ok = QCBORDecode_PeekNext(&asbdec, &asbitem);
454 CHK_PROPERTY(is_ok == QCBOR_SUCCESS);
455
456 if (asbitem.uDataType == QCBOR_TYPE_BYTE_STRING)
457 {
458 UsefulBufC buf;
459 QCBORDecode_GetByteString(&asbdec, &buf);
460 BSL_Data_t bufdata = { .owned = 0, .ptr = (uint8_t *)buf.ptr, .len = buf.len };
461 BSL_SecResult_t result;
462 int result_code = BSL_SecResult_Init(&result, item_id, self->sec_context_id, target_id, bufdata);
463 ASSERT_PROPERTY(result_code == 0);
464 BSL_LOG_DEBUG("ASB: Parsed Result (target_block=%lu, len=%lu)", result.target_block_num,
465 result._bytelen);
466 BSLB_SecResultList_push_back(self->results, result);
467 }
468 else
469 {
470 // Invalid case that needs better handling.
471 // NOLINTNEXTLINE
472 exit(1); // NOLINT
473 }
474 const size_t item_end = QCBORDecode_Tell(&asbdec);
475 BSL_LOG_DEBUG("result %" PRIu64 " between %" PRId64 " and %" PRId64, item_id, item_begin, item_end);
476
477 QCBORDecode_ExitArray(&asbdec);
478 }
479 QCBORDecode_ExitArray(&asbdec);
480 }
481 QCBORDecode_ExitArray(&asbdec);
482
483 QCBORError err = QCBORDecode_Finish(&asbdec);
484 if (err != QCBOR_SUCCESS)
485 {
486 BSL_LOG_WARNING("ASB decoding error %" PRIu32 " (%s)", err, qcbor_err_to_str(err));
487 return BSL_ERR_DECODING;
488 }
489
490 ASSERT_POSTCONDITION(BSL_AbsSecBlock_IsConsistent(self));
491 return BSL_SUCCESS;
492}
Concrete implementation of ASB and its functionality.
Single entry-point include file for all of the BPSec Lib (BSL) frontend API.
#define BSL_LOG_DEBUG(...)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool BSL_AbsSecBlock_ContainsTarget(const BSL_AbsSecBlock_t *self, uint64_t target_block_num)
Returns true if a given ASB contains the given block number as a security target.
void BSL_AbsSecBlock_Deinit(BSL_AbsSecBlock_t *self)
Deinitializes and clears this ASB, clearing and releasing any owned memory.
void BSL_AbsSecBlock_AddResult(BSL_AbsSecBlock_t *self, const BSL_SecResult_t *result)
Add a security result to this security block (does NOT copy)
#define BSL_LOG_INFO(...)
This is an overloaded member function, provided for convenience. It differs from the above function o...
struct BSL_AbsSecBlock_s BSL_AbsSecBlock_t
Forward declaration of BSL_AbsSecBlock_t.
#define BSL_LOG_WARNING(...)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void BSL_AbsSecBlock_AddTarget(BSL_AbsSecBlock_t *self, uint64_t target_block_id)
Adds a given block ID as a security target covered by this ASB.
int BSL_AbsSecBlock_StripResults(BSL_AbsSecBlock_t *self, uint64_t target_block_num)
Remove security parameters and results found in outcome from this ASB.
void BSL_AbsSecBlock_Init(BSL_AbsSecBlock_t *self, uint64_t sec_context_id, BSL_HostEID_t source_eid)
Populate a pre-allocated Absract Security Block.
void BSL_AbsSecBlock_InitEmpty(BSL_AbsSecBlock_t *self)
Initialize a pre-allocated ASB with no contents.
int BSL_AbsSecBlock_DecodeFromCBOR(BSL_AbsSecBlock_t *self, BSL_Data_t encoded_cbor)
Decodes and populates this ASB from a CBOR string.
bool BSL_AbsSecBlock_IsEmpty(const BSL_AbsSecBlock_t *self)
Returns true if this ASB contains nothing (i.e., no tarets, params and results)
size_t BSL_AbsSecBlock_Sizeof(void)
Returns the size of the AbsSecBlock struct in bytes.
int BSL_AbsSecBlock_EncodeToCBOR(const BSL_AbsSecBlock_t *self, BSL_Data_t allocated_target)
Encodes this ASB into a CBOR string into the space pre-allocated indicated by the argument.
void BSL_AbsSecBlock_AddParam(BSL_AbsSecBlock_t *self, const BSL_SecParam_t *param)
Add a security parameter to this security block (does NOT copy)
#define BSL_LOG_ERR(...)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool BSL_AbsSecBlock_IsConsistent(const BSL_AbsSecBlock_t *self)
Checks internal consistency and sanity of this structure.
@ BSL_ERR_PROPERTY_CHECK_FAILED
The BSL of a structure within it is not in a valid state.
@ BSL_ERR_ENCODING
CBOR encoding failure.
@ BSL_ERR_DECODING
CBOR decoding failure.
@ BSL_SUCCESS
Placeholder for non-error code.
void BSL_AbsSecBlock_Print(const BSL_AbsSecBlock_t *self)
Prints to LOG INFO.
int BSL_HostEID_DecodeFromCBOR(BSL_HostEID_t *eid, void *decoder)
Load an EID from CBOR.
int BSL_HostEID_EncodeToCBOR(const BSL_HostEID_t *eid, void *user_data)
Encode a EID into a CBOR sequence.
int BSL_HostEID_Init(BSL_HostEID_t *eid)
Initialize an abstract EID.
void BSL_HostEID_Deinit(BSL_HostEID_t *eid)
De-initialize an abstract EID.
uint8_t * BSL_Log_DumpAsHexString(uint8_t *dstbuf, size_t dstlen, const uint8_t *srcbuf, size_t srclen)
NOLINTEND.
int BSL_SecParam_IsInt64(const BSL_SecParam_t *self)
Returns true when the value type is an integer.
Definition SecParam.c:63
int BSL_SecParam_GetAsBytestr(const BSL_SecParam_t *self, BSL_Data_t *result)
Retrieve bytestring value of result when security parameter type is bytestring.
Definition SecParam.c:77
int BSL_SecParam_InitInt64(BSL_SecParam_t *self, uint64_t param_id, uint64_t value)
Initialize as a parameter containing an integer as a value.
Definition SecParam.c:51
int BSL_SecParam_InitBytestr(BSL_SecParam_t *self, uint64_t param_id, BSL_Data_t value)
Initialize as a parameter containing a bytestring.
Definition SecParam.c:34
uint64_t BSL_SecParam_GetAsUInt64(const BSL_SecParam_t *self)
Retrieve integer value of result when this result type is integer.
Definition SecParam.c:69
int BSL_SecResult_Init(BSL_SecResult_t *self, uint64_t result_id, uint64_t context_id, uint64_t target_block_num, BSL_Data_t content)
Populate a pre-allocated SecResult.
Definition SecResult.c:28
Heap data storage and views.
size_t len
Size of the data buffer.
BSL_DataPtr_t ptr
Pointer to the front of the buffer.
bool owned
True if this data is a copy.
Opaque pointer to BPA-specific Endpoint ID storage.
uint64_t param_id
Parameter ID.
Definition SecParam.h:70
uint64_t _uint_value
Private. When an integer, this field is populated with the correct value.
Definition SecParam.h:76
uint8_t _bytes[BSL_DEFAULT_BYTESTR_LEN+1]
Result as byte array, up to a given maximum.
Definition SecResult.h:90
uint64_t target_block_num
Target block id, put in here for convenience.
Definition SecResult.h:87
uint64_t result_id
Result ID, which is context depdendent, based on security context.
Definition SecResult.h:81
size_t _bytelen
Length of data (in bytes) of the contained bytestring. Always less than BSL_DEFAULT_BYTESTR_LEN.
Definition SecResult.h:93