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.
Fork of wolfSSL by
ed25519.h
00001 /* ed25519.h 00002 * 00003 * Copyright (C) 2006-2016 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 #ifndef WOLF_CRYPT_ED25519_H 00024 #define WOLF_CRYPT_ED25519_H 00025 00026 #include <wolfssl/wolfcrypt/types.h> 00027 00028 #ifdef HAVE_ED25519 00029 00030 #include <wolfssl/wolfcrypt/fe_operations.h> 00031 #include <wolfssl/wolfcrypt/ge_operations.h> 00032 #include <wolfssl/wolfcrypt/random.h> 00033 #include <wolfssl/wolfcrypt/sha512.h> 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 00040 /* info about EdDSA curve specifically ed25519, defined as an elliptic curve 00041 over GF(p) */ 00042 /* 00043 32, key size 00044 "ED25519", curve name 00045 "2^255-19", prime number 00046 "SHA512", hash function 00047 "-121665/121666", value of d 00048 */ 00049 00050 #define ED25519_KEY_SIZE 32 /* private key only */ 00051 #define ED25519_SIG_SIZE 64 00052 00053 #define ED25519_PUB_KEY_SIZE 32 /* compressed */ 00054 /* both private and public key */ 00055 #define ED25519_PRV_KEY_SIZE (ED25519_PUB_KEY_SIZE+ED25519_KEY_SIZE) 00056 00057 /* An ED25519 Key */ 00058 typedef struct { 00059 byte p[ED25519_PUB_KEY_SIZE]; /* compressed public key */ 00060 byte k[ED25519_PRV_KEY_SIZE]; /* private key : 32 secret -- 32 public */ 00061 #ifdef FREESCALE_LTC_ECC 00062 /* uncompressed point coordinates */ 00063 byte pointX[ED25519_KEY_SIZE]; /* recovered X coordinate */ 00064 byte pointY[ED25519_KEY_SIZE]; /* Y coordinate is the public key with The most significant bit of the final octet always zero. */ 00065 #endif 00066 } ed25519_key; 00067 00068 00069 WOLFSSL_API 00070 int wc_ed25519_make_key(WC_RNG* rng, int keysize, ed25519_key* key); 00071 WOLFSSL_API 00072 int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out, 00073 word32 *outlen, ed25519_key* key); 00074 WOLFSSL_API 00075 int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg, 00076 word32 msglen, int* stat, ed25519_key* key); 00077 WOLFSSL_API 00078 int wc_ed25519_init(ed25519_key* key); 00079 WOLFSSL_API 00080 void wc_ed25519_free(ed25519_key* key); 00081 WOLFSSL_API 00082 int wc_ed25519_import_public(const byte* in, word32 inLen, ed25519_key* key); 00083 WOLFSSL_API 00084 int wc_ed25519_import_private_key(const byte* priv, word32 privSz, 00085 const byte* pub, word32 pubSz, ed25519_key* key); 00086 WOLFSSL_API 00087 int wc_ed25519_export_public(ed25519_key*, byte* out, word32* outLen); 00088 WOLFSSL_API 00089 int wc_ed25519_export_private_only(ed25519_key* key, byte* out, word32* outLen); 00090 WOLFSSL_API 00091 int wc_ed25519_export_private(ed25519_key* key, byte* out, word32* outLen); 00092 WOLFSSL_API 00093 int wc_ed25519_export_key(ed25519_key* key, 00094 byte* priv, word32 *privSz, 00095 byte* pub, word32 *pubSz); 00096 00097 /* size helper */ 00098 WOLFSSL_API 00099 int wc_ed25519_size(ed25519_key* key); 00100 WOLFSSL_API 00101 int wc_ed25519_priv_size(ed25519_key* key); 00102 WOLFSSL_API 00103 int wc_ed25519_pub_size(ed25519_key* key); 00104 WOLFSSL_API 00105 int wc_ed25519_sig_size(ed25519_key* key); 00106 00107 #ifdef __cplusplus 00108 } /* extern "C" */ 00109 #endif 00110 00111 #endif /* HAVE_ED25519 */ 00112 #endif /* WOLF_CRYPT_ED25519_H */ 00113 00114
Generated on Tue Jul 12 2022 23:30:55 by
1.7.2
