source: UsbWattMeter/trunk/wolfssl-3.7.0/wolfssl/openssl/ec.h@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 6 years ago

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr
File size: 6.0 KB
Line 
1/* ec.h for openssl */
2
3#ifndef WOLFSSL_EC_H_
4#define WOLFSSL_EC_H_
5
6#include <wolfssl/openssl/ssl.h>
7#include <wolfssl/openssl/bn.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/* Map OpenSSL NID value */
14enum {
15 POINT_CONVERSION_UNCOMPRESSED = 4,
16 NID_secp111r1 = 0,
17 NID_secp128r1 = 1,
18 NID_secp160r1 = 2,
19 NID_cert192 = 3,
20 NID_cert224 = 4,
21 NID_X9_62_prime256v1 = 5,
22 NID_secp384r1 = 6,
23 NID_secp521r1 = 7,
24 NID_X9_62_prime_field = 100,
25 OPENSSL_EC_NAMED_CURVE = 0x001
26};
27
28struct WOLFSSL_EC_POINT {
29 WOLFSSL_BIGNUM *X;
30 WOLFSSL_BIGNUM *Y;
31 WOLFSSL_BIGNUM *Z;
32
33 void* internal; /* our ECC point */
34 char inSet; /* internal set from external ? */
35 char exSet; /* external set from internal ? */
36};
37
38struct WOLFSSL_EC_GROUP {
39 int curve_idx; /* index of curve, used by WolfSSL as reference */
40 int curve_nid; /* NID of curve, used by OpenSSL/OpenSSH as reference */
41};
42
43struct WOLFSSL_EC_KEY {
44 WOLFSSL_EC_GROUP *group;
45 WOLFSSL_EC_POINT *pub_key;
46 WOLFSSL_BIGNUM *priv_key;
47
48 void* internal; /* our ECC Key */
49 char inSet; /* internal set from external ? */
50 char exSet; /* external set from internal ? */
51};
52
53WOLFSSL_API
54int wolfSSL_ECPoint_i2d(const WOLFSSL_EC_GROUP *curve,
55 const WOLFSSL_EC_POINT *p,
56 unsigned char *out, unsigned int *len);
57WOLFSSL_API
58int wolfSSL_ECPoint_d2i(unsigned char *in, unsigned int len,
59 const WOLFSSL_EC_GROUP *curve, WOLFSSL_EC_POINT *p);
60WOLFSSL_API
61int wolfSSL_EC_KEY_LoadDer(WOLFSSL_EC_KEY* key,
62 const unsigned char* der, int derSz);
63WOLFSSL_API
64void wolfSSL_EC_KEY_free(WOLFSSL_EC_KEY *key);
65WOLFSSL_API
66WOLFSSL_EC_POINT *wolfSSL_EC_KEY_get0_public_key(const WOLFSSL_EC_KEY *key);
67WOLFSSL_API
68const WOLFSSL_EC_GROUP *wolfSSL_EC_KEY_get0_group(const WOLFSSL_EC_KEY *key);
69WOLFSSL_API
70int wolfSSL_EC_KEY_set_private_key(WOLFSSL_EC_KEY *key,
71 const WOLFSSL_BIGNUM *priv_key);
72WOLFSSL_API
73WOLFSSL_BIGNUM *wolfSSL_EC_KEY_get0_private_key(const WOLFSSL_EC_KEY *key);
74WOLFSSL_API
75WOLFSSL_EC_KEY *wolfSSL_EC_KEY_new_by_curve_name(int nid);
76WOLFSSL_API
77WOLFSSL_EC_KEY *wolfSSL_EC_KEY_new(void);
78WOLFSSL_API
79int wolfSSL_EC_KEY_set_group(WOLFSSL_EC_KEY *key, WOLFSSL_EC_GROUP *group);
80WOLFSSL_API
81int wolfSSL_EC_KEY_generate_key(WOLFSSL_EC_KEY *key);
82WOLFSSL_API
83void wolfSSL_EC_KEY_set_asn1_flag(WOLFSSL_EC_KEY *key, int asn1_flag);
84WOLFSSL_API
85int wolfSSL_EC_KEY_set_public_key(WOLFSSL_EC_KEY *key,
86 const WOLFSSL_EC_POINT *pub);
87WOLFSSL_API
88void wolfSSL_EC_GROUP_set_asn1_flag(WOLFSSL_EC_GROUP *group, int flag);
89WOLFSSL_API
90WOLFSSL_EC_GROUP *wolfSSL_EC_GROUP_new_by_curve_name(int nid);
91WOLFSSL_API
92int wolfSSL_EC_GROUP_cmp(const WOLFSSL_EC_GROUP *a, const WOLFSSL_EC_GROUP *b,
93 WOLFSSL_BN_CTX *ctx);
94WOLFSSL_API
95int wolfSSL_EC_GROUP_get_curve_name(const WOLFSSL_EC_GROUP *group);
96WOLFSSL_API
97int wolfSSL_EC_GROUP_get_degree(const WOLFSSL_EC_GROUP *group);
98WOLFSSL_API
99int wolfSSL_EC_GROUP_get_order(const WOLFSSL_EC_GROUP *group,
100 WOLFSSL_BIGNUM *order, WOLFSSL_BN_CTX *ctx);
101WOLFSSL_API
102void wolfSSL_EC_GROUP_free(WOLFSSL_EC_GROUP *group);
103#if defined(DEBUG_WOLFSSL) && !defined(NO_FILESYSTEM)
104WOLFSSL_API
105void wolfssl_EC_POINT_dump(const char *msg, const WOLFSSL_EC_POINT *p);
106#endif
107WOLFSSL_API
108WOLFSSL_EC_POINT *wolfSSL_EC_POINT_new(const WOLFSSL_EC_GROUP *group);
109WOLFSSL_API
110int wolfSSL_EC_POINT_get_affine_coordinates_GFp(const WOLFSSL_EC_GROUP *group,
111 const WOLFSSL_EC_POINT *p,
112 WOLFSSL_BIGNUM *x,
113 WOLFSSL_BIGNUM *y,
114 WOLFSSL_BN_CTX *ctx);
115WOLFSSL_API
116int wolfSSL_EC_POINT_mul(const WOLFSSL_EC_GROUP *group, WOLFSSL_EC_POINT *r,
117 const WOLFSSL_BIGNUM *n,
118 const WOLFSSL_EC_POINT *q, const WOLFSSL_BIGNUM *m,
119 WOLFSSL_BN_CTX *ctx);
120WOLFSSL_API
121void wolfSSL_EC_POINT_clear_free(WOLFSSL_EC_POINT *point);
122WOLFSSL_API
123int wolfSSL_EC_POINT_cmp(const WOLFSSL_EC_GROUP *group,
124 const WOLFSSL_EC_POINT *a, const WOLFSSL_EC_POINT *b,
125 WOLFSSL_BN_CTX *ctx);
126WOLFSSL_API
127void wolfSSL_EC_POINT_free(WOLFSSL_EC_POINT *point);
128WOLFSSL_API
129int wolfSSL_EC_POINT_is_at_infinity(const WOLFSSL_EC_GROUP *group,
130 const WOLFSSL_EC_POINT *a);
131
132#define EC_KEY_free wolfSSL_EC_KEY_free
133#define EC_KEY_get0_public_key wolfSSL_EC_KEY_get0_public_key
134#define EC_KEY_get0_group wolfSSL_EC_KEY_get0_group
135#define EC_KEY_set_private_key wolfSSL_EC_KEY_set_private_key
136#define EC_KEY_get0_private_key wolfSSL_EC_KEY_get0_private_key
137#define EC_KEY_new_by_curve_name wolfSSL_EC_KEY_new_by_curve_name
138#define EC_KEY_set_group wolfSSL_EC_KEY_set_group
139#define EC_KEY_generate_key wolfSSL_EC_KEY_generate_key
140#define EC_KEY_set_asn1_flag wolfSSL_EC_KEY_set_asn1_flag
141#define EC_KEY_set_public_key wolfSSL_EC_KEY_set_public_key
142#define EC_KEY_new wolfSSL_EC_KEY_new
143
144#define EC_GROUP_set_asn1_flag wolfSSL_EC_GROUP_set_asn1_flag
145#define EC_GROUP_new_by_curve_name wolfSSL_EC_GROUP_new_by_curve_name
146#define EC_GROUP_cmp wolfSSL_EC_GROUP_cmp
147#define EC_GROUP_get_curve_name wolfSSL_EC_GROUP_get_curve_name
148#define EC_GROUP_get_degree wolfSSL_EC_GROUP_get_degree
149#define EC_GROUP_get_order wolfSSL_EC_GROUP_get_order
150#define EC_GROUP_free wolfSSL_EC_GROUP_free
151
152#define EC_POINT_new wolfSSL_EC_POINT_new
153#define EC_POINT_get_affine_coordinates_GFp \
154 wolfSSL_EC_POINT_get_affine_coordinates_GFp
155#define EC_POINT_mul wolfSSL_EC_POINT_mul
156#define EC_POINT_clear_free wolfSSL_EC_POINT_clear_free
157#define EC_POINT_cmp wolfSSL_EC_POINT_cmp
158#define EC_POINT_free wolfSSL_EC_POINT_free
159#define EC_POINT_is_at_infinity wolfSSL_EC_POINT_is_at_infinity
160
161#ifdef __cplusplus
162} /* extern "C" */
163#endif
164
165#endif /* header */
Note: See TracBrowser for help on using the repository browser.