Add the authentication tlv base structure to tlv.h and basic tlv_pre_send() and tlv_post_recv() support. At this layer, there is no knowledge of security associations so only basic length checking and byte order swap is performed. Checks for the secParmIndicator are include but these fields are not currently supported by the 2019 standard.
Signed-off-by: Clay Kaiser <clay.kai...@ibm.com> --- tlv.c | 31 +++++++++++++++++++++++++++++++ tlv.h | 9 +++++++++ 2 files changed, 40 insertions(+) diff --git a/tlv.c b/tlv.c index 9b82bd9..d633ba6 100644 --- a/tlv.c +++ b/tlv.c @@ -993,6 +993,31 @@ static void slave_rx_sync_timing_data_pre_send(struct tlv_extra *extra) } } +static int auth_post_recv(struct tlv_extra *extra) +{ + struct authentication_tlv *auth = (struct authentication_tlv *) extra->tlv; + + if (auth->length < sizeof(*auth)) { + return -EBADMSG; + } + + NTOHL(auth->keyID); + + if (auth->secParamIndicator & 0x4) { + /* disclosedKey field indicator */ + return -EBADMSG; + } + + return 0; +} + +static void auth_pre_send(struct tlv_extra *extra) +{ + struct authentication_tlv *auth = (struct authentication_tlv *) extra->tlv; + + HTONL(auth->keyID); +} + static int unicast_message_type_valid(uint8_t message_type) { message_type >>= 4; @@ -1175,7 +1200,10 @@ int tlv_post_recv(struct tlv_extra *extra) break; case TLV_CUMULATIVE_RATE_RATIO: case TLV_PAD: + break; case TLV_AUTHENTICATION: + result = auth_post_recv(extra); + break; default: break; } @@ -1242,7 +1270,10 @@ void tlv_pre_send(struct TLV *tlv, struct tlv_extra *extra) break; case TLV_CUMULATIVE_RATE_RATIO: case TLV_PAD: + break; case TLV_AUTHENTICATION: + auth_pre_send(extra); + break; default: break; } diff --git a/tlv.h b/tlv.h index 8b51ffd..1beaac1 100644 --- a/tlv.h +++ b/tlv.h @@ -227,6 +227,15 @@ struct management_error_status { Octet data[0]; } PACKED; +struct authentication_tlv { + Enumeration16 type; + UInteger16 length; + UInteger8 spp; + Octet secParamIndicator; + UInteger32 keyID; + Octet data[0]; +} PACKED; + struct nsm_resp_tlv_head { Enumeration16 type; UInteger16 length; -- 2.42.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel