The 588-byte security header (Manual de Segurança do SFN §5.1, Table 1).
Field names follow the manual:
| Field | Size | Content |
|---|---|---|
c01 | 2 | header size, always 588 |
c02 | 1 | protocol version (0x02, 0x03; 0x00 for clear text) |
c03 | 1 | error code, 0x00 when there is no error |
c04 | 1 | special treatment indicator |
c05 | 1 | reserved, 0x00 |
c06 | 1 | recipient key algorithm (0x02 = RSA-2048) |
c07 | 1 | symmetric algorithm (0x01 = 3DES, 0x02 = AES-256) |
c08 | 1 | sender key algorithm (0x02 = RSA-2048) |
c09 | 1 | hash algorithm (0x03 = SHA-256) |
c10 | 1 | certification authority (PC) of the recipient certificate |
c11 | 32 | serial number of the recipient certificate (Sinetex.Serial) |
c12 | 1 | certification authority (PC) of the sender certificate |
c13 | 32 | serial number of the sender certificate |
c14 | 256 | symmetric key encrypted with RSAES-PKCS1-v1_5 |
c15 | 256 | signature, RSASSA-PKCS1-v1_5 |
c01 is read and written as a big-endian 16-bit integer.
The header is not covered by the signature: the protocol only signs the
content. Sinetex.open/2 checks every field against the certificates
involved, but bytes such as C03, C04 and C05 can be changed in transit
without breaking the signature.
Summary
Functions
Splits an envelope into its header and body.
Returns true for the "empty" header of §5.6.3: every field zeroed except
C01. The body of such an envelope is in clear text, neither signed nor
encrypted.
Encodes a header into its 588 bytes.
The header size in bytes: 588.
Types
Functions
Splits an envelope into its header and body.
Only the layout is decoded; field values are not validated. Returns
{:error, :too_short} if there are fewer than 588 bytes.
Returns true for the "empty" header of §5.6.3: every field zeroed except
C01. The body of such an envelope is in clear text, neither signed nor
encrypted.
@spec encode(t()) :: <<_::4704>>
Encodes a header into its 588 bytes.
Raises ArgumentError if a field does not fit its size.
@spec size() :: 588
The header size in bytes: 588.