2019-01-26 15:40:58 +00:00
|
|
|
#ifndef LLARP_CRYPTO_LIBSODIUM_HPP
|
|
|
|
#define LLARP_CRYPTO_LIBSODIUM_HPP
|
|
|
|
|
|
|
|
#include <crypto/crypto.hpp>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace sodium
|
|
|
|
{
|
|
|
|
struct CryptoLibSodium final : public Crypto
|
|
|
|
{
|
|
|
|
CryptoLibSodium();
|
|
|
|
|
|
|
|
~CryptoLibSodium()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// xchacha symmetric cipher
|
|
|
|
bool
|
2019-02-01 01:58:06 +00:00
|
|
|
xchacha20(const llarp_buffer_t &, const SharedSecret &,
|
2019-01-26 15:40:58 +00:00
|
|
|
const TunnelNonce &) override;
|
|
|
|
|
|
|
|
/// xchacha symmetric cipher (multibuffer)
|
|
|
|
bool
|
2019-02-01 01:58:06 +00:00
|
|
|
xchacha20_alt(const llarp_buffer_t &, const llarp_buffer_t &,
|
|
|
|
const SharedSecret &, const byte_t *) override;
|
2019-01-26 15:40:58 +00:00
|
|
|
|
|
|
|
/// path dh creator's side
|
|
|
|
bool
|
|
|
|
dh_client(SharedSecret &, const PubKey &, const SecretKey &,
|
|
|
|
const TunnelNonce &) override;
|
|
|
|
/// path dh relay side
|
|
|
|
bool
|
|
|
|
dh_server(SharedSecret &, const PubKey &, const SecretKey &,
|
|
|
|
const TunnelNonce &) override;
|
|
|
|
/// transport dh client side
|
|
|
|
bool
|
|
|
|
transport_dh_client(SharedSecret &, const PubKey &, const SecretKey &,
|
|
|
|
const TunnelNonce &) override;
|
|
|
|
/// transport dh server side
|
|
|
|
bool
|
|
|
|
transport_dh_server(SharedSecret &, const PubKey &, const SecretKey &,
|
|
|
|
const TunnelNonce &) override;
|
|
|
|
/// blake2b 256 bit
|
|
|
|
bool
|
2019-02-01 01:58:06 +00:00
|
|
|
shorthash(ShortHash &, const llarp_buffer_t &) override;
|
2019-01-26 15:40:58 +00:00
|
|
|
/// blake2s 256 bit hmac
|
|
|
|
bool
|
2019-02-01 01:58:06 +00:00
|
|
|
hmac(byte_t *, const llarp_buffer_t &, const SharedSecret &) override;
|
2019-01-26 15:40:58 +00:00
|
|
|
/// ed25519 sign
|
|
|
|
bool
|
2019-02-01 01:58:06 +00:00
|
|
|
sign(Signature &, const SecretKey &, const llarp_buffer_t &) override;
|
2019-01-26 15:40:58 +00:00
|
|
|
/// ed25519 verify
|
|
|
|
bool
|
2019-02-01 01:58:06 +00:00
|
|
|
verify(const PubKey &, const llarp_buffer_t &,
|
|
|
|
const Signature &) override;
|
2019-01-26 15:40:58 +00:00
|
|
|
/// seed to secretkey
|
|
|
|
bool
|
|
|
|
seed_to_secretkey(llarp::SecretKey &,
|
|
|
|
const llarp::IdentitySecret &) override;
|
|
|
|
/// randomize buffer
|
2019-02-01 01:58:06 +00:00
|
|
|
void
|
|
|
|
randomize(const llarp_buffer_t &) override;
|
2019-01-26 15:40:58 +00:00
|
|
|
/// randomizer memory
|
|
|
|
void
|
2019-05-28 19:45:09 +00:00
|
|
|
randbytes(byte_t *, size_t) override;
|
2019-01-26 15:40:58 +00:00
|
|
|
/// generate signing keypair
|
|
|
|
void
|
|
|
|
identity_keygen(SecretKey &) override;
|
|
|
|
/// generate encryption keypair
|
|
|
|
void
|
|
|
|
encryption_keygen(SecretKey &) override;
|
|
|
|
/// generate post quantum encrytion key
|
|
|
|
void
|
|
|
|
pqe_keygen(PQKeyPair &) override;
|
|
|
|
/// post quantum decrypt (buffer, sharedkey_dst, sec)
|
|
|
|
bool
|
|
|
|
pqe_decrypt(const PQCipherBlock &, SharedSecret &,
|
|
|
|
const byte_t *) override;
|
|
|
|
/// post quantum encrypt (buffer, sharedkey_dst, pub)
|
|
|
|
bool
|
|
|
|
pqe_encrypt(PQCipherBlock &, SharedSecret &, const PQPubKey &) override;
|
|
|
|
};
|
|
|
|
} // namespace sodium
|
|
|
|
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|