From f3cb3edb512bdcab498d825886c3366c341b3f78 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sun, 11 Dec 2016 15:28:38 -0500 Subject: 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. --- src/lib/passhash/passhash9/passhash9.cpp | 18 +++++++++--------- src/lib/passhash/passhash9/passhash9.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/lib/passhash/passhash9') diff --git a/src/lib/passhash/passhash9/passhash9.cpp b/src/lib/passhash/passhash9/passhash9.cpp index c6a2f7d9e..fef23515b 100644 --- a/src/lib/passhash/passhash9/passhash9.cpp +++ b/src/lib/passhash/passhash9/passhash9.cpp @@ -23,7 +23,7 @@ const size_t PASSHASH9_PBKDF_OUTPUT_LEN = 24; // 192 bits output const size_t WORK_FACTOR_SCALE = 10000; -std::unique_ptr get_pbkdf_prf(byte alg_id) +std::unique_ptr get_pbkdf_prf(uint8_t alg_id) { if(alg_id == 0) return MessageAuthenticationCode::create("HMAC(SHA-1)"); @@ -42,8 +42,8 @@ std::unique_ptr get_pbkdf_prf(byte alg_id) std::string generate_passhash9(const std::string& pass, RandomNumberGenerator& rng, - u16bit work_factor, - byte alg_id) + uint16_t work_factor, + uint8_t alg_id) { std::unique_ptr prf = get_pbkdf_prf(alg_id); @@ -54,12 +54,12 @@ std::string generate_passhash9(const std::string& pass, PKCS5_PBKDF2 kdf(prf.release()); // takes ownership of pointer - secure_vector salt(SALT_BYTES); + secure_vector salt(SALT_BYTES); rng.randomize(salt.data(), salt.size()); const size_t kdf_iterations = WORK_FACTOR_SCALE * work_factor; - secure_vector blob; + secure_vector blob; blob.push_back(alg_id); blob.push_back(get_byte(0, work_factor)); blob.push_back(get_byte(1, work_factor)); @@ -90,14 +90,14 @@ bool check_passhash9(const std::string& pass, const std::string& hash) if(hash[i] != MAGIC_PREFIX[i]) return false; - secure_vector bin = base64_decode(hash.c_str() + MAGIC_PREFIX.size()); + secure_vector bin = base64_decode(hash.c_str() + MAGIC_PREFIX.size()); if(bin.size() != BINARY_LENGTH) return false; - byte alg_id = bin[0]; + uint8_t alg_id = bin[0]; - const size_t work_factor = load_be(&bin[ALGID_BYTES], 0); + const size_t work_factor = load_be(&bin[ALGID_BYTES], 0); // Bug in the format, bad states shouldn't be representable, but are... if(work_factor == 0) @@ -116,7 +116,7 @@ bool check_passhash9(const std::string& pass, const std::string& hash) PKCS5_PBKDF2 kdf(pbkdf_prf.release()); // takes ownership of pointer - secure_vector cmp = kdf.derive_key( + secure_vector cmp = kdf.derive_key( PASSHASH9_PBKDF_OUTPUT_LEN, pass, &bin[ALGID_BYTES + WORKFACTOR_BYTES], SALT_BYTES, diff --git a/src/lib/passhash/passhash9/passhash9.h b/src/lib/passhash/passhash9/passhash9.h index 8e8293600..d2282481d 100644 --- a/src/lib/passhash/passhash9/passhash9.h +++ b/src/lib/passhash/passhash9/passhash9.h @@ -27,8 +27,8 @@ namespace Botan { */ std::string BOTAN_DLL generate_passhash9(const std::string& password, RandomNumberGenerator& rng, - u16bit work_factor = 10, - byte alg_id = 1); + uint16_t work_factor = 10, + uint8_t alg_id = 1); /** * Check a previously created password hash -- cgit v1.2.3