BSL v0.0.0
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
BPSecLib_Public.h
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 */
22
31#ifndef BSL_BPSECLIB_PUBLIC_H_
32#define BSL_BPSECLIB_PUBLIC_H_
33
34#include <stdbool.h>
35#include <stddef.h>
36#include <stdint.h>
37
39#if defined(__GNUC__) || defined(__clang__)
40#define BSL_REQUIRE_CHECK __attribute__((warn_unused_result))
41#else
42#define BSL_REQUIRE_CHECK
43#endif
44
47
51
54
57
60
61#define BSL_DEFAULT_STRLEN (128)
62typedef char BSL_StaticString_t[BSL_DEFAULT_STRLEN];
63
79
92
97typedef struct BSL_HostEID_s
98{
99 void *handle;
101
109
114typedef struct BSL_BundleRef_s
115{
116 void *data;
118
140
146{
147 uint64_t block_num;
148 uint64_t type_code;
149 uint64_t flags;
150 uint64_t crc;
151 void *btsd;
152 size_t btsd_len;
154
157typedef struct
158{
161
163 int (*get_host_eid_fn)(const void *user_data, BSL_HostEID_t *result);
164
166 int (*eid_init)(void *user_data, BSL_HostEID_t *result);
167
169 void (*eid_deinit)(void *user_data, BSL_HostEID_t *eid);
170
172 int (*bundle_metadata_fn)(const BSL_BundleRef_t *bundle_ref, BSL_PrimaryBlock_t *result_primary_block);
173
175 int (*bundle_get_block_ids)(const BSL_BundleRef_t *bundle_ref, size_t array_count,
176 uint64_t array_block_ids[array_count], size_t *result_count);
177
179 int (*block_metadata_fn)(const BSL_BundleRef_t *bundle_ref, uint64_t block_num, BSL_CanonicalBlock_t *result_block);
180
183 int (*block_create_fn)(BSL_BundleRef_t *bundle_ref, uint64_t block_type_code, uint64_t *result_block_num);
184
186 int (*block_remove_fn)(BSL_BundleRef_t *bundle_ref, uint64_t block_num);
187
189 int (*block_realloc_btsd_fn)(BSL_BundleRef_t *bundle_ref, uint64_t block_num, size_t bytesize);
190
192 int (*eid_to_cbor)(void *encoder, const BSL_HostEID_t *eid);
193
195 int (*eid_from_cbor)(void *encoder, BSL_HostEID_t *eid);
196
198 int (*eid_from_text)(BSL_HostEID_t *eid, const char *text, void *user_data);
199
201 int (*eidpat_init)(BSL_HostEIDPattern_t *pat, void *user_data);
202
204 void (*eidpat_deinit)(BSL_HostEIDPattern_t *pat, void *user_data);
205
207 int (*eidpat_from_text)(BSL_HostEIDPattern_t *pat, const char *text, void *user_data);
208
210 bool (*eidpat_match)(const BSL_HostEIDPattern_t *pat, const BSL_HostEID_t *eid, void *user_data);
212
219
224
234
243
252int BSL_API_RegisterSecurityContext(BSL_LibCtx_t *lib, uint64_t sec_ctx_id, BSL_SecCtxDesc_t desc);
253
262
281int BSL_API_QuerySecurity(const BSL_LibCtx_t *bsl, BSL_SecurityActionSet_t *output_action_set,
282 const BSL_BundleRef_t *bundle, BSL_PolicyLocation_e location);
283
292int BSL_API_ApplySecurity(const BSL_LibCtx_t *bsl, BSL_SecurityResponseSet_t *response_output, BSL_BundleRef_t *bundle,
293 const BSL_SecurityActionSet_t *policy_actions);
294
295#endif /* BSL_BPSECLIB_PUBLIC_H_ */
struct BSL_PrimaryBlock_s BSL_PrimaryBlock_t
Contains Bundle Primary Block fields and metadata.
BSL_BundleCRCType_e
Block CRC types.
@ BSL_BUNDLECRCTYPE_NONE
No CRC value.
@ BSL_BUNDLECRCTYPE_16
CRC-16.
@ BSL_BUNDLECRCTYPE_32
CRC-32C.
BSL_REQUIRE_CHECK int BSL_API_RegisterPolicyProvider(BSL_LibCtx_t *lib, BSL_PolicyDesc_t desc)
Register a Policy Provider module with the BSL.
#define BSL_REQUIRE_CHECK
This annotation on a function requires the caller to capture and inspect the return value.
struct BSL_BundleRef_s BSL_BundleRef_t
Reference to a Bundle owned and stored in the host BPA.
struct BSL_HostEID_s BSL_HostEID_t
Opaque pointer to BPA-specific Endpoint ID storage.
int BSL_HostDescriptors_Set(BSL_HostDescriptors_t desc)
Set the BPA descriptor (callbacks) for this process.
BSL_REQUIRE_CHECK int BSL_API_InitLib(BSL_LibCtx_t *bsl)
Initialize the BPSecLib (BSL) library context.
void BSL_HostDescriptors_Get(BSL_HostDescriptors_t *desc)
Copy the BPA descriptor for this process.
struct BSL_HostEIDPattern_s BSL_HostEIDPattern_t
Reference to a EID pattern owned and stored in the BPA.
BSL_REQUIRE_CHECK int BSL_API_RegisterSecurityContext(BSL_LibCtx_t *lib, uint64_t sec_ctx_id, BSL_SecCtxDesc_t desc)
Register a security context module with the BSL.
BSL_PolicyLocation_e
Indicates where in the lifecycle of the BPA the bundle is querying for security policy.
@ BSL_POLICYLOCATION_APPOUT
Bundle destination at delivery.
@ BSL_POLICYLOCATION_APPIN
Bundle source at creation.
@ BSL_POLICYLOCATION_CLIN
Bundle ingress from CLA.
@ BSL_POLICYLOCATION_CLOUT
Bundle egress to CLA.
BSL_REQUIRE_CHECK int BSL_API_QuerySecurity(const BSL_LibCtx_t *bsl, BSL_SecurityActionSet_t *output_action_set, const BSL_BundleRef_t *bundle, BSL_PolicyLocation_e location)
Query BSL to populate a BSL_SecurityActionSet_t containg security processing instructions.
BSL_REQUIRE_CHECK int BSL_API_ApplySecurity(const BSL_LibCtx_t *bsl, BSL_SecurityResponseSet_t *response_output, BSL_BundleRef_t *bundle, const BSL_SecurityActionSet_t *policy_actions)
Performs the given security operations on a Bundle, modifying or even dropping it entirely.
struct BSL_CanonicalBlock_s BSL_CanonicalBlock_t
Structure containing parsed Canonical Block fields.
BSL_REQUIRE_CHECK int BSL_API_DeinitLib(BSL_LibCtx_t *bsl)
Deinitialize and release any resources held by the BSL.
Reference to a Bundle owned and stored in the host BPA.
void * data
Opaque pointer, not used by the BSL.
Structure containing parsed Canonical Block fields.
uint64_t flags
CBOR-decoded flags field.
uint64_t block_num
CBOR-decoded block number (should always be > 0)
void * btsd
Pointer to BTSD owned by the host BPA.
size_t btsd_len
Length in bytes of the BTSD pointer.
uint64_t crc
CBOR-decoded block CRC.
uint64_t type_code
CBOR-decoded block type code (should be > 0)
Dynamic BPA descriptor.
void * user_data
User data pointer for callbacks.
Reference to a EID pattern owned and stored in the BPA.
void * handle
Opaque pointer for BPA backend to use.
Opaque pointer to BPA-specific Endpoint ID storage.
void * handle
Opaque pointer for BPA backend to use.
Concrete definition of library context.
Descriptor of opaque data and callbacks for Policy Provider.
Contains Bundle Primary Block fields and metadata.
uint64_t field_bundle_creation_time
CBOR-decoded bundle creation time.
uint64_t field_adu_length
CBOR-decoded field of ADU length.
uint64_t field_seq_num
CBOR-decoded sequence number.
size_t block_count
Helpful count of total canonical blocks in bundle, not a field of the header.
uint64_t field_lifetime
CBOR-decoded lifetime.
BSL_HostEID_t field_src_node_id
Source in host BPA's internal representation of an EID.
uint64_t field_frag_offset
CBOR-decoded fragment offset (warning, may not be implemented yet).
uint64_t field_crc_type
CBOR-decoded field of Primary Block CRC type.
BSL_HostEID_t field_report_to_eid
Report-to EID in host BPA's internal representation of an EID.
uint64_t field_flags
CBOR-decoded field of bundle processing control flags.
uint64_t field_version
CBOR-decoded field of Primary Block BP version.
BSL_HostEID_t field_dest_eid
Destination in host BPA's internal representation of an EID.
Security Context descriptor (interface)
Contains the populated security operations for this bundle.
Contains the results and outcomes after performing the security operations.