diff options
author | Jack Lloyd <[email protected]> | 2016-12-11 15:28:38 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-12-18 16:48:24 -0500 |
commit | f3cb3edb512bdcab498d825886c3366c341b3f78 (patch) | |
tree | 645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/lib/pubkey/curve25519 | |
parent | c1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff) |
Convert to using standard uintN_t integer types
Renames a couple of functions for somewhat better name consistency,
eg make_u32bit becomes make_uint32. The old typedefs remain for now
since probably lots of application code uses them.
Diffstat (limited to 'src/lib/pubkey/curve25519')
-rw-r--r-- | src/lib/pubkey/curve25519/curve25519.cpp | 20 | ||||
-rw-r--r-- | src/lib/pubkey/curve25519/curve25519.h | 26 | ||||
-rw-r--r-- | src/lib/pubkey/curve25519/donna.cpp | 6 |
3 files changed, 26 insertions, 26 deletions
diff --git a/src/lib/pubkey/curve25519/curve25519.cpp b/src/lib/pubkey/curve25519/curve25519.cpp index 7c3dea0f3..4908bf46f 100644 --- a/src/lib/pubkey/curve25519/curve25519.cpp +++ b/src/lib/pubkey/curve25519/curve25519.cpp @@ -14,7 +14,7 @@ namespace Botan { void curve25519_basepoint(uint8_t mypublic[32], const uint8_t secret[32]) { - const byte basepoint[32] = { 9 }; + const uint8_t basepoint[32] = { 9 }; curve25519_donna(mypublic, secret, basepoint); } @@ -26,10 +26,10 @@ void size_check(size_t size, const char* thing) throw Decoding_Error("Invalid size " + std::to_string(size) + " for Curve25519 " + thing); } -secure_vector<byte> curve25519(const secure_vector<byte>& secret, - const byte pubval[32]) +secure_vector<uint8_t> curve25519(const secure_vector<uint8_t>& secret, + const uint8_t pubval[32]) { - secure_vector<byte> out(32); + secure_vector<uint8_t> out(32); curve25519_donna(out.data(), secret.data(), pubval); return out; } @@ -47,7 +47,7 @@ bool Curve25519_PublicKey::check_key(RandomNumberGenerator&, bool) const } Curve25519_PublicKey::Curve25519_PublicKey(const AlgorithmIdentifier&, - const std::vector<byte>& key_bits) + const std::vector<uint8_t>& key_bits) { BER_Decoder(key_bits) .start_cons(SEQUENCE) @@ -58,7 +58,7 @@ Curve25519_PublicKey::Curve25519_PublicKey(const AlgorithmIdentifier&, size_check(m_public.size(), "public key"); } -std::vector<byte> Curve25519_PublicKey::public_key_bits() const +std::vector<uint8_t> Curve25519_PublicKey::public_key_bits() const { return DER_Encoder() .start_cons(SEQUENCE) @@ -75,7 +75,7 @@ Curve25519_PrivateKey::Curve25519_PrivateKey(RandomNumberGenerator& rng) } Curve25519_PrivateKey::Curve25519_PrivateKey(const AlgorithmIdentifier&, - const secure_vector<byte>& key_bits) + const secure_vector<uint8_t>& key_bits) { BER_Decoder(key_bits) .start_cons(SEQUENCE) @@ -88,7 +88,7 @@ Curve25519_PrivateKey::Curve25519_PrivateKey(const AlgorithmIdentifier&, size_check(m_private.size(), "private key"); } -secure_vector<byte> Curve25519_PrivateKey::private_key_bits() const +secure_vector<uint8_t> Curve25519_PrivateKey::private_key_bits() const { return DER_Encoder() .start_cons(SEQUENCE) @@ -105,7 +105,7 @@ bool Curve25519_PrivateKey::check_key(RandomNumberGenerator&, bool) const return public_point == m_public; } -secure_vector<byte> Curve25519_PrivateKey::agree(const byte w[], size_t w_len) const +secure_vector<uint8_t> Curve25519_PrivateKey::agree(const uint8_t w[], size_t w_len) const { size_check(w_len, "public value"); return curve25519(m_private, w); @@ -124,7 +124,7 @@ class Curve25519_KA_Operation : public PK_Ops::Key_Agreement_with_KDF PK_Ops::Key_Agreement_with_KDF(kdf), m_key(key) {} - secure_vector<byte> raw_agree(const byte w[], size_t w_len) override + secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) override { return m_key.agree(w, w_len); } diff --git a/src/lib/pubkey/curve25519/curve25519.h b/src/lib/pubkey/curve25519/curve25519.h index 68f3cb387..43e998df6 100644 --- a/src/lib/pubkey/curve25519/curve25519.h +++ b/src/lib/pubkey/curve25519/curve25519.h @@ -25,9 +25,9 @@ class BOTAN_DLL Curve25519_PublicKey : public virtual Public_Key AlgorithmIdentifier algorithm_identifier() const override; - std::vector<byte> public_key_bits() const override; + std::vector<uint8_t> public_key_bits() const override; - std::vector<byte> public_value() const { return m_public; } + std::vector<uint8_t> public_value() const { return m_public; } /** * Create a Curve25519 Public Key. @@ -35,24 +35,24 @@ class BOTAN_DLL Curve25519_PublicKey : public virtual Public_Key * @param key_bits DER encoded public key bits */ Curve25519_PublicKey(const AlgorithmIdentifier& alg_id, - const std::vector<byte>& key_bits); + const std::vector<uint8_t>& key_bits); /** * Create a Curve25519 Public Key. * @param pub 32-byte raw public key */ - explicit Curve25519_PublicKey(const std::vector<byte>& pub) : m_public(pub) {} + explicit Curve25519_PublicKey(const std::vector<uint8_t>& pub) : m_public(pub) {} /** * Create a Curve25519 Public Key. * @param pub 32-byte raw public key */ - explicit Curve25519_PublicKey(const secure_vector<byte>& pub) : + explicit Curve25519_PublicKey(const secure_vector<uint8_t>& pub) : m_public(pub.begin(), pub.end()) {} protected: Curve25519_PublicKey() {} - std::vector<byte> m_public; + std::vector<uint8_t> m_public; }; class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey, @@ -66,7 +66,7 @@ class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey, * @param key_bits PKCS #8 structure */ Curve25519_PrivateKey(const AlgorithmIdentifier& alg_id, - const secure_vector<byte>& key_bits); + const secure_vector<uint8_t>& key_bits); /** * Generate a private key. @@ -78,15 +78,15 @@ class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey, * Construct a private key from the specified parameters. * @param secret_key DER encoded private key bits */ - explicit Curve25519_PrivateKey(const secure_vector<byte>& secret_key); + explicit Curve25519_PrivateKey(const secure_vector<uint8_t>& secret_key); - std::vector<byte> public_value() const override { return Curve25519_PublicKey::public_value(); } + std::vector<uint8_t> public_value() const override { return Curve25519_PublicKey::public_value(); } - secure_vector<byte> agree(const byte w[], size_t w_len) const; + secure_vector<uint8_t> agree(const uint8_t w[], size_t w_len) const; - const secure_vector<byte>& get_x() const { return m_private; } + const secure_vector<uint8_t>& get_x() const { return m_private; } - secure_vector<byte> private_key_bits() const override; + secure_vector<uint8_t> private_key_bits() const override; bool check_key(RandomNumberGenerator& rng, bool strong) const override; @@ -96,7 +96,7 @@ class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey, const std::string& provider) const override; private: - secure_vector<byte> m_private; + secure_vector<uint8_t> m_private; }; /* diff --git a/src/lib/pubkey/curve25519/donna.cpp b/src/lib/pubkey/curve25519/donna.cpp index 22400015f..89f3fbc4a 100644 --- a/src/lib/pubkey/curve25519/donna.cpp +++ b/src/lib/pubkey/curve25519/donna.cpp @@ -35,8 +35,8 @@ namespace Botan { -typedef byte u8; -typedef u64bit limb; +typedef uint8_t u8; +typedef uint64_t limb; typedef limb felem[5]; typedef struct @@ -214,7 +214,7 @@ static inline void fsquare_times(felem output, const felem in, limb count) { /* Load a little-endian 64-bit number */ static limb load_limb(const u8 *in) { - return load_le<u64bit>(in, 0); + return load_le<uint64_t>(in, 0); } static void |