3 * Copyright (C) 2006-2015 wolfSSL Inc.
5 * This file is part of wolfSSL. (formerly known as CyaSSL)
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.
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.
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
22 #ifndef WOLF_CRYPT_ED25519_H
23 #define WOLF_CRYPT_ED25519_H
25 #include <wolfssl/wolfcrypt/types.h>
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>
39 /* info about EdDSA curve specifically ed25519, defined as an elliptic curve
44 "2^255-19", prime number
45 "SHA512", hash function
46 "-121665/121666", value of d
49 #define ED25519_KEY_SIZE 32
50 #define ED25519_SIG_SIZE 64
55 byte p[32]; /* compressed public key */
56 byte k[64]; /* private key : 32 secret -- 32 public */
61 int wc_ed25519_make_key(RNG* rng, int keysize, ed25519_key* key);
63 int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out,
64 word32 *outlen, ed25519_key* key);
66 int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg,
67 word32 msglen, int* stat, ed25519_key* key);
69 int wc_ed25519_init(ed25519_key* key);
71 void wc_ed25519_free(ed25519_key* key);
73 int wc_ed25519_import_public(const byte* in, word32 inLen, ed25519_key* key);
75 int wc_ed25519_import_private_key(const byte* priv, word32 privSz,
76 const byte* pub, word32 pubSz, ed25519_key* key);
78 int wc_ed25519_export_public(ed25519_key*, byte* out, word32* outLen);
80 int wc_ed25519_export_private_only(ed25519_key* key, byte* out, word32* outLen);
84 int wc_ed25519_size(ed25519_key* key);
86 int wc_ed25519_sig_size(ed25519_key* key);
92 #endif /* HAVE_ED25519 */
93 #endif /* WOLF_CRYPT_ED25519_H */