Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*********************************************************************
######################################################################
##
## Created by: Denis Filatov
##
## Copyleft (c) 2015
## This code is provided under the CeCill-C license agreement.
######################################################################
*********************************************************************/
#ifndef ecc_api_h
#define ecc_api_h
#ifdef __cplusplus
extern "C" {
#endif
int ecc_api_init();
int ecc_api_done();
typedef enum {
ecies_nistp256,
ecies_brainpoolp256r,
ecies_brainpoolp384r,
}ecc_curve_id;
typedef enum {
sha_256,
sha_384
}ecc_hash_id;
typedef enum {
aes_128_ccm
}ecc_sym_algorithm;
typedef enum {
ecc_bin,
ecc_hex,
ecc_pem
}ecc_format;
typedef enum {
ecc_x_only = 0,
ecc_compressed_y0 = 2,
ecc_compressed_y1 = 3,
ecc_uncompressed = 4
}ecc_point_type;
void * ecc_key_gen(ecc_curve_id pk_alg);
void * ecc_key_init(ecc_curve_id pk_alg, const char* pkey);
void ecc_key_free(void*);
int ecc_key_private(void*, char* buf);
int ecc_key_public(void*, char* x, char* y, int * psign);
int ecc_key_private_save(void*, const char* path, ecc_format format);
void * ecc_key_private_load(const char* path, ecc_curve_id pk_alg);
int ecc_key_public_save(void*, const char* path, ecc_format format);
void * ecc_key_public_load(const char* path, ecc_curve_id pk_alg);
void * ecc_key_public_set(ecc_curve_id pk_alg, ecc_point_type ptype, const char * px, const char * py);
#define sha256_hash_size 32
#define sha384_hash_size 48
int sha256_calculate(char* hash, const char * ptr, int len);
int sha384_calculate(char* hash, const char * ptr, int len);
int ecc_sign(void * key, const char * hash, int hlength, char *r, char *s);
#ifdef __cplusplus
}
#endif
#endif