Security Scol plugin
donna.h
Go to the documentation of this file.
1// donna.h - written and placed in public domain by Jeffrey Walton
2// Crypto++ specific implementation wrapped around Andrew
3// Moon's public domain curve25519-donna and ed25519-donna,
4// https://github.com/floodyberry/curve25519-donna and
5// https://github.com/floodyberry/ed25519-donna.
6
7// The curve25519 and ed25519 source files multiplex different repos and
8// architectures using namespaces. The repos are Andrew Moon's
9// curve25519-donna and ed25519-donna. The architectures are 32-bit, 64-bit
10// and SSE. For example, 32-bit x25519 uses symbols from Donna::X25519 and
11// Donna::Arch32.
12
13// If needed, see Moon's commit "Go back to ignoring 256th bit [sic]",
14// https://github.com/floodyberry/curve25519-donna/commit/57a683d18721a658
15
25
26#ifndef CRYPTOPP_DONNA_H
27#define CRYPTOPP_DONNA_H
28
29#include "cryptlib.h"
30#include "stdcpp.h"
31
32NAMESPACE_BEGIN(CryptoPP)
33NAMESPACE_BEGIN(Donna)
34
35//***************************** curve25519 *****************************//
36
37
45int curve25519_mult(byte publicKey[32], const byte secretKey[32]);
46
56int curve25519_mult(byte sharedKey[32], const byte secretKey[32], const byte othersKey[32]);
57
58//******************************* ed25519 *******************************//
59
67int ed25519_publickey(byte publicKey[32], const byte secretKey[32]);
68
82int ed25519_sign(const byte* message, size_t messageLength, const byte secretKey[32], const byte publicKey[32], byte signature[64]);
83
99int ed25519_sign(std::istream& stream, const byte secretKey[32], const byte publicKey[32], byte signature[64]);
100
112int
113ed25519_sign_open(const byte *message, size_t messageLength, const byte publicKey[32], const byte signature[64]);
114
128int
129ed25519_sign_open(std::istream& stream, const byte publicKey[32], const byte signature[64]);
130
131//****************************** Internal ******************************//
132
133#ifndef CRYPTOPP_DOXYGEN_PROCESSING
134
135// CRYPTOPP_WORD128_AVAILABLE mostly depends upon GCC support for
136// __SIZEOF_INT128__. If __SIZEOF_INT128__ is not available then Moon
137// provides routines for MSC and GCC. It should cover most platforms,
138// but there are gaps like MS ARM64 and XLC. We tried to enable the
139// 64-bit path for SunCC from 12.5 but we got the dreaded compile
140// error "The operand ___LCM cannot be assigned to".
141
142#if defined(CRYPTOPP_WORD128_AVAILABLE) || \
143 (defined(_MSC_VER) && defined(_M_X64))
144# define CRYPTOPP_CURVE25519_64BIT 1
145#else
146# define CRYPTOPP_CURVE25519_32BIT 1
147#endif
148
149// Benchmarking on a modern 64-bit Core i5-6400 @2.7 GHz shows SSE2 on Linux
150// is not profitable. Here are the numbers in milliseconds/operation:
151//
152// * Langley, C++, 0.050
153// * Moon, C++: 0.040
154// * Moon, SSE2: 0.061
155// * Moon, native: 0.045
156//
157// However, a modern 64-bit Core i5-3200 @2.5 GHz shows SSE2 is profitable
158// for MS compilers. Here are the numbers in milliseconds/operation:
159//
160// * x86, no SSE2, 0.294
161// * x86, SSE2, 0.097
162// * x64, no SSE2, 0.081
163// * x64, SSE2, 0.071
164
165#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE) && defined(_MSC_VER)
166# define CRYPTOPP_CURVE25519_SSE2 1
167#endif
168
169#if (CRYPTOPP_CURVE25519_SSE2)
170 extern int curve25519_mult_SSE2(byte sharedKey[32], const byte secretKey[32], const byte othersKey[32]);
171#endif
172
173#endif // CRYPTOPP_DOXYGEN_PROCESSING
174
175NAMESPACE_END // Donna
176NAMESPACE_END // CryptoPP
177
178#endif // CRYPTOPP_DONNA_H
Abstract base classes that provide a uniform interface to this library.
int ed25519_sign_open(const byte *message, size_t messageLength, const byte publicKey[32], const byte signature[64])
Verifies a signature on a message.
int ed25519_sign(const byte *message, size_t messageLength, const byte secretKey[32], const byte publicKey[32], byte signature[64])
Creates a signature on a message.
int ed25519_publickey(byte publicKey[32], const byte secretKey[32])
Creates a public key from a secret key.
int curve25519_mult(byte publicKey[32], const byte secretKey[32])
Generate a public key.
Common C++ header files.