1 #define _POSIX_C_SOURCE 200809L 8 static const uint16_t version = 1;
10 #define SERIALIZE_VARIABLE(dst, x) \ 11 do { memcpy((dst), &x, sizeof x); (dst) += sizeof x; } while(0) 12 #define SERIALIZE_BYTES(dst, bs) \ 14 bytes_t *__b = (bs); \ 15 uint32_t __net_len = htonl(__b->data_len); \ 16 SERIALIZE_VARIABLE((dst), __net_len); \ 17 memcpy((dst), __b->data, __b->data_len); \ 18 (dst) += __b->data_len; \ 27 uint16_t net_version = htons(version);
28 uint16_t net_id = htons(ks->
id);
31 size_t buffer_size =
sizeof(net_version) +
sizeof(net_id) +
sizeof(ks->
n->
data_len) +
33 uint8_t *buffer = malloc(buffer_size);
43 bytes_t bs = {buffer, (uint32_t) buffer_size};
52 uint16_t net_version = htons(version);
53 uint16_t net_id = htons(ss->
id);
55 size_t buffer_size =
sizeof(net_version) +
sizeof(net_id) +
sizeof(ss->
x_i->
data_len) +
58 uint8_t *buffer = malloc(buffer_size);
67 bytes_t bs = {buffer, (uint32_t) buffer_size};
76 uint8_t *buffer = malloc(buffer_size);
87 size_t buffer_size = 0;
89 uint16_t net_version = htons(version);
90 buffer_size +=
sizeof net_version;
96 uint16_t net_k = htons(kmi->
k);
97 buffer_size +=
sizeof net_k;
99 uint16_t net_l = htons(kmi->
l);
100 buffer_size +=
sizeof net_l;
105 buffer_size +=
sizeof vk_v->
data_len;
108 buffer_size +=
sizeof vk_u->
data_len;
112 for (
int i = 0; i < kmi->
l; i++) {
117 uint8_t *buffer = malloc(buffer_size);
126 for (
int i = 0; i < kmi->
l; i++) {
131 bytes_t bs = {buffer, buffer_size};
139 #define DESERIALIZE_SHORT(dst, buf) \ 141 memcpy(&dst, buf, sizeof dst); \ 143 (buf) += sizeof dst; \ 146 #define DESERIALIZE_BYTES(dst, buf) \ 148 bytes_t * __b = (dst); \ 150 memcpy(&len, (buf), sizeof(len)); \ 152 (buf) += sizeof(len); \ 153 __b->data = alloc(len); \ 154 __b->data_len = len; \ 155 memcpy(__b->data, (buf), len); \ 161 uint8_t *p = buffer->
data;
163 uint16_t message_version;
166 if (message_version != version) {
167 fprintf(stderr,
"KeyShare, Version mismatch: (Message=%x) != (Library=%x)\n", message_version, version);
185 uint8_t *p = buffer->
data;
188 uint16_t message_version;
191 if (message_version != version) {
192 fprintf(stderr,
"SignatureShare, Version mismatch: (Message=%d) != (Library=%d)\n", message_version, version);
210 uint8_t *p = buffer->
data;
212 uint16_t message_version;
215 if (message_version != version) {
216 fprintf(stderr,
"KeyMetaInfo, Version mismatch: (Message=%d) != (Library=%d)\n", message_version, version);
234 for (
int i = 0; i < l; i++) {
void tc_clear_bytes(bytes_t *bytes)
char * tc_bytes_b64(const bytes_t *b)
#define DESERIALIZE_SHORT(dst, buf)
Structure that's stores a pointer that points to data_len bytes.
Structure that represents a signature share, to be joined generating a standard RSA signatures...
key_share_t * tc_init_key_share()
char * tc_serialize_signature_share(const signature_share_t *ss)
signature_share_t * tc_init_signature_share()
signature_share_t * tc_deserialize_signature_share(const char *b64)
char * tc_serialize_key_metainfo(const key_metainfo_t *kmi)
Structure that represents a standard RSA public key. Used to verify signatures.
#define DESERIALIZE_BYTES(dst, buf)
char * tc_serialize_key_share(const key_share_t *ks)
key_metainfo_t * tc_init_key_metainfo(uint16_t k, uint16_t l)
key_metainfo_t * tc_deserialize_key_metainfo(const char *b64)
key_share_t * tc_deserialize_key_share(const char *b64)
Structure that represents one key share, to be used to generate a signature share.
#define SERIALIZE_VARIABLE(dst, x)
#define SERIALIZE_BYTES(dst, bs)
bytes_t * tc_init_bytes(void *bs, size_t len)
bytes_t * tc_b64_bytes(const char *b64)