source: UsbWattMeter/trunk/wolfssl-3.7.0/wolfssl/wolfcrypt/curve25519.h@ 167

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

MIMEにSJISを設定

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr; charset=SHIFT_JIS
File size: 4.7 KB
RevLine 
[164]1/* curve25519.h
2 *
3 * Copyright (C) 2006-2015 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL. (formerly known as CyaSSL)
6 *
7 * wolfSSL is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * wolfSSL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#ifndef WOLF_CRYPT_CURVE25519_H
23#define WOLF_CRYPT_CURVE25519_H
24
25#include <wolfssl/wolfcrypt/types.h>
26
27#ifdef HAVE_CURVE25519
28
29#include <wolfssl/wolfcrypt/fe_operations.h>
30#include <wolfssl/wolfcrypt/random.h>
31
32#ifdef __cplusplus
33 extern "C" {
34#endif
35
36#define CURVE25519_KEYSIZE 32
37
38/* curve25519 set type */
39typedef struct {
40 int size; /* The size of the curve in octets */
41 const char* name; /* name of this curve */
42} curve25519_set_type;
43
44
45/* ECC point, the internal structure is Little endian
46 * the mathematical functions used the endianess */
47typedef struct {
48 byte point[CURVE25519_KEYSIZE];
49}ECPoint;
50
51/* A CURVE25519 Key */
52typedef struct {
53 int idx; /* Index into the ecc_sets[] for the parameters of
54 this curve if -1, this key is using user supplied
55 curve in dp */
56 const curve25519_set_type* dp; /* domain parameters, either points to
57 curves (idx >= 0) or user supplied */
58 ECPoint p; /* public key */
59 ECPoint k; /* private key */
60} curve25519_key;
61
62enum {
63 EC25519_LITTLE_ENDIAN=0,
64 EC25519_BIG_ENDIAN=1
65};
66
67WOLFSSL_API
68int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key);
69
70WOLFSSL_API
71int wc_curve25519_shared_secret(curve25519_key* private_key,
72 curve25519_key* public_key,
73 byte* out, word32* outlen);
74
75WOLFSSL_API
76int wc_curve25519_shared_secret_ex(curve25519_key* private_key,
77 curve25519_key* public_key,
78 byte* out, word32* outlen, int endian);
79
80WOLFSSL_API
81int wc_curve25519_init(curve25519_key* key);
82
83WOLFSSL_API
84void wc_curve25519_free(curve25519_key* key);
85
86
87/* raw key helpers */
88WOLFSSL_API
89int wc_curve25519_import_private(const byte* priv, word32 privSz,
90 curve25519_key* key);
91WOLFSSL_API
92int wc_curve25519_import_private_ex(const byte* priv, word32 privSz,
93 curve25519_key* key, int endian);
94
95WOLFSSL_API
96int wc_curve25519_import_private_raw(const byte* priv, word32 privSz,
97 const byte* pub, word32 pubSz, curve25519_key* key);
98WOLFSSL_API
99int wc_curve25519_import_private_raw_ex(const byte* priv, word32 privSz,
100 const byte* pub, word32 pubSz,
101 curve25519_key* key, int endian);
102WOLFSSL_API
103int wc_curve25519_export_private_raw(curve25519_key* key, byte* out,
104 word32* outLen);
105WOLFSSL_API
106int wc_curve25519_export_private_raw_ex(curve25519_key* key, byte* out,
107 word32* outLen, int endian);
108
109WOLFSSL_API
110int wc_curve25519_import_public(const byte* in, word32 inLen,
111 curve25519_key* key);
112WOLFSSL_API
113int wc_curve25519_import_public_ex(const byte* in, word32 inLen,
114 curve25519_key* key, int endian);
115
116WOLFSSL_API
117int wc_curve25519_export_public(curve25519_key* key, byte* out, word32* outLen);
118WOLFSSL_API
119int wc_curve25519_export_public_ex(curve25519_key* key, byte* out,
120 word32* outLen, int endian);
121
122WOLFSSL_API
123int wc_curve25519_export_key_raw(curve25519_key* key,
124 byte* priv, word32 *privSz,
125 byte* pub, word32 *pubSz);
126WOLFSSL_API
127int wc_curve25519_export_key_raw_ex(curve25519_key* key,
128 byte* priv, word32 *privSz,
129 byte* pub, word32 *pubSz,
130 int endian);
131/* size helper */
132WOLFSSL_API
133int wc_curve25519_size(curve25519_key* key);
134
135#ifdef __cplusplus
136 } /* extern "C" */
137#endif
138
139#endif /* HAVE_CURVE25519 */
140#endif /* WOLF_CRYPT_CURVE25519_H */
141
Note: See TracBrowser for help on using the repository browser.