source: UsbWattMeter/trunk/wolfssl-3.7.0/wolfssl/wolfcrypt/ed25519.h@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 8 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: 3.3 KB
Line 
1/* ed25519.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_ED25519_H
23#define WOLF_CRYPT_ED25519_H
24
25#include <wolfssl/wolfcrypt/types.h>
26
27#ifdef HAVE_ED25519
28
29#include <wolfssl/wolfcrypt/fe_operations.h>
30#include <wolfssl/wolfcrypt/ge_operations.h>
31#include <wolfssl/wolfcrypt/random.h>
32#include <wolfssl/wolfcrypt/sha512.h>
33
34#ifdef __cplusplus
35 extern "C" {
36#endif
37
38
39/* info about EdDSA curve specifically ed25519, defined as an elliptic curve
40 over GF(p) */
41/*
42 32, key size
43 "ED25519", curve name
44 "2^255-19", prime number
45 "SHA512", hash function
46 "-121665/121666", value of d
47*/
48
49#define ED25519_KEY_SIZE 32 /* private key only */
50#define ED25519_SIG_SIZE 64
51
52#define ED25519_PUB_KEY_SIZE 32 /* compressed */
53/* both private and public key */
54#define ED25519_PRV_KEY_SIZE (ED25519_PUB_KEY_SIZE+ED25519_KEY_SIZE)
55
56/* An ED25519 Key */
57typedef struct {
58 byte p[ED25519_PUB_KEY_SIZE]; /* compressed public key */
59 byte k[ED25519_PRV_KEY_SIZE]; /* private key : 32 secret -- 32 public */
60} ed25519_key;
61
62
63WOLFSSL_API
64int wc_ed25519_make_key(WC_RNG* rng, int keysize, ed25519_key* key);
65WOLFSSL_API
66int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out,
67 word32 *outlen, ed25519_key* key);
68WOLFSSL_API
69int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg,
70 word32 msglen, int* stat, ed25519_key* key);
71WOLFSSL_API
72int wc_ed25519_init(ed25519_key* key);
73WOLFSSL_API
74void wc_ed25519_free(ed25519_key* key);
75WOLFSSL_API
76int wc_ed25519_import_public(const byte* in, word32 inLen, ed25519_key* key);
77WOLFSSL_API
78int wc_ed25519_import_private_key(const byte* priv, word32 privSz,
79 const byte* pub, word32 pubSz, ed25519_key* key);
80WOLFSSL_API
81int wc_ed25519_export_public(ed25519_key*, byte* out, word32* outLen);
82WOLFSSL_API
83int wc_ed25519_export_private_only(ed25519_key* key, byte* out, word32* outLen);
84WOLFSSL_API
85int wc_ed25519_export_private(ed25519_key* key, byte* out, word32* outLen);
86WOLFSSL_API
87int wc_ed25519_export_key(ed25519_key* key,
88 byte* priv, word32 *privSz,
89 byte* pub, word32 *pubSz);
90
91/* size helper */
92WOLFSSL_API
93int wc_ed25519_size(ed25519_key* key);
94WOLFSSL_API
95int wc_ed25519_priv_size(ed25519_key* key);
96WOLFSSL_API
97int wc_ed25519_pub_size(ed25519_key* key);
98WOLFSSL_API
99int wc_ed25519_sig_size(ed25519_key* key);
100
101#ifdef __cplusplus
102 } /* extern "C" */
103#endif
104
105#endif /* HAVE_ED25519 */
106#endif /* WOLF_CRYPT_ED25519_H */
107
Note: See TracBrowser for help on using the repository browser.