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/passhash/passhash9 | |
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/passhash/passhash9')
-rw-r--r-- | src/lib/passhash/passhash9/passhash9.cpp | 18 | ||||
-rw-r--r-- | src/lib/passhash/passhash9/passhash9.h | 4 |
2 files changed, 11 insertions, 11 deletions
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<MessageAuthenticationCode> get_pbkdf_prf(byte alg_id) +std::unique_ptr<MessageAuthenticationCode> get_pbkdf_prf(uint8_t alg_id) { if(alg_id == 0) return MessageAuthenticationCode::create("HMAC(SHA-1)"); @@ -42,8 +42,8 @@ std::unique_ptr<MessageAuthenticationCode> 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<MessageAuthenticationCode> 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<byte> salt(SALT_BYTES); + secure_vector<uint8_t> salt(SALT_BYTES); rng.randomize(salt.data(), salt.size()); const size_t kdf_iterations = WORK_FACTOR_SCALE * work_factor; - secure_vector<byte> blob; + secure_vector<uint8_t> 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<byte> bin = base64_decode(hash.c_str() + MAGIC_PREFIX.size()); + secure_vector<uint8_t> 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<u16bit>(&bin[ALGID_BYTES], 0); + const size_t work_factor = load_be<uint16_t>(&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<byte> cmp = kdf.derive_key( + secure_vector<uint8_t> 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 |