OlinCoin
Test
ser_key.h
1#pragma once
2
3#include "mbedtls/ecdsa.h"
4
5/******************************************************************************
6 * Pub Keys
7 ******************************************************************************/
8
9#define PUB_KEY_SER_LEN 65
10
18ssize_t ser_pub_key(unsigned char *dest, mbedtls_ecp_point *key);
19
28unsigned char *ser_pub_key_alloc(ssize_t *written, mbedtls_ecp_point *key);
29
37ssize_t deser_pub_key(mbedtls_ecp_point *dest, unsigned char *src);
38
46mbedtls_ecp_point *deser_pub_key_alloc(ssize_t *read, unsigned char *src);
47
48/******************************************************************************
49 * Private Keys
50 ******************************************************************************/
51
52#define PRIV_KEY_SER_LEN 32
53
61ssize_t ser_priv_key(unsigned char *dest, mbedtls_mpi *key);
62
71unsigned char *ser_priv_key_alloc(ssize_t *written, mbedtls_mpi *key);
72
80ssize_t deser_priv_key(mbedtls_mpi *dest, unsigned char *src);
81
89mbedtls_mpi *deser_priv_key_alloc(ssize_t *read, unsigned char *src);
90
91/******************************************************************************
92 * Key Pairs
93 ******************************************************************************/
94
95#define KEYPAIR_SER_LEN PUB_KEY_SER_LEN + PRIV_KEY_SER_LEN
96
104ssize_t ser_keypair(unsigned char *dest, mbedtls_ecdsa_context *keypair);
105
114unsigned char *ser_keypair_alloc(ssize_t *written, mbedtls_ecdsa_context *keypair);
115
123ssize_t deser_keypair(mbedtls_ecdsa_context *dest, unsigned char *src);
124
132mbedtls_ecdsa_context *deser_keypair_alloc(ssize_t *read, unsigned char *src);