protocomm: Generated proto-c and python files for SRP6a scheme

- Added protobuf auto-generated files to pre-commit check
  ignore lists
This commit is contained in:
Laukik Hase 2022-05-30 15:03:54 +05:30 committed by BOT
parent 73989eb05b
commit 5169e22277
12 changed files with 981 additions and 17 deletions

View File

@ -155,6 +155,7 @@ exclude =
components/protocomm/python/constants_pb2.py,
components/protocomm/python/sec0_pb2.py,
components/protocomm/python/sec1_pb2.py,
components/protocomm/python/sec2_pb2.py,
components/protocomm/python/session_pb2.py,
components/wifi_provisioning/python/wifi_scan_pb2.py,
components/wifi_provisioning/python/wifi_config_pb2.py,

View File

@ -9,6 +9,7 @@ set(srcs
"proto-c/constants.pb-c.c"
"proto-c/sec0.pb-c.c"
"proto-c/sec1.pb-c.c"
"proto-c/sec2.pb-c.c"
"proto-c/session.pb-c.c"
"src/transports/protocomm_console.c"
"src/transports/protocomm_httpd.c")

View File

@ -0,0 +1,574 @@
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
/* Generated from: sec2.proto */
/* Do not generate deprecated warnings for self */
#ifndef PROTOBUF_C__NO_DEPRECATED
#define PROTOBUF_C__NO_DEPRECATED
#endif
#include "sec2.pb-c.h"
void s2_session_cmd0__init
(S2SessionCmd0 *message)
{
static const S2SessionCmd0 init_value = S2_SESSION_CMD0__INIT;
*message = init_value;
}
size_t s2_session_cmd0__get_packed_size
(const S2SessionCmd0 *message)
{
assert(message->base.descriptor == &s2_session_cmd0__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t s2_session_cmd0__pack
(const S2SessionCmd0 *message,
uint8_t *out)
{
assert(message->base.descriptor == &s2_session_cmd0__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t s2_session_cmd0__pack_to_buffer
(const S2SessionCmd0 *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &s2_session_cmd0__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
S2SessionCmd0 *
s2_session_cmd0__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (S2SessionCmd0 *)
protobuf_c_message_unpack (&s2_session_cmd0__descriptor,
allocator, len, data);
}
void s2_session_cmd0__free_unpacked
(S2SessionCmd0 *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &s2_session_cmd0__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void s2_session_resp0__init
(S2SessionResp0 *message)
{
static const S2SessionResp0 init_value = S2_SESSION_RESP0__INIT;
*message = init_value;
}
size_t s2_session_resp0__get_packed_size
(const S2SessionResp0 *message)
{
assert(message->base.descriptor == &s2_session_resp0__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t s2_session_resp0__pack
(const S2SessionResp0 *message,
uint8_t *out)
{
assert(message->base.descriptor == &s2_session_resp0__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t s2_session_resp0__pack_to_buffer
(const S2SessionResp0 *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &s2_session_resp0__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
S2SessionResp0 *
s2_session_resp0__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (S2SessionResp0 *)
protobuf_c_message_unpack (&s2_session_resp0__descriptor,
allocator, len, data);
}
void s2_session_resp0__free_unpacked
(S2SessionResp0 *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &s2_session_resp0__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void s2_session_cmd1__init
(S2SessionCmd1 *message)
{
static const S2SessionCmd1 init_value = S2_SESSION_CMD1__INIT;
*message = init_value;
}
size_t s2_session_cmd1__get_packed_size
(const S2SessionCmd1 *message)
{
assert(message->base.descriptor == &s2_session_cmd1__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t s2_session_cmd1__pack
(const S2SessionCmd1 *message,
uint8_t *out)
{
assert(message->base.descriptor == &s2_session_cmd1__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t s2_session_cmd1__pack_to_buffer
(const S2SessionCmd1 *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &s2_session_cmd1__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
S2SessionCmd1 *
s2_session_cmd1__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (S2SessionCmd1 *)
protobuf_c_message_unpack (&s2_session_cmd1__descriptor,
allocator, len, data);
}
void s2_session_cmd1__free_unpacked
(S2SessionCmd1 *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &s2_session_cmd1__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void s2_session_resp1__init
(S2SessionResp1 *message)
{
static const S2SessionResp1 init_value = S2_SESSION_RESP1__INIT;
*message = init_value;
}
size_t s2_session_resp1__get_packed_size
(const S2SessionResp1 *message)
{
assert(message->base.descriptor == &s2_session_resp1__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t s2_session_resp1__pack
(const S2SessionResp1 *message,
uint8_t *out)
{
assert(message->base.descriptor == &s2_session_resp1__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t s2_session_resp1__pack_to_buffer
(const S2SessionResp1 *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &s2_session_resp1__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
S2SessionResp1 *
s2_session_resp1__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (S2SessionResp1 *)
protobuf_c_message_unpack (&s2_session_resp1__descriptor,
allocator, len, data);
}
void s2_session_resp1__free_unpacked
(S2SessionResp1 *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &s2_session_resp1__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void sec2_payload__init
(Sec2Payload *message)
{
static const Sec2Payload init_value = SEC2_PAYLOAD__INIT;
*message = init_value;
}
size_t sec2_payload__get_packed_size
(const Sec2Payload *message)
{
assert(message->base.descriptor == &sec2_payload__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t sec2_payload__pack
(const Sec2Payload *message,
uint8_t *out)
{
assert(message->base.descriptor == &sec2_payload__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t sec2_payload__pack_to_buffer
(const Sec2Payload *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &sec2_payload__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
Sec2Payload *
sec2_payload__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (Sec2Payload *)
protobuf_c_message_unpack (&sec2_payload__descriptor,
allocator, len, data);
}
void sec2_payload__free_unpacked
(Sec2Payload *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &sec2_payload__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
static const ProtobufCFieldDescriptor s2_session_cmd0__field_descriptors[2] =
{
{
"client_username",
1,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_BYTES,
0, /* quantifier_offset */
offsetof(S2SessionCmd0, client_username),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"client_pubkey",
2,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_BYTES,
0, /* quantifier_offset */
offsetof(S2SessionCmd0, client_pubkey),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned s2_session_cmd0__field_indices_by_name[] = {
1, /* field[1] = client_pubkey */
0, /* field[0] = client_username */
};
static const ProtobufCIntRange s2_session_cmd0__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 2 }
};
const ProtobufCMessageDescriptor s2_session_cmd0__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"S2SessionCmd0",
"S2SessionCmd0",
"S2SessionCmd0",
"",
sizeof(S2SessionCmd0),
2,
s2_session_cmd0__field_descriptors,
s2_session_cmd0__field_indices_by_name,
1, s2_session_cmd0__number_ranges,
(ProtobufCMessageInit) s2_session_cmd0__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor s2_session_resp0__field_descriptors[3] =
{
{
"status",
1,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_ENUM,
0, /* quantifier_offset */
offsetof(S2SessionResp0, status),
&status__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"device_pubkey",
2,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_BYTES,
0, /* quantifier_offset */
offsetof(S2SessionResp0, device_pubkey),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"device_salt",
3,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_BYTES,
0, /* quantifier_offset */
offsetof(S2SessionResp0, device_salt),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned s2_session_resp0__field_indices_by_name[] = {
1, /* field[1] = device_pubkey */
2, /* field[2] = device_salt */
0, /* field[0] = status */
};
static const ProtobufCIntRange s2_session_resp0__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 3 }
};
const ProtobufCMessageDescriptor s2_session_resp0__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"S2SessionResp0",
"S2SessionResp0",
"S2SessionResp0",
"",
sizeof(S2SessionResp0),
3,
s2_session_resp0__field_descriptors,
s2_session_resp0__field_indices_by_name,
1, s2_session_resp0__number_ranges,
(ProtobufCMessageInit) s2_session_resp0__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor s2_session_cmd1__field_descriptors[1] =
{
{
"client_proof",
1,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_BYTES,
0, /* quantifier_offset */
offsetof(S2SessionCmd1, client_proof),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned s2_session_cmd1__field_indices_by_name[] = {
0, /* field[0] = client_proof */
};
static const ProtobufCIntRange s2_session_cmd1__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor s2_session_cmd1__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"S2SessionCmd1",
"S2SessionCmd1",
"S2SessionCmd1",
"",
sizeof(S2SessionCmd1),
1,
s2_session_cmd1__field_descriptors,
s2_session_cmd1__field_indices_by_name,
1, s2_session_cmd1__number_ranges,
(ProtobufCMessageInit) s2_session_cmd1__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor s2_session_resp1__field_descriptors[3] =
{
{
"status",
1,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_ENUM,
0, /* quantifier_offset */
offsetof(S2SessionResp1, status),
&status__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"device_proof",
2,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_BYTES,
0, /* quantifier_offset */
offsetof(S2SessionResp1, device_proof),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"device_nonce",
3,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_BYTES,
0, /* quantifier_offset */
offsetof(S2SessionResp1, device_nonce),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned s2_session_resp1__field_indices_by_name[] = {
2, /* field[2] = device_nonce */
1, /* field[1] = device_proof */
0, /* field[0] = status */
};
static const ProtobufCIntRange s2_session_resp1__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 3 }
};
const ProtobufCMessageDescriptor s2_session_resp1__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"S2SessionResp1",
"S2SessionResp1",
"S2SessionResp1",
"",
sizeof(S2SessionResp1),
3,
s2_session_resp1__field_descriptors,
s2_session_resp1__field_indices_by_name,
1, s2_session_resp1__number_ranges,
(ProtobufCMessageInit) s2_session_resp1__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor sec2_payload__field_descriptors[5] =
{
{
"msg",
1,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_ENUM,
0, /* quantifier_offset */
offsetof(Sec2Payload, msg),
&sec2_msg_type__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"sc0",
20,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Sec2Payload, payload_case),
offsetof(Sec2Payload, sc0),
&s2_session_cmd0__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"sr0",
21,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Sec2Payload, payload_case),
offsetof(Sec2Payload, sr0),
&s2_session_resp0__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"sc1",
22,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Sec2Payload, payload_case),
offsetof(Sec2Payload, sc1),
&s2_session_cmd1__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"sr1",
23,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Sec2Payload, payload_case),
offsetof(Sec2Payload, sr1),
&s2_session_resp1__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned sec2_payload__field_indices_by_name[] = {
0, /* field[0] = msg */
1, /* field[1] = sc0 */
3, /* field[3] = sc1 */
2, /* field[2] = sr0 */
4, /* field[4] = sr1 */
};
static const ProtobufCIntRange sec2_payload__number_ranges[2 + 1] =
{
{ 1, 0 },
{ 20, 1 },
{ 0, 5 }
};
const ProtobufCMessageDescriptor sec2_payload__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"Sec2Payload",
"Sec2Payload",
"Sec2Payload",
"",
sizeof(Sec2Payload),
5,
sec2_payload__field_descriptors,
sec2_payload__field_indices_by_name,
2, sec2_payload__number_ranges,
(ProtobufCMessageInit) sec2_payload__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCEnumValue sec2_msg_type__enum_values_by_number[4] =
{
{ "S2Session_Command0", "SEC2_MSG_TYPE__S2Session_Command0", 0 },
{ "S2Session_Response0", "SEC2_MSG_TYPE__S2Session_Response0", 1 },
{ "S2Session_Command1", "SEC2_MSG_TYPE__S2Session_Command1", 2 },
{ "S2Session_Response1", "SEC2_MSG_TYPE__S2Session_Response1", 3 },
};
static const ProtobufCIntRange sec2_msg_type__value_ranges[] = {
{0, 0},{0, 4}
};
static const ProtobufCEnumValueIndex sec2_msg_type__enum_values_by_name[4] =
{
{ "S2Session_Command0", 0 },
{ "S2Session_Command1", 2 },
{ "S2Session_Response0", 1 },
{ "S2Session_Response1", 3 },
};
const ProtobufCEnumDescriptor sec2_msg_type__descriptor =
{
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
"Sec2MsgType",
"Sec2MsgType",
"Sec2MsgType",
"",
4,
sec2_msg_type__enum_values_by_number,
4,
sec2_msg_type__enum_values_by_name,
1,
sec2_msg_type__value_ranges,
NULL,NULL,NULL,NULL /* reserved[1234] */
};

View File

@ -0,0 +1,270 @@
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
/* Generated from: sec2.proto */
#ifndef PROTOBUF_C_sec2_2eproto__INCLUDED
#define PROTOBUF_C_sec2_2eproto__INCLUDED
#include <protobuf-c/protobuf-c.h>
PROTOBUF_C__BEGIN_DECLS
#if PROTOBUF_C_VERSION_NUMBER < 1003000
# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers.
#elif 1004000 < PROTOBUF_C_MIN_COMPILER_VERSION
# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c.
#endif
#include "constants.pb-c.h"
typedef struct S2SessionCmd0 S2SessionCmd0;
typedef struct S2SessionResp0 S2SessionResp0;
typedef struct S2SessionCmd1 S2SessionCmd1;
typedef struct S2SessionResp1 S2SessionResp1;
typedef struct Sec2Payload Sec2Payload;
/* --- enums --- */
/*
* A message must be of type Cmd0 / Cmd1 / Resp0 / Resp1
*/
typedef enum _Sec2MsgType {
SEC2_MSG_TYPE__S2Session_Command0 = 0,
SEC2_MSG_TYPE__S2Session_Response0 = 1,
SEC2_MSG_TYPE__S2Session_Command1 = 2,
SEC2_MSG_TYPE__S2Session_Response1 = 3
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(SEC2_MSG_TYPE)
} Sec2MsgType;
/* --- messages --- */
/*
* Data structure of Session command0 packet
*/
struct S2SessionCmd0
{
ProtobufCMessage base;
ProtobufCBinaryData client_username;
ProtobufCBinaryData client_pubkey;
};
#define S2_SESSION_CMD0__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&s2_session_cmd0__descriptor) \
, {0,NULL}, {0,NULL} }
/*
* Data structure of Session response0 packet
*/
struct S2SessionResp0
{
ProtobufCMessage base;
Status status;
ProtobufCBinaryData device_pubkey;
ProtobufCBinaryData device_salt;
};
#define S2_SESSION_RESP0__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&s2_session_resp0__descriptor) \
, STATUS__Success, {0,NULL}, {0,NULL} }
/*
* Data structure of Session command1 packet
*/
struct S2SessionCmd1
{
ProtobufCMessage base;
ProtobufCBinaryData client_proof;
};
#define S2_SESSION_CMD1__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&s2_session_cmd1__descriptor) \
, {0,NULL} }
/*
* Data structure of Session response1 packet
*/
struct S2SessionResp1
{
ProtobufCMessage base;
Status status;
ProtobufCBinaryData device_proof;
ProtobufCBinaryData device_nonce;
};
#define S2_SESSION_RESP1__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&s2_session_resp1__descriptor) \
, STATUS__Success, {0,NULL}, {0,NULL} }
typedef enum {
SEC2_PAYLOAD__PAYLOAD__NOT_SET = 0,
SEC2_PAYLOAD__PAYLOAD_SC0 = 20,
SEC2_PAYLOAD__PAYLOAD_SR0 = 21,
SEC2_PAYLOAD__PAYLOAD_SC1 = 22,
SEC2_PAYLOAD__PAYLOAD_SR1 = 23
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(SEC2_PAYLOAD__PAYLOAD__CASE)
} Sec2Payload__PayloadCase;
/*
* Payload structure of session data
*/
struct Sec2Payload
{
ProtobufCMessage base;
/*
*!< Type of message
*/
Sec2MsgType msg;
Sec2Payload__PayloadCase payload_case;
union {
/*
*!< Payload data interpreted as Cmd0
*/
S2SessionCmd0 *sc0;
/*
*!< Payload data interpreted as Resp0
*/
S2SessionResp0 *sr0;
/*
*!< Payload data interpreted as Cmd1
*/
S2SessionCmd1 *sc1;
/*
*!< Payload data interpreted as Resp1
*/
S2SessionResp1 *sr1;
};
};
#define SEC2_PAYLOAD__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&sec2_payload__descriptor) \
, SEC2_MSG_TYPE__S2Session_Command0, SEC2_PAYLOAD__PAYLOAD__NOT_SET, {0} }
/* S2SessionCmd0 methods */
void s2_session_cmd0__init
(S2SessionCmd0 *message);
size_t s2_session_cmd0__get_packed_size
(const S2SessionCmd0 *message);
size_t s2_session_cmd0__pack
(const S2SessionCmd0 *message,
uint8_t *out);
size_t s2_session_cmd0__pack_to_buffer
(const S2SessionCmd0 *message,
ProtobufCBuffer *buffer);
S2SessionCmd0 *
s2_session_cmd0__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void s2_session_cmd0__free_unpacked
(S2SessionCmd0 *message,
ProtobufCAllocator *allocator);
/* S2SessionResp0 methods */
void s2_session_resp0__init
(S2SessionResp0 *message);
size_t s2_session_resp0__get_packed_size
(const S2SessionResp0 *message);
size_t s2_session_resp0__pack
(const S2SessionResp0 *message,
uint8_t *out);
size_t s2_session_resp0__pack_to_buffer
(const S2SessionResp0 *message,
ProtobufCBuffer *buffer);
S2SessionResp0 *
s2_session_resp0__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void s2_session_resp0__free_unpacked
(S2SessionResp0 *message,
ProtobufCAllocator *allocator);
/* S2SessionCmd1 methods */
void s2_session_cmd1__init
(S2SessionCmd1 *message);
size_t s2_session_cmd1__get_packed_size
(const S2SessionCmd1 *message);
size_t s2_session_cmd1__pack
(const S2SessionCmd1 *message,
uint8_t *out);
size_t s2_session_cmd1__pack_to_buffer
(const S2SessionCmd1 *message,
ProtobufCBuffer *buffer);
S2SessionCmd1 *
s2_session_cmd1__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void s2_session_cmd1__free_unpacked
(S2SessionCmd1 *message,
ProtobufCAllocator *allocator);
/* S2SessionResp1 methods */
void s2_session_resp1__init
(S2SessionResp1 *message);
size_t s2_session_resp1__get_packed_size
(const S2SessionResp1 *message);
size_t s2_session_resp1__pack
(const S2SessionResp1 *message,
uint8_t *out);
size_t s2_session_resp1__pack_to_buffer
(const S2SessionResp1 *message,
ProtobufCBuffer *buffer);
S2SessionResp1 *
s2_session_resp1__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void s2_session_resp1__free_unpacked
(S2SessionResp1 *message,
ProtobufCAllocator *allocator);
/* Sec2Payload methods */
void sec2_payload__init
(Sec2Payload *message);
size_t sec2_payload__get_packed_size
(const Sec2Payload *message);
size_t sec2_payload__pack
(const Sec2Payload *message,
uint8_t *out);
size_t sec2_payload__pack_to_buffer
(const Sec2Payload *message,
ProtobufCBuffer *buffer);
Sec2Payload *
sec2_payload__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void sec2_payload__free_unpacked
(Sec2Payload *message,
ProtobufCAllocator *allocator);
/* --- per-message closures --- */
typedef void (*S2SessionCmd0_Closure)
(const S2SessionCmd0 *message,
void *closure_data);
typedef void (*S2SessionResp0_Closure)
(const S2SessionResp0 *message,
void *closure_data);
typedef void (*S2SessionCmd1_Closure)
(const S2SessionCmd1 *message,
void *closure_data);
typedef void (*S2SessionResp1_Closure)
(const S2SessionResp1 *message,
void *closure_data);
typedef void (*Sec2Payload_Closure)
(const Sec2Payload *message,
void *closure_data);
/* --- services --- */
/* --- descriptors --- */
extern const ProtobufCEnumDescriptor sec2_msg_type__descriptor;
extern const ProtobufCMessageDescriptor s2_session_cmd0__descriptor;
extern const ProtobufCMessageDescriptor s2_session_resp0__descriptor;
extern const ProtobufCMessageDescriptor s2_session_cmd1__descriptor;
extern const ProtobufCMessageDescriptor s2_session_resp1__descriptor;
extern const ProtobufCMessageDescriptor sec2_payload__descriptor;
PROTOBUF_C__END_DECLS
#endif /* PROTOBUF_C_sec2_2eproto__INCLUDED */

View File

@ -52,7 +52,7 @@ void session_data__free_unpacked
assert(message->base.descriptor == &session_data__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
static const ProtobufCFieldDescriptor session_data__field_descriptors[3] =
static const ProtobufCFieldDescriptor session_data__field_descriptors[4] =
{
{
"sec_ver",
@ -90,17 +90,30 @@ static const ProtobufCFieldDescriptor session_data__field_descriptors[3] =
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"sec2",
12,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(SessionData, proto_case),
offsetof(SessionData, sec2),
&sec2_payload__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned session_data__field_indices_by_name[] = {
1, /* field[1] = sec0 */
2, /* field[2] = sec1 */
3, /* field[3] = sec2 */
0, /* field[0] = sec_ver */
};
static const ProtobufCIntRange session_data__number_ranges[2 + 1] =
{
{ 2, 0 },
{ 10, 1 },
{ 0, 3 }
{ 0, 4 }
};
const ProtobufCMessageDescriptor session_data__descriptor =
{
@ -110,25 +123,27 @@ const ProtobufCMessageDescriptor session_data__descriptor =
"SessionData",
"",
sizeof(SessionData),
3,
4,
session_data__field_descriptors,
session_data__field_indices_by_name,
2, session_data__number_ranges,
(ProtobufCMessageInit) session_data__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCEnumValue sec_scheme_version__enum_values_by_number[2] =
static const ProtobufCEnumValue sec_scheme_version__enum_values_by_number[3] =
{
{ "SecScheme0", "SEC_SCHEME_VERSION__SecScheme0", 0 },
{ "SecScheme1", "SEC_SCHEME_VERSION__SecScheme1", 1 },
{ "SecScheme2", "SEC_SCHEME_VERSION__SecScheme2", 2 },
};
static const ProtobufCIntRange sec_scheme_version__value_ranges[] = {
{0, 0},{0, 2}
{0, 0},{0, 3}
};
static const ProtobufCEnumValueIndex sec_scheme_version__enum_values_by_name[2] =
static const ProtobufCEnumValueIndex sec_scheme_version__enum_values_by_name[3] =
{
{ "SecScheme0", 0 },
{ "SecScheme1", 1 },
{ "SecScheme2", 2 },
};
const ProtobufCEnumDescriptor sec_scheme_version__descriptor =
{
@ -137,9 +152,9 @@ const ProtobufCEnumDescriptor sec_scheme_version__descriptor =
"SecSchemeVersion",
"SecSchemeVersion",
"",
2,
3,
sec_scheme_version__enum_values_by_number,
2,
3,
sec_scheme_version__enum_values_by_name,
1,
sec_scheme_version__value_ranges,

View File

@ -16,6 +16,7 @@ PROTOBUF_C__BEGIN_DECLS
#include "sec0.pb-c.h"
#include "sec1.pb-c.h"
#include "sec2.pb-c.h"
typedef struct SessionData SessionData;
@ -34,7 +35,11 @@ typedef enum _SecSchemeVersion {
/*
*!< Security scheme 1 - Curve25519 + AES-256-CTR
*/
SEC_SCHEME_VERSION__SecScheme1 = 1
SEC_SCHEME_VERSION__SecScheme1 = 1,
/*
*!< Security scheme 2 - SRP6a + AES-256-GCM
*/
SEC_SCHEME_VERSION__SecScheme2 = 2
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(SEC_SCHEME_VERSION)
} SecSchemeVersion;
@ -43,7 +48,8 @@ typedef enum _SecSchemeVersion {
typedef enum {
SESSION_DATA__PROTO__NOT_SET = 0,
SESSION_DATA__PROTO_SEC0 = 10,
SESSION_DATA__PROTO_SEC1 = 11
SESSION_DATA__PROTO_SEC1 = 11,
SESSION_DATA__PROTO_SEC2 = 12
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(SESSION_DATA__PROTO__CASE)
} SessionData__ProtoCase;
@ -68,6 +74,10 @@ struct SessionData
*!< Payload data in case of security 1
*/
Sec1Payload *sec1;
/*
*!< Payload data in case of security 2
*/
Sec2Payload *sec2;
};
};
#define SESSION_DATA__INIT \

View File

@ -8,6 +8,7 @@ set(PY_OUT_PATH "${CMAKE_CURRENT_LIST_DIR}/../python")
set(PROTO_SRCS "constants.proto"
"sec0.proto"
"sec1.proto"
"sec2.proto"
"session.proto")
add_custom_target(c_proto

View File

@ -0,0 +1,48 @@
syntax = "proto3";
import "constants.proto";
/* A message must be of type Cmd0 / Cmd1 / Resp0 / Resp1 */
enum Sec2MsgType {
S2Session_Command0 = 0;
S2Session_Response0 = 1;
S2Session_Command1 = 2;
S2Session_Response1 = 3;
}
// NOTE: Client: Host (shell, Android/iOS) | Device: ESP32-XX
/* Data structure of Session command0 packet */
message S2SessionCmd0 {
bytes client_username = 1;
bytes client_pubkey = 2;
}
/* Data structure of Session response0 packet */
message S2SessionResp0 {
Status status = 1;
bytes device_pubkey = 2;
bytes device_salt = 3;
}
/* Data structure of Session command1 packet */
message S2SessionCmd1 {
bytes client_proof = 1;
}
/* Data structure of Session response1 packet */
message S2SessionResp1 {
Status status = 1;
bytes device_proof = 2;
bytes device_nonce = 3;
}
/* Payload structure of session data */
message Sec2Payload {
Sec2MsgType msg = 1; /*!< Type of message */
oneof payload {
S2SessionCmd0 sc0 = 20; /*!< Payload data interpreted as Cmd0 */
S2SessionResp0 sr0 = 21; /*!< Payload data interpreted as Resp0 */
S2SessionCmd1 sc1 = 22; /*!< Payload data interpreted as Cmd1 */
S2SessionResp1 sr1 = 23; /*!< Payload data interpreted as Resp1 */
}
}

View File

@ -2,12 +2,15 @@ syntax = "proto3";
import "sec0.proto";
import "sec1.proto";
import "sec2.proto";
/* Allowed values for the type of security
* being used in a protocomm session */
enum SecSchemeVersion {
SecScheme0 = 0; /*!< Unsecured - plaintext communication */
SecScheme1 = 1; /*!< Security scheme 1 - Curve25519 + AES-256-CTR*/
SecScheme0 = 0; /*!< Unsecured - plaintext communication */
SecScheme1 = 1; /*!< Security scheme 1 - Curve25519 + AES-256-CTR*/
SecScheme2 = 2; /*!< Security scheme 2 - SRP6a + AES-256-GCM*/
}
/* Data structure exchanged when establishing
@ -17,5 +20,6 @@ message SessionData {
oneof proto {
Sec0Payload sec0 = 10; /*!< Payload data in case of security 0 */
Sec1Payload sec1 = 11; /*!< Payload data in case of security 1 */
Sec2Payload sec2 = 12; /*!< Payload data in case of security 2 */
}
}

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: sec2.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
import constants_pb2 as constants__pb2
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nsec2.proto\x1a\x0f\x63onstants.proto\"?\n\rS2SessionCmd0\x12\x17\n\x0f\x63lient_username\x18\x01 \x01(\x0c\x12\x15\n\rclient_pubkey\x18\x02 \x01(\x0c\"U\n\x0eS2SessionResp0\x12\x17\n\x06status\x18\x01 \x01(\x0e\x32\x07.Status\x12\x15\n\rdevice_pubkey\x18\x02 \x01(\x0c\x12\x13\n\x0b\x64\x65vice_salt\x18\x03 \x01(\x0c\"%\n\rS2SessionCmd1\x12\x14\n\x0c\x63lient_proof\x18\x01 \x01(\x0c\"U\n\x0eS2SessionResp1\x12\x17\n\x06status\x18\x01 \x01(\x0e\x32\x07.Status\x12\x14\n\x0c\x64\x65vice_proof\x18\x02 \x01(\x0c\x12\x14\n\x0c\x64\x65vice_nonce\x18\x03 \x01(\x0c\"\xb1\x01\n\x0bSec2Payload\x12\x19\n\x03msg\x18\x01 \x01(\x0e\x32\x0c.Sec2MsgType\x12\x1d\n\x03sc0\x18\x14 \x01(\x0b\x32\x0e.S2SessionCmd0H\x00\x12\x1e\n\x03sr0\x18\x15 \x01(\x0b\x32\x0f.S2SessionResp0H\x00\x12\x1d\n\x03sc1\x18\x16 \x01(\x0b\x32\x0e.S2SessionCmd1H\x00\x12\x1e\n\x03sr1\x18\x17 \x01(\x0b\x32\x0f.S2SessionResp1H\x00\x42\t\n\x07payload*o\n\x0bSec2MsgType\x12\x16\n\x12S2Session_Command0\x10\x00\x12\x17\n\x13S2Session_Response0\x10\x01\x12\x16\n\x12S2Session_Command1\x10\x02\x12\x17\n\x13S2Session_Response1\x10\x03\x62\x06proto3')
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'sec2_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:
DESCRIPTOR._options = None
_SEC2MSGTYPE._serialized_start=489
_SEC2MSGTYPE._serialized_end=600
_S2SESSIONCMD0._serialized_start=31
_S2SESSIONCMD0._serialized_end=94
_S2SESSIONRESP0._serialized_start=96
_S2SESSIONRESP0._serialized_end=181
_S2SESSIONCMD1._serialized_start=183
_S2SESSIONCMD1._serialized_end=220
_S2SESSIONRESP1._serialized_start=222
_S2SESSIONRESP1._serialized_end=307
_SEC2PAYLOAD._serialized_start=310
_SEC2PAYLOAD._serialized_end=487
# @@protoc_insertion_point(module_scope)

View File

@ -13,17 +13,18 @@ _sym_db = _symbol_database.Default()
import sec0_pb2 as sec0__pb2
import sec1_pb2 as sec1__pb2
import sec2_pb2 as sec2__pb2
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\rsession.proto\x1a\nsec0.proto\x1a\nsec1.proto\"v\n\x0bSessionData\x12\"\n\x07sec_ver\x18\x02 \x01(\x0e\x32\x11.SecSchemeVersion\x12\x1c\n\x04sec0\x18\n \x01(\x0b\x32\x0c.Sec0PayloadH\x00\x12\x1c\n\x04sec1\x18\x0b \x01(\x0b\x32\x0c.Sec1PayloadH\x00\x42\x07\n\x05proto*2\n\x10SecSchemeVersion\x12\x0e\n\nSecScheme0\x10\x00\x12\x0e\n\nSecScheme1\x10\x01\x62\x06proto3')
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\rsession.proto\x1a\nsec0.proto\x1a\nsec1.proto\x1a\nsec2.proto\"\x94\x01\n\x0bSessionData\x12\"\n\x07sec_ver\x18\x02 \x01(\x0e\x32\x11.SecSchemeVersion\x12\x1c\n\x04sec0\x18\n \x01(\x0b\x32\x0c.Sec0PayloadH\x00\x12\x1c\n\x04sec1\x18\x0b \x01(\x0b\x32\x0c.Sec1PayloadH\x00\x12\x1c\n\x04sec2\x18\x0c \x01(\x0b\x32\x0c.Sec2PayloadH\x00\x42\x07\n\x05proto*B\n\x10SecSchemeVersion\x12\x0e\n\nSecScheme0\x10\x00\x12\x0e\n\nSecScheme1\x10\x01\x12\x0e\n\nSecScheme2\x10\x02\x62\x06proto3')
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'session_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:
DESCRIPTOR._options = None
_SECSCHEMEVERSION._serialized_start=161
_SECSCHEMEVERSION._serialized_end=211
_SESSIONDATA._serialized_start=41
_SESSIONDATA._serialized_end=159
_SECSCHEMEVERSION._serialized_start=204
_SECSCHEMEVERSION._serialized_end=270
_SESSIONDATA._serialized_start=54
_SESSIONDATA._serialized_end=202
# @@protoc_insertion_point(module_scope)

View File

@ -1084,11 +1084,14 @@ components/protocomm/proto-c/sec0.pb-c.c
components/protocomm/proto-c/sec0.pb-c.h
components/protocomm/proto-c/sec1.pb-c.c
components/protocomm/proto-c/sec1.pb-c.h
components/protocomm/proto-c/sec2.pb-c.c
components/protocomm/proto-c/sec2.pb-c.h
components/protocomm/proto-c/session.pb-c.c
components/protocomm/proto-c/session.pb-c.h
components/protocomm/python/constants_pb2.py
components/protocomm/python/sec0_pb2.py
components/protocomm/python/sec1_pb2.py
components/protocomm/python/sec2_pb2.py
components/protocomm/python/session_pb2.py
components/protocomm/src/common/protocomm_priv.h
components/protocomm/src/security/security0.c