libtc  20160415
Threshold Cryptography functions library
Macros | Functions
structs_serialization.c File Reference
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <arpa/inet.h>
#include "tc_internal.h"

Go to the source code of this file.

Macros

#define _POSIX_C_SOURCE   200809L
 
#define SERIALIZE_VARIABLE(dst, x)   do { memcpy((dst), &x, sizeof x); (dst) += sizeof x; } while(0)
 
#define SERIALIZE_BYTES(dst, bs)
 
#define DESERIALIZE_SHORT(dst, buf)
 
#define DESERIALIZE_BYTES(dst, buf)
 

Functions

char * tc_serialize_key_share (const key_share_t *ks)
 
char * tc_serialize_signature_share (const signature_share_t *ss)
 
char * tc_serialize_key_metainfo (const key_metainfo_t *kmi)
 
key_share_ttc_deserialize_key_share (const char *b64)
 
signature_share_ttc_deserialize_signature_share (const char *b64)
 
key_metainfo_ttc_deserialize_key_metainfo (const char *b64)
 

Macro Definition Documentation

#define _POSIX_C_SOURCE   200809L

Definition at line 1 of file structs_serialization.c.

#define DESERIALIZE_BYTES (   dst,
  buf 
)
Value:
do { \
bytes_t * __b = (dst); \
uint32_t len; \
memcpy(&len, (buf), sizeof(len)); \
len = ntohl(len); \
(buf) += sizeof(len); \
__b->data = alloc(len); \
__b->data_len = len; \
memcpy(__b->data, (buf), len); \
(buf) += len; \
} while(0)
void * alloc(size_t size)
Definition: structs_init.c:9

Definition at line 146 of file structs_serialization.c.

#define DESERIALIZE_SHORT (   dst,
  buf 
)
Value:
do { \
memcpy(&dst, buf, sizeof dst); \
dst = ntohs(dst); \
(buf) += sizeof dst; \
} while (0)

Definition at line 139 of file structs_serialization.c.

#define SERIALIZE_BYTES (   dst,
  bs 
)
Value:
do { \
bytes_t *__b = (bs); \
uint32_t __net_len = htonl(__b->data_len); \
SERIALIZE_VARIABLE((dst), __net_len); \
memcpy((dst), __b->data, __b->data_len); \
(dst) += __b->data_len; \
} while(0)

Definition at line 12 of file structs_serialization.c.

#define SERIALIZE_VARIABLE (   dst,
 
)    do { memcpy((dst), &x, sizeof x); (dst) += sizeof x; } while(0)

Definition at line 10 of file structs_serialization.c.

Function Documentation

key_metainfo_t* tc_deserialize_key_metainfo ( const char *  b64)

Deserializes a key share from a C string in the Base64 format

Definition at line 208 of file structs_serialization.c.

key_share_t* tc_deserialize_key_share ( const char *  b64)

Deserializes a key share from a C string in the Base64 format

Definition at line 159 of file structs_serialization.c.

signature_share_t* tc_deserialize_signature_share ( const char *  b64)

Deserializes a signature share from a C string in the Base64 format

Definition at line 183 of file structs_serialization.c.

char* tc_serialize_key_metainfo ( const key_metainfo_t kmi)

Serializes a key shares array metainfo as a C string in the Base64 format

Definition at line 86 of file structs_serialization.c.

char* tc_serialize_key_share ( const key_share_t ks)

Serializes a key share as a C string in the Base64 format

Definition at line 21 of file structs_serialization.c.

char* tc_serialize_signature_share ( const signature_share_t ss)

Serializes a signature share as a C string in the Base64 format

Definition at line 51 of file structs_serialization.c.