Hybrid ICN (hICN) plugin  v21.06-rc0-4-g18fa668
ah.h
1 /*
2  * Copyright (c) 2017-2019 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
20 #ifndef HICN_PROTOCOL_AH_H
21 #define HICN_PROTOCOL_AH_H
22 
23 #include "../common.h"
24 
25 /*
26  * The TCP PSH flag is set to indicate TCP payload in fact contains a AH header
27  * with signature information for the packet
28  */
29 #define AH_FLAG 0x10
30 
31 /*
32  * The length of the AH struct must be 44 bytes.
33  */
34 #define EXPECTED_AH_HDRLEN 44
35 
36 typedef struct
37 {
38  u8 nh; // (to match with reserved in IPSEC AH)
39  u8 payloadlen; // Len of signature/HMAC in 4-bytes words (maximum size)
40  union
41  {
42  u16 reserved;
43 
44  struct
45  {
46  u8 validationAlgorithm; // As defined in parc_SignerAlgorithm.h
47  u8 signatureGap; // used to match IPSEC specification and to
48  // have the real size of the signature(without
49  // padding). It is the result of Maximum
50  // signature size - real size
51  };
52  };
53  union
54  {
55  struct
56  {
57  u32 spi;
58  u32 seq;
59  };
60  // Unix timestamp indicating when the signature has been calculated
61  u8 timestamp_as_u8[8];
62  u16 timestamp_as_u16[4];
63  u32 timestamp_as_u32[2];
64  };
65  // ICV would follow
66  u8 keyId[32]; // Hash of pub key
67  /* 44 B + validationPayload */
68  u8 validationPayload[0]; // Holds the signature
69 } _ah_header_t;
70 
71 #define AH_HDRLEN sizeof (_ah_header_t)
72 static_assert (EXPECTED_AH_HDRLEN == AH_HDRLEN,
73  "Size of AH Struct does not match its expected size.");
74 
75 #endif /* HICN_PROTOCOL_AH_H */
76 
77 /*
78  * fd.io coding-style-patch-verification: ON
79  *
80  * Local Variables:
81  * eval: (c-set-style "gnu")
82  * End:
83  */
_ah_header_t
Definition: ah.h:36