diff options
author | Jack Lloyd <[email protected]> | 2016-12-18 16:53:10 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-12-18 16:53:25 -0500 |
commit | 5eca80aa3336dc49c721e9c6404f531f2e290537 (patch) | |
tree | 645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/lib/pubkey/dlies/dlies.cpp | |
parent | c1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff) | |
parent | f3cb3edb512bdcab498d825886c3366c341b3f78 (diff) |
Merge GH #771 Use cstdint integer types
Diffstat (limited to 'src/lib/pubkey/dlies/dlies.cpp')
-rw-r--r-- | src/lib/pubkey/dlies/dlies.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lib/pubkey/dlies/dlies.cpp b/src/lib/pubkey/dlies/dlies.cpp index 09f24adb7..ca91a0fd4 100644 --- a/src/lib/pubkey/dlies/dlies.cpp +++ b/src/lib/pubkey/dlies/dlies.cpp @@ -41,7 +41,7 @@ DLIES_Encryptor::DLIES_Encryptor(const DH_PrivateKey& own_priv_key, BOTAN_ASSERT_NONNULL(mac); } -std::vector<byte> DLIES_Encryptor::enc(const byte in[], size_t length, +std::vector<uint8_t> DLIES_Encryptor::enc(const uint8_t in[], size_t length, RandomNumberGenerator&) const { if(m_other_pub_key.empty()) @@ -54,14 +54,14 @@ std::vector<byte> DLIES_Encryptor::enc(const byte in[], size_t length, // derive secret key from secret value const size_t required_key_length = m_cipher ? m_cipher_key_len + m_mac_keylen : length + m_mac_keylen; - const secure_vector<byte> secret_keys = m_kdf->derive_key(required_key_length, secret_value.bits_of()); + const secure_vector<uint8_t> secret_keys = m_kdf->derive_key(required_key_length, secret_value.bits_of()); if(secret_keys.size() != required_key_length) { throw Encoding_Error("DLIES: KDF did not provide sufficient output"); } - secure_vector<byte> ciphertext(in, in + length); + secure_vector<uint8_t> ciphertext(in, in + length); const size_t cipher_key_len = m_cipher ? m_cipher_key_len : length; if(m_cipher) @@ -83,10 +83,10 @@ std::vector<byte> DLIES_Encryptor::enc(const byte in[], size_t length, // calculate MAC m_mac->set_key(secret_keys.data() + cipher_key_len, m_mac_keylen); - secure_vector<byte> tag = m_mac->process(ciphertext); + secure_vector<uint8_t> tag = m_mac->process(ciphertext); // out = (ephemeral) public key + ciphertext + tag - secure_vector<byte> out(m_own_pub_key.size() + ciphertext.size() + tag.size()); + secure_vector<uint8_t> out(m_own_pub_key.size() + ciphertext.size() + tag.size()); buffer_insert(out, 0, m_own_pub_key); buffer_insert(out, 0 + m_own_pub_key.size(), ciphertext); buffer_insert(out, 0 + m_own_pub_key.size() + ciphertext.size(), tag); @@ -140,8 +140,8 @@ DLIES_Decryptor::DLIES_Decryptor(const DH_PrivateKey& own_priv_key, DLIES_Decryptor(own_priv_key, rng, kdf, nullptr, 0, mac, mac_key_length) {} -secure_vector<byte> DLIES_Decryptor::do_decrypt(byte& valid_mask, - const byte msg[], size_t length) const +secure_vector<uint8_t> DLIES_Decryptor::do_decrypt(uint8_t& valid_mask, + const uint8_t msg[], size_t length) const { if(length < m_pub_key_size + m_mac->output_length()) { @@ -149,7 +149,7 @@ secure_vector<byte> DLIES_Decryptor::do_decrypt(byte& valid_mask, } // calculate secret value - std::vector<byte> other_pub_key(msg, msg + m_pub_key_size); + std::vector<uint8_t> other_pub_key(msg, msg + m_pub_key_size); const SymmetricKey secret_value = m_ka.derive_key(0, other_pub_key); const size_t ciphertext_len = length - m_pub_key_size - m_mac->output_length(); @@ -157,24 +157,24 @@ secure_vector<byte> DLIES_Decryptor::do_decrypt(byte& valid_mask, // derive secret key from secret value const size_t required_key_length = cipher_key_len + m_mac_keylen; - secure_vector<byte> secret_keys = m_kdf->derive_key(required_key_length, secret_value.bits_of()); + secure_vector<uint8_t> secret_keys = m_kdf->derive_key(required_key_length, secret_value.bits_of()); if(secret_keys.size() != required_key_length) { throw Encoding_Error("DLIES: KDF did not provide sufficient output"); } - secure_vector<byte> ciphertext(msg + m_pub_key_size, msg + m_pub_key_size + ciphertext_len); + secure_vector<uint8_t> ciphertext(msg + m_pub_key_size, msg + m_pub_key_size + ciphertext_len); // calculate MAC m_mac->set_key(secret_keys.data() + cipher_key_len, m_mac_keylen); - secure_vector<byte> calculated_tag = m_mac->process(ciphertext); + secure_vector<uint8_t> calculated_tag = m_mac->process(ciphertext); // calculated tag == received tag ? - secure_vector<byte> tag(msg + m_pub_key_size + ciphertext_len, + secure_vector<uint8_t> tag(msg + m_pub_key_size + ciphertext_len, msg + m_pub_key_size + ciphertext_len + m_mac->output_length()); - valid_mask = CT::expand_mask<byte>(same_mem(tag.data(), calculated_tag.data(), tag.size())); + valid_mask = CT::expand_mask<uint8_t>(same_mem(tag.data(), calculated_tag.data(), tag.size())); // decrypt if(m_cipher) @@ -204,7 +204,7 @@ secure_vector<byte> DLIES_Decryptor::do_decrypt(byte& valid_mask, } else { - return secure_vector<byte>(); + return secure_vector<uint8_t>(); } } else |