source: asp3_tinet_ecnl_rx/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/ed25519.h@ 337

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

ASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 4.0 KB
Line 
1/* ed25519.h
2 *
3 * Copyright (C) 2006-2017 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL.
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-1335, USA
20 */
21
22
23#ifndef WOLF_CRYPT_ED25519_H
24#define WOLF_CRYPT_ED25519_H
25
26#include <wolfssl/wolfcrypt/types.h>
27
28#ifdef HAVE_ED25519
29
30#include <wolfssl/wolfcrypt/fe_operations.h>
31#include <wolfssl/wolfcrypt/ge_operations.h>
32#include <wolfssl/wolfcrypt/random.h>
33#include <wolfssl/wolfcrypt/sha512.h>
34
35#ifdef WOLFSSL_ASYNC_CRYPT
36 #include <wolfssl/wolfcrypt/async.h>
37#endif
38
39#ifdef __cplusplus
40 extern "C" {
41#endif
42
43
44/* info about EdDSA curve specifically ed25519, defined as an elliptic curve
45 over GF(p) */
46/*
47 32, key size
48 "ED25519", curve name
49 "2^255-19", prime number
50 "SHA512", hash function
51 "-121665/121666", value of d
52*/
53
54#define ED25519_KEY_SIZE 32 /* private key only */
55#define ED25519_SIG_SIZE 64
56
57#define ED25519_PUB_KEY_SIZE 32 /* compressed */
58/* both private and public key */
59#define ED25519_PRV_KEY_SIZE (ED25519_PUB_KEY_SIZE+ED25519_KEY_SIZE)
60
61
62#ifndef WC_ED25519KEY_TYPE_DEFINED
63 typedef struct ed25519_key ed25519_key;
64 #define WC_ED25519KEY_TYPE_DEFINED
65#endif
66
67/* An ED25519 Key */
68struct ed25519_key {
69 byte p[ED25519_PUB_KEY_SIZE]; /* compressed public key */
70 byte k[ED25519_PRV_KEY_SIZE]; /* private key : 32 secret -- 32 public */
71#ifdef FREESCALE_LTC_ECC
72 /* uncompressed point coordinates */
73 byte pointX[ED25519_KEY_SIZE]; /* recovered X coordinate */
74 byte pointY[ED25519_KEY_SIZE]; /* Y coordinate is the public key with The most significant bit of the final octet always zero. */
75#endif
76#ifdef WOLFSSL_ASYNC_CRYPT
77 WC_ASYNC_DEV asyncDev;
78#endif
79};
80
81
82WOLFSSL_API
83int wc_ed25519_make_key(WC_RNG* rng, int keysize, ed25519_key* key);
84WOLFSSL_API
85int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out,
86 word32 *outlen, ed25519_key* key);
87WOLFSSL_API
88int wc_ed25519_verify_msg(const byte* sig, word32 siglen, const byte* msg,
89 word32 msglen, int* stat, ed25519_key* key);
90WOLFSSL_API
91int wc_ed25519_init(ed25519_key* key);
92WOLFSSL_API
93void wc_ed25519_free(ed25519_key* key);
94WOLFSSL_API
95int wc_ed25519_import_public(const byte* in, word32 inLen, ed25519_key* key);
96WOLFSSL_API
97int wc_ed25519_import_private_only(const byte* priv, word32 privSz,
98 ed25519_key* key);
99WOLFSSL_API
100int wc_ed25519_import_private_key(const byte* priv, word32 privSz,
101 const byte* pub, word32 pubSz, ed25519_key* key);
102WOLFSSL_API
103int wc_ed25519_export_public(ed25519_key*, byte* out, word32* outLen);
104WOLFSSL_API
105int wc_ed25519_export_private_only(ed25519_key* key, byte* out, word32* outLen);
106WOLFSSL_API
107int wc_ed25519_export_private(ed25519_key* key, byte* out, word32* outLen);
108WOLFSSL_API
109int wc_ed25519_export_key(ed25519_key* key,
110 byte* priv, word32 *privSz,
111 byte* pub, word32 *pubSz);
112
113int wc_ed25519_check_key(ed25519_key* key);
114
115/* size helper */
116WOLFSSL_API
117int wc_ed25519_size(ed25519_key* key);
118WOLFSSL_API
119int wc_ed25519_priv_size(ed25519_key* key);
120WOLFSSL_API
121int wc_ed25519_pub_size(ed25519_key* key);
122WOLFSSL_API
123int wc_ed25519_sig_size(ed25519_key* key);
124
125#ifdef __cplusplus
126 } /* extern "C" */
127#endif
128
129#endif /* HAVE_ED25519 */
130#endif /* WOLF_CRYPT_ED25519_H */
131
Note: See TracBrowser for help on using the repository browser.