1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! IPsec Encapsulating Security Payload (ESP, RFC 4303) Layer 3 wire builder.
//!
//! Serializes an [`IpsecSpec`] / [`EspSpec`] into an RFC 4303 IPsec ESP wire payload encapsulated
//! directly inside IPv4 or IPv6 with protocol / Next Header number `50` (`0x32`). The builder
//! writes the 32-bit big-endian Security Parameters Index (`SPI`, default `0x1000`), 32-bit
//! big-endian Sequence Number (`SEQ`, default `1`), explicit Initialization Vector (`IV`, default
//! 8 zeroed bytes), encrypted payload (or 16-byte `0xAA` dummy ciphertext when unspecified), ESP
//! trailer (`Pad Length = 0` and `Next Header` default `59`), and trailing Integrity Check Value (`ICV`).
//!
//! Canonical `.fasm` syntax:
//! `a -> b [ESP | IPSEC] [SPI <u32>] [SEQ <u32>] [IV "<hex>"] [ICV "<hex>"] [NEXT_HEADER <u8>] [PAYLOAD "<str>" | HEXPAYLOAD "<hex>"]`
use crate*;
use Vec;
/// Builds an RFC 4303 IPsec Encapsulating Security Payload (`ESP`) body and returns `(bytes, 50)`.