diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/constructs/rfc3394/rfc3394.cpp | 4 | ||||
-rw-r--r-- | src/passhash/bcrypt/bcrypt.cpp | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/constructs/rfc3394/rfc3394.cpp b/src/constructs/rfc3394/rfc3394.cpp index b000873fd..db6420ff3 100644 --- a/src/constructs/rfc3394/rfc3394.cpp +++ b/src/constructs/rfc3394/rfc3394.cpp @@ -39,7 +39,7 @@ SecureVector<byte> rfc3394_keywrap(const MemoryRegion<byte>& key, if(key.size() % 8 != 0) throw std::invalid_argument("Bad input key size for NIST key wrap"); - std::auto_ptr<BlockCipher> aes(make_aes(kek.length(), af)); + std::unique_ptr<BlockCipher> aes(make_aes(kek.length(), af)); aes->set_key(kek); const size_t n = key.size() / 8; @@ -81,7 +81,7 @@ SecureVector<byte> rfc3394_keyunwrap(const MemoryRegion<byte>& key, if(key.size() < 16 || key.size() % 8 != 0) throw std::invalid_argument("Bad input key size for NIST key unwrap"); - std::auto_ptr<BlockCipher> aes(make_aes(kek.length(), af)); + std::unique_ptr<BlockCipher> aes(make_aes(kek.length(), af)); aes->set_key(kek); const size_t n = (key.size() - 8) / 8; diff --git a/src/passhash/bcrypt/bcrypt.cpp b/src/passhash/bcrypt/bcrypt.cpp index e533c6081..3507db879 100644 --- a/src/passhash/bcrypt/bcrypt.cpp +++ b/src/passhash/bcrypt/bcrypt.cpp @@ -120,8 +120,13 @@ std::string make_bcrypt(const std::string& pass, std::string salt_b64 = bcrypt_base64_encode(&salt[0], salt.size()); - return "$2a$" + to_string(work_factor, 2) + "$" + salt_b64.substr(0, 22) + - bcrypt_base64_encode(&ctext[0], ctext.size() - 1); + std::string work_factor_str = std::to_string(work_factor); + if(work_factor_str.length() == 1) + work_factor_str = "0" + work_factor_str; + + return "$2a$" + work_factor_str + + "$" + salt_b64.substr(0, 22) + + bcrypt_base64_encode(&ctext[0], ctext.size() - 1); } } |