Skip to content

Commit

Permalink
fix plaintext split error
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanHri committed Sep 16, 2024
1 parent 54fbc4a commit fb74ec4
Show file tree
Hide file tree
Showing 20 changed files with 1,006 additions and 516 deletions.
22 changes: 20 additions & 2 deletions cddl_models/edhoc_plaintext.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,28 @@

; This file should be processed with cddl-gen (https://github.com/NordicSemiconductor/cddl-gen/tree/master) to create cbor encoding and decoding code

plaintext = ( ? C_R: int / bstr, ID_CRED_x: map / bstr / int, SGN_or_MAC_x: bstr, ? AD_x: bstr)
; plaintext 2
ptxt2 = ( C_R: int / bstr, ID_CRED_R: map2 / bstr / int, SGN_or_MAC_2: bstr, ? EAD_2: bstr)

; plaintext 3
ptxt3 = ( ID_CRED_I: map3 / bstr / int, SGN_or_MAC_3: bstr, ? EAD_3: bstr)

;currently x5bag and x5u are not supported
map = {
map2 = {
? kid: 4 => int / bstr,

? x5bag: 32 => bstr,
? x5chain: 33 => bstr,
? x5t: 34 => [alg: (int / tstr), hash: bstr ],
? x5u: 35 => bstr,

? c5b: 52 => bstr,
? c5c: 53 => bstr,
? c5t: 54 => [alg: (int / tstr), hash: bstr ],
? c5u: 55 => bstr,
}

map3 = {
? kid: 4 => int / bstr,

? x5bag: 32 => bstr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* Generated with a --default-max-qty of 3
*/

#ifndef EDHOC_DECODE_PLAINTEXT_H__
#define EDHOC_DECODE_PLAINTEXT_H__
#ifndef EDHOC_DECODE_PLAINTEXT2_H__
#define EDHOC_DECODE_PLAINTEXT2_H__

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include "cbor/edhoc_decode_plaintext_types.h"
#include "cbor/edhoc_decode_plaintext2_types.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -22,14 +22,14 @@ extern "C" {
#endif


int cbor_decode_plaintext(
int cbor_decode_ptxt2(
const uint8_t *payload, size_t payload_len,
struct plaintext *result,
struct ptxt2 *result,
size_t *payload_len_out);


#ifdef __cplusplus
}
#endif

#endif /* EDHOC_DECODE_PLAINTEXT_H__ */
#endif /* EDHOC_DECODE_PLAINTEXT2_H__ */
136 changes: 136 additions & 0 deletions inc/cbor/edhoc_decode_plaintext2_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Generated using zcbor version 0.8.99
* https://github.com/NordicSemiconductor/zcbor
* Generated with a --default-max-qty of 3
*/

#ifndef EDHOC_DECODE_PLAINTEXT2_TYPES_H__
#define EDHOC_DECODE_PLAINTEXT2_TYPES_H__

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <zcbor_common.h>

#ifdef __cplusplus
extern "C" {
#endif

/** Which value for --default-max-qty this file was created with.
*
* The define is used in the other generated file to do a build-time
* compatibility check.
*
* See `zcbor --help` for more information about --default-max-qty
*/
#define DEFAULT_MAX_QTY 3

struct map2_kid_r {
union {
int32_t map2_kid_int;
struct zcbor_string map2_kid_bstr;
};
enum {
map2_kid_int_c,
map2_kid_bstr_c,
} map2_kid_choice;
};

struct map2_x5bag {
struct zcbor_string map2_x5bag;
};

struct map2_x5chain {
struct zcbor_string map2_x5chain;
};

struct map2_x5t_r {
union {
int32_t map2_x5t_alg_int;
struct zcbor_string map2_x5t_alg_tstr;
};
enum {
map2_x5t_alg_int_c,
map2_x5t_alg_tstr_c,
} map2_x5t_alg_choice;
struct zcbor_string map2_x5t_hash;
};

struct map2_x5u {
struct zcbor_string map2_x5u;
};

struct map2_c5b {
struct zcbor_string map2_c5b;
};

struct map2_c5c {
struct zcbor_string map2_c5c;
};

struct map2_c5t_r {
union {
int32_t map2_c5t_alg_int;
struct zcbor_string map2_c5t_alg_tstr;
};
enum {
map2_c5t_alg_int_c,
map2_c5t_alg_tstr_c,
} map2_c5t_alg_choice;
struct zcbor_string map2_c5t_hash;
};

struct map2_c5u {
struct zcbor_string map2_c5u;
};

struct map2 {
struct map2_kid_r map2_kid;
bool map2_kid_present;
struct map2_x5bag map2_x5bag;
bool map2_x5bag_present;
struct map2_x5chain map2_x5chain;
bool map2_x5chain_present;
struct map2_x5t_r map2_x5t;
bool map2_x5t_present;
struct map2_x5u map2_x5u;
bool map2_x5u_present;
struct map2_c5b map2_c5b;
bool map2_c5b_present;
struct map2_c5c map2_c5c;
bool map2_c5c_present;
struct map2_c5t_r map2_c5t;
bool map2_c5t_present;
struct map2_c5u map2_c5u;
bool map2_c5u_present;
};

struct ptxt2 {
union {
int32_t ptxt2_C_R_int;
struct zcbor_string ptxt2_C_R_bstr;
};
enum {
ptxt2_C_R_int_c,
ptxt2_C_R_bstr_c,
} ptxt2_C_R_choice;
union {
struct map2 ptxt2_ID_CRED_R_map2_m;
struct zcbor_string ptxt2_ID_CRED_R_bstr;
int32_t ptxt2_ID_CRED_R_int;
};
enum {
ptxt2_ID_CRED_R_map2_m_c,
ptxt2_ID_CRED_R_bstr_c,
ptxt2_ID_CRED_R_int_c,
} ptxt2_ID_CRED_R_choice;
struct zcbor_string ptxt2_SGN_or_MAC_2;
struct zcbor_string ptxt2_EAD_2;
bool ptxt2_EAD_2_present;
};

#ifdef __cplusplus
}
#endif

#endif /* EDHOC_DECODE_PLAINTEXT2_TYPES_H__ */
35 changes: 35 additions & 0 deletions inc/cbor/edhoc_decode_plaintext3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Generated using zcbor version 0.8.99
* https://github.com/NordicSemiconductor/zcbor
* Generated with a --default-max-qty of 3
*/

#ifndef EDHOC_DECODE_PLAINTEXT3_H__
#define EDHOC_DECODE_PLAINTEXT3_H__

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include "cbor/edhoc_decode_plaintext3_types.h"

#ifdef __cplusplus
extern "C" {
#endif

#if DEFAULT_MAX_QTY != 3
#error "The type file was generated with a different default_max_qty than this file"
#endif


int cbor_decode_ptxt3(
const uint8_t *payload, size_t payload_len,
struct ptxt3 *result,
size_t *payload_len_out);


#ifdef __cplusplus
}
#endif

#endif /* EDHOC_DECODE_PLAINTEXT3_H__ */
128 changes: 128 additions & 0 deletions inc/cbor/edhoc_decode_plaintext3_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Generated using zcbor version 0.8.99
* https://github.com/NordicSemiconductor/zcbor
* Generated with a --default-max-qty of 3
*/

#ifndef EDHOC_DECODE_PLAINTEXT3_TYPES_H__
#define EDHOC_DECODE_PLAINTEXT3_TYPES_H__

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <zcbor_common.h>

#ifdef __cplusplus
extern "C" {
#endif

/** Which value for --default-max-qty this file was created with.
*
* The define is used in the other generated file to do a build-time
* compatibility check.
*
* See `zcbor --help` for more information about --default-max-qty
*/
#define DEFAULT_MAX_QTY 3

struct map3_kid_r {
union {
int32_t map3_kid_int;
struct zcbor_string map3_kid_bstr;
};
enum {
map3_kid_int_c,
map3_kid_bstr_c,
} map3_kid_choice;
};

struct map3_x5bag {
struct zcbor_string map3_x5bag;
};

struct map3_x5chain {
struct zcbor_string map3_x5chain;
};

struct map3_x5t_r {
union {
int32_t map3_x5t_alg_int;
struct zcbor_string map3_x5t_alg_tstr;
};
enum {
map3_x5t_alg_int_c,
map3_x5t_alg_tstr_c,
} map3_x5t_alg_choice;
struct zcbor_string map3_x5t_hash;
};

struct map3_x5u {
struct zcbor_string map3_x5u;
};

struct map3_c5b {
struct zcbor_string map3_c5b;
};

struct map3_c5c {
struct zcbor_string map3_c5c;
};

struct map3_c5t_r {
union {
int32_t map3_c5t_alg_int;
struct zcbor_string map3_c5t_alg_tstr;
};
enum {
map3_c5t_alg_int_c,
map3_c5t_alg_tstr_c,
} map3_c5t_alg_choice;
struct zcbor_string map3_c5t_hash;
};

struct map3_c5u {
struct zcbor_string map3_c5u;
};

struct map3 {
struct map3_kid_r map3_kid;
bool map3_kid_present;
struct map3_x5bag map3_x5bag;
bool map3_x5bag_present;
struct map3_x5chain map3_x5chain;
bool map3_x5chain_present;
struct map3_x5t_r map3_x5t;
bool map3_x5t_present;
struct map3_x5u map3_x5u;
bool map3_x5u_present;
struct map3_c5b map3_c5b;
bool map3_c5b_present;
struct map3_c5c map3_c5c;
bool map3_c5c_present;
struct map3_c5t_r map3_c5t;
bool map3_c5t_present;
struct map3_c5u map3_c5u;
bool map3_c5u_present;
};

struct ptxt3 {
union {
struct map3 ptxt3_ID_CRED_I_map3_m;
struct zcbor_string ptxt3_ID_CRED_I_bstr;
int32_t ptxt3_ID_CRED_I_int;
};
enum {
ptxt3_ID_CRED_I_map3_m_c,
ptxt3_ID_CRED_I_bstr_c,
ptxt3_ID_CRED_I_int_c,
} ptxt3_ID_CRED_I_choice;
struct zcbor_string ptxt3_SGN_or_MAC_3;
struct zcbor_string ptxt3_EAD_3;
bool ptxt3_EAD_3_present;
};

#ifdef __cplusplus
}
#endif

#endif /* EDHOC_DECODE_PLAINTEXT3_TYPES_H__ */
Loading

0 comments on commit fb74ec4

Please sign in to comment.