8 #include <botan/curve25519.h>
9 #include <botan/internal/pk_ops_impl.h>
10 #include <botan/ber_dec.h>
11 #include <botan/der_enc.h>
17 const uint8_t basepoint[32] = { 9 };
23 void size_check(
size_t size,
const char* thing)
26 throw Decoding_Error(
"Invalid size " +
std::to_string(size) +
" for Curve25519 " + thing);
29 secure_vector<uint8_t> curve25519(
const secure_vector<uint8_t>& secret,
30 const uint8_t pubval[32])
32 secure_vector<uint8_t> out(32);
50 const std::vector<uint8_t>& key_bits)
57 size_check(
m_public.size(),
"public key");
85 size_check(
m_public.size(),
"public key");
86 size_check(m_private.size(),
"private key");
101 std::vector<uint8_t> public_point(32);
108 size_check(w_len,
"public value");
109 return curve25519(m_private, w);
122 PK_Ops::Key_Agreement_with_KDF(kdf),
125 secure_vector<uint8_t> raw_agree(
const uint8_t w[],
size_t w_len)
override
127 return m_key.agree(w, w_len);
135 std::unique_ptr<PK_Ops::Key_Agreement>
137 const std::string& params,
138 const std::string& provider)
const
140 if(provider ==
"base" || provider.empty())
141 return std::unique_ptr<PK_Ops::Key_Agreement>(
new Curve25519_KA_Operation(*
this, params));
bool check_key(RandomNumberGenerator &rng, bool strong) const override
secure_vector< uint8_t > random_vec(size_t bytes)
std::vector< uint8_t > get_contents_unlocked()
std::string algo_name() const override
secure_vector< uint8_t > get_contents()
AlgorithmIdentifier algorithm_identifier() const override
BER_Decoder & decode(bool &v)
std::string to_string(const BER_Object &obj)
Curve25519_PublicKey()=default
virtual OID get_oid() const
bool check_key(RandomNumberGenerator &rng, bool strong) const override
DER_Encoder & encode(bool b)
std::vector< uint8_t > public_key_bits() const override
secure_vector< uint8_t > private_key_bits() const override
std::vector< T, secure_allocator< T >> secure_vector
std::unique_ptr< PK_Ops::Key_Agreement > create_key_agreement_op(RandomNumberGenerator &rng, const std::string ¶ms, const std::string &provider) const override
BER_Decoder start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
Curve25519_PrivateKey(const AlgorithmIdentifier &alg_id, const secure_vector< uint8_t > &key_bits)
std::vector< uint8_t > m_public
void curve25519_basepoint(uint8_t mypublic[32], const uint8_t secret[32])
secure_vector< uint8_t > agree(const uint8_t w[], size_t w_len) const
DER_Encoder & start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
void BOTAN_DLL curve25519_donna(uint8_t mypublic[32], const uint8_t secret[32], const uint8_t basepoint[32])
const Curve25519_PrivateKey & m_key