2017-02-01 17:14:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
struct Exchange {
|
|
|
|
unsigned char* epubkey;
|
|
|
|
size_t epubkey_size;
|
|
|
|
unsigned char* signature;
|
|
|
|
size_t signature_size;
|
|
|
|
};
|
|
|
|
|
2017-02-06 22:11:22 +00:00
|
|
|
struct Exchange* libp2p_secio_exchange_new();
|
2017-02-09 09:55:16 +00:00
|
|
|
void libp2p_secio_exchange_free(struct Exchange* in);
|
2017-02-06 22:11:22 +00:00
|
|
|
|
2017-02-01 17:14:52 +00:00
|
|
|
/**
|
|
|
|
* retrieves the approximate size of an encoded version of the passed in struct
|
|
|
|
* @param in the struct to look at
|
|
|
|
* @reutrns the size of buffer needed
|
|
|
|
*/
|
|
|
|
size_t libp2p_secio_exchange_protobuf_encode_size(struct Exchange* in);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Encode the struct Exchange in protobuf format
|
|
|
|
* @param in the struct to be encoded
|
|
|
|
* @param buffer where to put the results
|
|
|
|
* @param max_buffer_length the max to write
|
|
|
|
* @param bytes_written how many bytes were written to the buffer
|
|
|
|
* @returns true(1) on success, otherwise false(0)
|
|
|
|
*/
|
|
|
|
int libp2p_secio_exchange_protobuf_encode(struct Exchange* in, unsigned char* buffer, size_t max_buffer_length, size_t* bytes_written);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Turns a protobuf array into an Exchange struct
|
|
|
|
* @param buffer the protobuf array
|
|
|
|
* @param max_buffer_length the length of the buffer
|
|
|
|
* @param out a pointer to the new struct Exchange NOTE: this method allocates memory
|
|
|
|
* @returns true(1) on success, otherwise false(0)
|
|
|
|
*/
|
|
|
|
int libp2p_secio_exchange_protobuf_decode(unsigned char* buffer, size_t max_buffer_length, struct Exchange** out);
|