Botan 2.19.5 Crypto and TLS for C&

sodium_25519.cpp
Go to the documentation of this file.
1/*
2* (C) 2019 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/sodium.h>
8#include <botan/ed25519.h>
9#include <botan/curve25519.h>
10
11 namespace Botan {
12
13 int Sodium::crypto_scalarmult_curve25519(uint8_t out[32], const uint8_t scalar[32], const uint8_t point[32])
14 {
15 curve25519_donna(out, scalar, point);
16 return 0;
17 }
18
19 int Sodium::crypto_scalarmult_curve25519_base(uint8_t out[32], const uint8_t scalar[32])
20 {
21 curve25519_basepoint(out, scalar);
22 return 0;
23 }
24 int Sodium::crypto_sign_ed25519_detached(uint8_t sig[],
25 unsigned long long* sig_len,
26 const uint8_t msg[],
27 size_t msg_len,
28 const uint8_t sk[32])
29 {
30 ed25519_sign(sig, msg, msg_len, sk, nullptr, 0);
31
32 if(sig_len)
33 *sig_len = 64;
34 return 0;
35 }
36
37 int Sodium::crypto_sign_ed25519_verify_detached(const uint8_t sig[],
38 const uint8_t msg[],
39 size_t msg_len,
40 const uint8_t pk[32])
41 {
42 const bool ok = ed25519_verify(msg, msg_len, sig, pk, nullptr, 0);
43 return ok ? 0 : -1;
44 }
45
46 int Sodium::crypto_sign_ed25519_keypair(uint8_t pk[32], uint8_t sk[64])
47 {
48 secure_vector<uint8_t> seed(32);
49 randombytes_buf(seed.data(), seed.size());
50 return crypto_sign_ed25519_seed_keypair(pk, sk, seed.data());
51 }
52
53 int Sodium::crypto_sign_ed25519_seed_keypair(uint8_t pk[], uint8_t sk[],
54 const uint8_t seed[])
55 {
56 ed25519_gen_keypair(pk, sk, seed);
57 return 0;
58 }
59
60}
Botan::Sodium::crypto_sign_ed25519_verify_detached
int crypto_sign_ed25519_verify_detached(const uint8_t sig[], const uint8_t msg[], size_t msg_len, const uint8_t pk[32])
Definition: sodium_25519.cpp:37
Botan::Sodium::crypto_scalarmult_curve25519
int crypto_scalarmult_curve25519(uint8_t out[32], const uint8_t scalar[32], const uint8_t basepoint[32])
Definition: sodium_25519.cpp:13
Botan::Sodium::crypto_sign_ed25519_detached
int crypto_sign_ed25519_detached(uint8_t sig[], unsigned long long *sig_len, const uint8_t msg[], size_t msg_len, const uint8_t sk[32])
Definition: sodium_25519.cpp:24
Botan::Sodium::crypto_scalarmult_curve25519_base
int crypto_scalarmult_curve25519_base(uint8_t out[32], const uint8_t scalar[32])
Definition: sodium_25519.cpp:19
Botan::Sodium::crypto_sign_ed25519_keypair
int crypto_sign_ed25519_keypair(uint8_t pk[32], uint8_t sk[64])
Definition: sodium_25519.cpp:46
Botan::Sodium::crypto_sign_ed25519_seed_keypair
int crypto_sign_ed25519_seed_keypair(uint8_t pk[], uint8_t sk[], const uint8_t seed[])
Definition: sodium_25519.cpp:53
Botan::Sodium::randombytes_buf
void randombytes_buf(void *buf, size_t size)
Definition: sodium_utils.cpp:18
Botan
Definition: alg_id.cpp:13
Botan::ed25519_sign
void ed25519_sign(uint8_t sig[64], const uint8_t m[], size_t mlen, const uint8_t sk[64], const uint8_t domain_sep[], size_t domain_sep_len)
Definition: ed25519.cpp:36
Botan::ed25519_gen_keypair
void ed25519_gen_keypair(uint8_t *pk, uint8_t *sk, const uint8_t seed[32])
Definition: ed25519.cpp:18
Botan::curve25519_donna
void curve25519_donna(uint8_t mypublic[32], const uint8_t secret[32], const uint8_t basepoint[32])
Definition: donna.cpp:440
Botan::ed25519_verify
bool ed25519_verify(const uint8_t *m, size_t mlen, const uint8_t sig[64], const uint8_t *pk, const uint8_t domain_sep[], size_t domain_sep_len)
Definition: ed25519.cpp:71
Botan::curve25519_basepoint
void curve25519_basepoint(uint8_t mypublic[32], const uint8_t secret[32])
Definition: curve25519.cpp:16
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65