diff options
author | Jack Lloyd <[email protected]> | 2017-08-29 18:16:44 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-08-29 18:16:44 -0400 |
commit | 17ef09021892afc4c0e9fe7ba97423bf832e6dc5 (patch) | |
tree | b364838fde2dc1efedb91feb309a0a77fd4428d1 | |
parent | 6deac88ea6ef221474bcb63722bd7a8bd283ca67 (diff) |
Slight cleanup in Curve25519_PrivateKey constructor
-rw-r--r-- | src/lib/pubkey/curve25519/curve25519.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/lib/pubkey/curve25519/curve25519.cpp b/src/lib/pubkey/curve25519/curve25519.cpp index 6cd5b0cb8..7776c6550 100644 --- a/src/lib/pubkey/curve25519/curve25519.cpp +++ b/src/lib/pubkey/curve25519/curve25519.cpp @@ -64,16 +64,14 @@ std::vector<uint8_t> Curve25519_PublicKey::public_key_bits() const Curve25519_PrivateKey::Curve25519_PrivateKey(const secure_vector<uint8_t>& secret_key) { - if(secret_key.size() == 32) - { - m_public.resize(32); - m_private = secret_key; - curve25519_basepoint(m_public.data(), m_private.data()); - } - else + if(secret_key.size() != 32) throw Decoding_Error("Invalid size for Curve25519 private key"); + + m_public.resize(32); + m_private = secret_key; + curve25519_basepoint(m_public.data(), m_private.data()); } - + Curve25519_PrivateKey::Curve25519_PrivateKey(RandomNumberGenerator& rng) { m_private = rng.random_vec(32); |