From c8ca93efb316b7e1e35a415374d67d9a8351b07f Mon Sep 17 00:00:00 2001 From: Mazet Laurent Date: Tue, 27 May 2025 19:19:24 +0200 Subject: [PATCH] update pdu definitions --- def.h | 2 +- morep.c | 4 +- pdu_channel.c => pdu_association.c | 26 ++++---- pdu_association.h | 103 +++++++++++++++++++++++++++++ pdu_channel.h | 103 ----------------------------- 5 files changed, 119 insertions(+), 119 deletions(-) rename pdu_channel.c => pdu_association.c (52%) create mode 100644 pdu_association.h delete mode 100644 pdu_channel.h diff --git a/def.h b/def.h index a017c88..66438ff 100644 --- a/def.h +++ b/def.h @@ -24,7 +24,7 @@ #define MOREP_PAYLOAD (1496 * 16 - 1) #endif -#define AAD_LENGTH 4 +#define AAD_LENGTH 16 #define IV_LENGTH 12 #define KEY_LENGTH 32 #define TAG_LENGTH 16 diff --git a/morep.c b/morep.c index 7b1e793..a009b61 100644 --- a/morep.c +++ b/morep.c @@ -4,8 +4,8 @@ Copyright Thales 20250319 */ -/* include: def.h morep.h parse.h pdu_bypass.h pdu_channel.h pdu_clear_data.h pdu_encrypted_data.h pdu_key.h pdu_prng_param.h pdu_raw_data.h pdu_status.h verbose.h */ -/* archive: parse.o pdu_bypass.o pdu_channel.o pdu_clear_data.o pdu_encrypted_data.o pdu_key.o pdu_prng_param.o pdu_raw_data.o pdu_status.o */ +/* include: def.h morep.h parse.h pdu_association.h pdu_bypass.h pdu_clear_data.h pdu_encrypted_data.h pdu_key.h pdu_prng_param.h pdu_raw_data.h pdu_status.h verbose.h */ +/* archive: parse.o pdu_association.o pdu_bypass.o pdu_clear_data.o pdu_encrypted_data.o pdu_key.o pdu_prng_param.o pdu_raw_data.o pdu_status.o */ #include #include diff --git a/pdu_channel.c b/pdu_association.c similarity index 52% rename from pdu_channel.c rename to pdu_association.c index 90dd888..6df75d2 100644 --- a/pdu_channel.c +++ b/pdu_association.c @@ -1,12 +1,12 @@ /* - File name : pdu_channel.c + File name : pdu_association.c Projet : MERLIN Date of creation : 2025/04/08 Version : 1.0 Copyright : Thales SIX Author : Laurent Mazet - Description : This file contains functions for channel pdu + Description : This file contains functions for association pdu History : - initial version @@ -16,44 +16,44 @@ #include "parse.h" -#include "pdu_channel.h" +#include "pdu_association.h" -int parse_channel (char *line, CHANNEL_t *out) +int parse_association (char *line, ASSOCIATION_t *out) { BEGIN_PARSE (line) - PARSE_INT ("CHANNELID", out->channel_id) + PARSE_INT ("ASSOCID", out->assoc_id) PARSE_INT ("KEYID", out->key_id) END_PARSE () } -int format_channel (CHANNEL_t *in, char *buffer, int maxlen) +int format_association (ASSOCIATION_t *in, char *buffer, int maxlen) { BEGIN_FORMAT (buffer, maxlen) - FORMAT_INT ("CHANNELID", in->channel_id) + FORMAT_INT ("ASSOCID", in->assoc_id) FORMAT_INT ("KEYID", in->key_id) END_FORMAT () } -int serial_channel (CHANNEL_t *in, uint8_t *buffer, int maxlen) +int serial_association (ASSOCIATION_t *in, uint8_t *buffer, int maxlen) { BEGIN_SERIAL (buffer, maxlen) - SERIAL_INT ("CHANNELID", in->channel_id) + SERIAL_INT ("ASSOCID", in->assoc_id) SERIAL_INT ("KEYID", in->key_id) END_SERIAL () } -int deserial_channel (uint8_t *buffer, int len, CHANNEL_t *out) +int deserial_association (uint8_t *buffer, int len, ASSOCIATION_t *out) { BEGIN_DESERIAL (buffer, len) - DESERIAL_INT ("CHANNELID", out->channel_id) + DESERIAL_INT ("ASSOCID", out->assoc_id) DESERIAL_INT ("KEYID", out->key_id) END_DESERIAL () } -int check_channel (CHANNEL_t *first, CHANNEL_t *second, int fields) +int check_association (ASSOCIATION_t *first, ASSOCIATION_t *second, int fields) { BEGIN_CHECK (fields) - CHECK_INT ("CHANNELID", first->channel_id, second->channel_id) + CHECK_INT ("ASSOCID", first->assoc_id, second->assoc_id) CHECK_INT ("KEYID", first->key_id, second->key_id) END_CHECK () } diff --git a/pdu_association.h b/pdu_association.h new file mode 100644 index 0000000..4885d50 --- /dev/null +++ b/pdu_association.h @@ -0,0 +1,103 @@ +/* + File name : pdu_association.h + Projet : MERLIN + Date of creation : 2025/04/08 + Version : 1.0 + Copyright : Thales SIX + Author : Laurent Mazet + + Description : This file contains functions for association pdu + + History : + - initial version +*/ + +#ifndef __ASSOCIATION_H__ +#define __ASSOCIATION_H__ + +#include +#include + +#include "def.h" + +__BEGIN_DECLS + +/** + @defgroup ASSOCIATION + @ingroup MESSAGES +*/ + +/** + @ingroup ASSOCIATION + + association type +*/ +typedef struct { + uint8_t assoc_id; /**< association index */ + uint8_t key_id; /**< key index */ +} ASSOCIATION_t; + +/** + @ingroup ASSOCIATION + + Parse a string containing some association type fields + + @param line string to analyse + @param out output structure + @return 0 on success +*/ +int parse_association (char *line, ASSOCIATION_t *out); + +/** + @ingroup ASSOCIATION + + Format association type fields into a string + + @param in input structure + @param buffer output string + @param maxlen buffer limit + @return 0 on success +*/ +int format_association (ASSOCIATION_t *in, char *buffer, int maxlen); + +/** + @ingroup ASSOCIATION + + Serial association type fields into a network stream + + @param in input structure + @param buffer network stream + @param maxlen buffer limit + @return buffer length +*/ +int serial_association (ASSOCIATION_t *in, uint8_t *buffer, int maxlen); + +/** + @ingroup ASSOCIATION + + Deserial association type fields from a network stream + + @param buffer network stream + @param len buffer length + @param out output structure + @return 0 on success +*/ +int deserial_association (uint8_t *buffer, int len, ASSOCIATION_t *out); + +/** + @ingroup ASSOCIATION + + Check two association structures field by field + + @param first first structure + @param second second structure + @param fields field mask to be checked + @return 0 on success +*/ +int check_association (ASSOCIATION_t *first, ASSOCIATION_t *second, int fields); + +__END_DECLS + +#endif /* __ASSOCIATION_H__ */ + +/* vim: set ts=4 sw=4 si et: */ diff --git a/pdu_channel.h b/pdu_channel.h deleted file mode 100644 index 8153682..0000000 --- a/pdu_channel.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - File name : pdu_channel.h - Projet : MERLIN - Date of creation : 2025/04/08 - Version : 1.0 - Copyright : Thales SIX - Author : Laurent Mazet - - Description : This file contains functions for channel pdu - - History : - - initial version -*/ - -#ifndef __CHANNEL_H__ -#define __CHANNEL_H__ - -#include -#include - -#include "def.h" - -__BEGIN_DECLS - -/** - @defgroup CHANNEL - @ingroup MESSAGES -*/ - -/** - @ingroup CHANNEL - - Channel type -*/ -typedef struct { - uint8_t channel_id; /**< channel index */ - uint8_t key_id; /**< key index */ -} CHANNEL_t; - -/** - @ingroup CHANNEL - - Parse a string containing some channel type fields - - @param line string to analyse - @param out output structure - @return 0 on success -*/ -int parse_channel (char *line, CHANNEL_t *out); - -/** - @ingroup CHANNEL - - Format channel type fields into a string - - @param in input structure - @param buffer output string - @param maxlen buffer limit - @return 0 on success -*/ -int format_channel (CHANNEL_t *in, char *buffer, int maxlen); - -/** - @ingroup CHANNEL - - Serial channel type fields into a network stream - - @param in input structure - @param buffer network stream - @param maxlen buffer limit - @return buffer length -*/ -int serial_channel (CHANNEL_t *in, uint8_t *buffer, int maxlen); - -/** - @ingroup CHANNEL - - Deserial channel type fields from a network stream - - @param buffer network stream - @param len buffer length - @param out output structure - @return 0 on success -*/ -int deserial_channel (uint8_t *buffer, int len, CHANNEL_t *out); - -/** - @ingroup CHANNEL - - Check two channel structures field by field - - @param first first structure - @param second second structure - @param fields field mask to be checked - @return 0 on success -*/ -int check_channel (CHANNEL_t *first, CHANNEL_t *second, int fields); - -__END_DECLS - -#endif /* __CHANNEL_H__ */ - -/* vim: set ts=4 sw=4 si et: */ -- 2.30.2