BSL v0.0.0
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
SamplePolicyProvider.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
28#ifndef BSLP_SAMPLE_POLICY_PROVIDER_H
29#define BSLP_SAMPLE_POLICY_PROVIDER_H
30
31#include <stdint.h>
32
33#include <BPSecLib_Private.h>
34
42typedef struct
43{
44 BSL_PolicyLocation_e location;
45 BSL_HostEIDPattern_t src_eid_pattern;
46 BSL_HostEIDPattern_t secsrc_eid_pattern;
47 BSL_HostEIDPattern_t dst_eid_pattern;
49
64 BSL_HostEIDPattern_t src_eid_pattern, BSL_HostEIDPattern_t secsrc_eid_pattern,
65 BSL_HostEIDPattern_t dst_eid_pattern);
66
67void BSLP_PolicyPredicate_Deinit(BSLP_PolicyPredicate_t *self);
68
78 BSL_HostEID_t src_eid, BSL_HostEID_t dst_eid);
79
93typedef struct BSLP_PolicyRule_s
94{
95 BSL_StaticString_t description;
96 BSLP_PolicyPredicate_t *predicate;
97 BSL_SecRole_e role;
98 BSL_BundleBlockTypeCode_e target_block_type;
99 BSL_SecBlockType_e sec_block_type;
100 uint64_t context_id;
101 BSL_SecParam_t *params;
102 size_t nparams;
103 BSL_PolicyAction_e failure_action_code;
105
119int BSLP_PolicyRule_Init(BSLP_PolicyRule_t *self, const char *desc, BSLP_PolicyPredicate_t *predicate,
120 uint64_t context_id, BSL_SecRole_e role, BSL_SecBlockType_e sec_block_type,
121 BSL_BundleBlockTypeCode_e target_block_type, BSL_PolicyAction_e failure_action_code);
122
129
137
149 const BSL_BundleRef_t *bundle, BSL_PolicyLocation_e location);
150
151#define BSLP_POLICYPREDICATE_ARRAY_CAPACITY (100)
154{
155 BSL_StaticString_t name;
156 BSLP_PolicyPredicate_t predicates[BSLP_POLICYPREDICATE_ARRAY_CAPACITY];
157 size_t predicate_count;
158 BSLP_PolicyRule_t rules[BSLP_POLICYPREDICATE_ARRAY_CAPACITY];
159 size_t rule_count;
161
162void BSLP_Deinit(void *user_data);
163
164int BSLP_QueryPolicy(const void *user_data, BSL_SecurityActionSet_t *output_action_set, const BSL_BundleRef_t *bundle,
165 BSL_PolicyLocation_e location);
166#endif // BSLP_SAMPLE_POLICY_PROVIDER_H
Single entry-point include file for all of the BPSec Lib (BSL) frontend API.
BSL_SecBlockType_e
RFC 9172-specified block type codes for BIB and BCB.
BSL_BundleBlockTypeCode_e
Block types using IANA-assigned code points from .
BSL_PolicyAction_e
Codes indicating the fate of a block if a security operation over it fails.
BSL_SecRole_e
Security role of an operation.
BSL_PolicyLocation_e
Indicates where in the lifecycle of the BPA the bundle is querying for security policy.
struct BSLP_PolicyProvider_s BSLP_PolicyProvider_t
Concrete definition of the BSL_PolicyProvider_t.
int BSLP_PolicyRule_EvaluateAsSecOper(const BSLP_PolicyRule_t *self, BSL_SecOper_t *sec_oper, const BSL_BundleRef_t *bundle, BSL_PolicyLocation_e location)
Critical function creating a security operation from a bundle and location.
int BSLP_PolicyRule_Init(BSLP_PolicyRule_t *self, const char *desc, BSLP_PolicyPredicate_t *predicate, uint64_t context_id, BSL_SecRole_e role, BSL_SecBlockType_e sec_block_type, BSL_BundleBlockTypeCode_e target_block_type, BSL_PolicyAction_e failure_action_code)
Initialize this policy rule.
bool BSLP_PolicyPredicate_IsMatch(const BSLP_PolicyPredicate_t *self, BSL_PolicyLocation_e location, BSL_HostEID_t src_eid, BSL_HostEID_t dst_eid)
Returns true if the given predicate matches the arguments.
void BSLP_PolicyRule_AddParam(BSLP_PolicyRule_t *self, const BSL_SecParam_t *param)
Include a BPSec parameter to this rule.
void BSLP_PolicyPredicate_Init(BSLP_PolicyPredicate_t *self, BSL_PolicyLocation_e location, BSL_HostEIDPattern_t src_eid_pattern, BSL_HostEIDPattern_t secsrc_eid_pattern, BSL_HostEIDPattern_t dst_eid_pattern)
Initialize this policy predicate.
int BSLP_QueryPolicy(const void *user_data, BSL_SecurityActionSet_t *output_action_set, const BSL_BundleRef_t *bundle, BSL_PolicyLocation_e location)
Note that criticality is HIGH.
void BSLP_PolicyRule_Deinit(BSLP_PolicyRule_t *self)
De-initialize, release any resources, and zero this struct.
struct BSLP_PolicyRule_s BSLP_PolicyRule_t
Represents a policy rule.
THE key function that matches a bundle against a rule to provide the output action and specific param...
Concrete definition of the BSL_PolicyProvider_t.
Represents a policy rule.
Reference to a Bundle owned and stored in the host BPA.
Reference to a EID pattern owned and stored in the BPA.
Opaque pointer to BPA-specific Endpoint ID storage.
Contains the populated security operations for this bundle.