Replace hardcoded parameters
This commit is contained in:
@@ -19,7 +19,7 @@ namespace crypto_util {
|
||||
|
||||
// Encrypts the provided plantext std::string using AES-CBC encryption.
|
||||
std::string EncryptAesCbc(const std::string& key, const std::string& iv,
|
||||
const std::string& plaintext) {
|
||||
const std::string& plaintext) {
|
||||
const size_t num_padding_bytes =
|
||||
AES_BLOCK_SIZE - (plaintext.size() % AES_BLOCK_SIZE);
|
||||
std::string padded_text = plaintext;
|
||||
@@ -28,7 +28,7 @@ std::string EncryptAesCbc(const std::string& key, const std::string& iv,
|
||||
}
|
||||
|
||||
std::string EncryptAesCbcNoPad(const std::string& key, const std::string& iv,
|
||||
const std::string& plaintext) {
|
||||
const std::string& plaintext) {
|
||||
if (iv.size() != AES_BLOCK_SIZE) {
|
||||
LOG(WARNING) << "Invalid CBC IV size: " << iv.size();
|
||||
return std::string();
|
||||
@@ -56,7 +56,7 @@ std::string EncryptAesCbcNoPad(const std::string& key, const std::string& iv,
|
||||
// Decrypts the AES-CBC encrypted text. Returns an empty std::string on error or
|
||||
// the plaintext on success.
|
||||
std::string DecryptAesCbc(const std::string& key, const std::string& iv,
|
||||
const std::string& ciphertext) {
|
||||
const std::string& ciphertext) {
|
||||
if (ciphertext.empty()) {
|
||||
LOG(WARNING) << "Empty ciphertext.";
|
||||
return std::string();
|
||||
@@ -100,7 +100,7 @@ std::string DecryptAesCbc(const std::string& key, const std::string& iv,
|
||||
}
|
||||
|
||||
std::string DecryptAesCbcNoPad(const std::string& key, const std::string& iv,
|
||||
const std::string& ciphertext) {
|
||||
const std::string& ciphertext) {
|
||||
std::vector<uint8_t> local_iv(iv.begin(), iv.end());
|
||||
if (local_iv.empty()) {
|
||||
local_iv.resize(AES_BLOCK_SIZE, '\0');
|
||||
|
||||
Reference in New Issue
Block a user