F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
SdlsAuthMask.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title SdlsAuthMask.hpp
3 // \brief SDLS additional authenticated data (AAD) construction
4 // ======================================================================
5 
6 #ifndef Svc_Ccsds_Utils_SdlsAuthMask_HPP
7 #define Svc_Ccsds_Utils_SdlsAuthMask_HPP
8 
9 #include <cstring>
10 #include "Fw/FPrimeBasicTypes.hpp"
11 
12 namespace Svc {
13 namespace Ccsds {
14 namespace Utils {
15 
16 // AES-GCM authenticates, but does not encrypt, a block of frame fields supplied as AAD. SDLS
17 // uses this to bind a frame to its virtual channel and security association. The block is a
18 // masked copy of the frame header: fields that differ between the two ends are zeroed.
19 
24 struct SdlsTcAuthMask final {
25  static constexpr FwSizeType TC_PRIMARY_HEADER_SIZE = 5;
26  static constexpr FwSizeType SPI_SIZE = 2;
27  static constexpr FwSizeType IV_SIZE = 12;
29 
31  static constexpr U8 VCID_MASK = 0xFC;
32  static constexpr FwSizeType VCID_BYTE_INDEX = 2;
33  static constexpr U8 VCID_SHIFT = 2;
34 
36 
37  SdlsTcAuthMask(U8 vcId, U16 securityAssociationIndex) {
38  (void)::memset(this->bytes, 0, SIZE);
39  this->bytes[VCID_BYTE_INDEX] = static_cast<U8>((vcId << VCID_SHIFT) & VCID_MASK);
40  this->bytes[TC_PRIMARY_HEADER_SIZE] = static_cast<U8>(securityAssociationIndex >> 8);
41  this->bytes[TC_PRIMARY_HEADER_SIZE + 1] = static_cast<U8>(securityAssociationIndex & 0xFF);
42  }
43 };
44 
50 struct SdlsTmAuthMask final {
51  static constexpr FwSizeType TM_PRIMARY_HEADER_SIZE = 6;
52  static constexpr FwSizeType SPI_SIZE = 2;
53  static constexpr FwSizeType IV_SIZE = 12;
55 
57  static constexpr U8 VCID_MASK = 0x0E;
58  static constexpr FwSizeType VCID_BYTE_INDEX = 1;
59  static constexpr U8 VCID_SHIFT = 1;
60 
62 
63  SdlsTmAuthMask(U8 vcId, U16 securityAssociationIndex) {
64  (void)::memset(this->bytes, 0, SIZE);
65  this->bytes[VCID_BYTE_INDEX] = static_cast<U8>((vcId << VCID_SHIFT) & VCID_MASK);
66  this->bytes[TM_PRIMARY_HEADER_SIZE] = static_cast<U8>(securityAssociationIndex >> 8);
67  this->bytes[TM_PRIMARY_HEADER_SIZE + 1] = static_cast<U8>(securityAssociationIndex & 0xFF);
68  }
69 };
70 
71 } // namespace Utils
72 } // namespace Ccsds
73 } // namespace Svc
74 
75 #endif
PlatformSizeType FwSizeType
static constexpr FwSizeType TC_PRIMARY_HEADER_SIZE
static constexpr FwSizeType IV_SIZE
SdlsTcAuthMask(U8 vcId, U16 securityAssociationIndex)
static constexpr FwSizeType SIZE
static constexpr FwSizeType SPI_SIZE
static constexpr FwSizeType IV_SIZE
static constexpr U8 VCID_MASK
Byte 2 holds the 6-bit VCID in bits 7..2, with the top of the frame length below it.
static constexpr FwSizeType SPI_SIZE
static constexpr FwSizeType SIZE
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
static constexpr FwSizeType VCID_BYTE_INDEX
static constexpr FwSizeType VCID_BYTE_INDEX
SdlsTmAuthMask(U8 vcId, U16 securityAssociationIndex)
static constexpr U8 VCID_MASK
Byte 1 holds the 3-bit VCID in bits 3..1, between the low spacecraft ID bits and the OCF flag...
static constexpr FwSizeType TM_PRIMARY_HEADER_SIZE
RateGroupDivider component implementation.