Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ed25519.h
00001 /* ed25519.h 00002 * 00003 * Copyright (C) 2006-2017 wolfSSL Inc. 00004 * 00005 * This file is part of wolfSSL. 00006 * 00007 * wolfSSL is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * wolfSSL is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 00020 */ 00021 00022 /*! 00023 \file wolfssl/wolfcrypt/ed25519.h 00024 */ 00025 00026 00027 #ifndef WOLF_CRYPT_ED25519_H 00028 #define WOLF_CRYPT_ED25519_H 00029 00030 #include <wolfcrypt/types.h> 00031 00032 #ifdef HAVE_ED25519 00033 00034 #include <wolfcrypt/fe_operations.h> 00035 #include <wolfcrypt/ge_operations.h> 00036 #include <wolfcrypt/random.h> 00037 #include <wolfcrypt/sha512.h> 00038 00039 #ifdef WOLFSSL_ASYNC_CRYPT 00040 #include <wolfcrypt/async.h> 00041 #endif 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 00048 /* info about EdDSA curve specifically ed25519, defined as an elliptic curve 00049 over GF(p) */ 00050 /* 00051 32, key size 00052 "ED25519", curve name 00053 "2^255-19", prime number 00054 "SHA512", hash function 00055 "-121665/121666", value of d 00056 */ 00057 00058 #define ED25519_KEY_SIZE 32 /* private key only */ 00059 #define ED25519_SIG_SIZE 64 00060 00061 #define ED25519_PUB_KEY_SIZE 32 /* compressed */ 00062 /* both private and public key */ 00063 #define ED25519_PRV_KEY_SIZE (ED25519_PUB_KEY_SIZE+ED25519_KEY_SIZE) 00064 00065 00066 #ifndef WC_ED25519KEY_TYPE_DEFINED 00067 typedef struct ed25519_key ed25519_key; 00068 #define WC_ED25519KEY_TYPE_DEFINED 00069 #endif 00070 00071 /* An ED25519 Key */ 00072 struct ed25519_key { 00073 byte p[ED25519_PUB_KEY_SIZE]; /* compressed public key */ 00074 byte k[ED25519_PRV_KEY_SIZE]; /* private key : 32 secret -- 32 public */ 00075 #ifdef FREESCALE_LTC_ECC 00076 /* uncompressed point coordinates */ 00077 byte pointX[ED25519_KEY_SIZE]; /* recovered X coordinate */ 00078 byte pointY[ED25519_KEY_SIZE]; /* Y coordinate is the public key with The most significant bit of the final octet always zero. */ 00079 #endif 00080 int pubKeySet:1; 00081 #ifdef WOLFSSL_ASYNC_CRYPT 00082 WC_ASYNC_DEV asyncDev; 00083 #endif 00084 }; 00085 00086 00087 WOLFSSL_API 00088 int wc_ed25519_make_key(WC_RNG* rng, int keysize, ed25519_key* key); 00089 WOLFSSL_API 00090 int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out, 00091 word32 *outlen, ed25519_key* key); 00092 WOLFSSL_API 00093 int wc_ed25519_verify_msg(const byte* sig, word32 siglen, const byte* msg, 00094 word32 msglen, int* stat, ed25519_key* key); 00095 WOLFSSL_API 00096 int wc_ed25519_init(ed25519_key* key); 00097 WOLFSSL_API 00098 void wc_ed25519_free(ed25519_key* key); 00099 WOLFSSL_API 00100 int wc_ed25519_import_public(const byte* in, word32 inLen, ed25519_key* key); 00101 WOLFSSL_API 00102 int wc_ed25519_import_private_only(const byte* priv, word32 privSz, 00103 ed25519_key* key); 00104 WOLFSSL_API 00105 int wc_ed25519_import_private_key(const byte* priv, word32 privSz, 00106 const byte* pub, word32 pubSz, ed25519_key* key); 00107 WOLFSSL_API 00108 int wc_ed25519_export_public(ed25519_key*, byte* out, word32* outLen); 00109 WOLFSSL_API 00110 int wc_ed25519_export_private_only(ed25519_key* key, byte* out, word32* outLen); 00111 WOLFSSL_API 00112 int wc_ed25519_export_private(ed25519_key* key, byte* out, word32* outLen); 00113 WOLFSSL_API 00114 int wc_ed25519_export_key(ed25519_key* key, 00115 byte* priv, word32 *privSz, 00116 byte* pub, word32 *pubSz); 00117 00118 int wc_ed25519_check_key(ed25519_key* key); 00119 00120 /* size helper */ 00121 WOLFSSL_API 00122 int wc_ed25519_size(ed25519_key* key); 00123 WOLFSSL_API 00124 int wc_ed25519_priv_size(ed25519_key* key); 00125 WOLFSSL_API 00126 int wc_ed25519_pub_size(ed25519_key* key); 00127 WOLFSSL_API 00128 int wc_ed25519_sig_size(ed25519_key* key); 00129 00130 #ifdef __cplusplus 00131 } /* extern "C" */ 00132 #endif 00133 00134 #endif /* HAVE_ED25519 */ 00135 #endif /* WOLF_CRYPT_ED25519_H */ 00136 00137
Generated on Tue Jul 12 2022 16:58:05 by
1.7.2