Exmbus.Parser.Afl (Exmbus v0.4.0)

View Source

Authentication and Fragmentation Layer (AFL) as per EN 13757-7:2018

The Authentication and Fragmentation Sublayer provides three essential services:

— fragmentation of long messages in multiple datagrams; — a Message Authentication Code (MAC) to prove the authenticity of the TPL and APL; — a Message counter which supplies a security relevant message identification that may be used for the key derivation function (refer to 9.6.1).

This optional layer shall be applied if at least one of these services is required.

Overview of the AFL layer:

Size (bytes)Field NameDescription
1CIIndicates that an Authentication and Fragmentation Sublayer follows.
1AFLLAFL-Length
2FCLFragmentation Control field
1MCLMessage Control field *a
2KIKey Information field *a
4MCRMessage counter field *a
N *bMACMessage Authentication Code *a
2MLMessage Length field *a
  • *a This is an optional field. Their inclusion is defined by the Fragmentation Control Field specified in 6.3.2.
  • *b The length of MAC depends on AT-subfield in AFL.MCL.

All multi byte fields of AFL except the AFL.MAC shall be transmitted with least significant byte first (little endian).

Summary

Functions

Returns true if this message is part of a fragmented message.

Parses an AFL and add it to the parse context.

Verifies the MAC of the AFL. NOTE: This handler should be attached after the TPL has been parsed, so that we can use the TPL CF field to determine the key to use.

Parses an AFL and add it to the parse context.

Functions

fragmented?(afl)

Returns true if this message is part of a fragmented message.

maybe_parse(ctx)

Parses an AFL and add it to the parse context.

In contrast to parse/1, this function will not fail if the data doesn't contain an AFL. Instead, it will assign a %None{} struct to the ell context field.

maybe_verify_mac(ctx)

Verifies the MAC of the AFL. NOTE: This handler should be attached after the TPL has been parsed, so that we can use the TPL CF field to determine the key to use.

parse(ctx)

Parses an AFL and add it to the parse context.