Skip to content

Commit

Permalink
crypto: remove legacy decrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien Béraud committed Mar 24, 2024
1 parent c8b5611 commit acde8fa
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ static std::uniform_int_distribution<int> rand_byte{ 0, std::numeric_limits<uint
static std::uniform_int_distribution<uint8_t> rand_byte;
#endif

#define DHT_AES_LEGACY_DECRYPT 1

namespace dht {
namespace crypto {

Expand Down Expand Up @@ -130,21 +128,7 @@ Blob aesDecrypt(const uint8_t* data, size_t data_length, const Blob& key)
gcm_aes_digest(&aes, GCM_DIGEST_SIZE, digest.data());

if (not std::equal(digest.begin(), digest.end(), data + data_length - GCM_DIGEST_SIZE)) {
#if DHT_AES_LEGACY_DECRYPT
//gcm_aes_decrypt(&aes, data_sz, ret.data(), data + GCM_IV_SIZE);
Blob ret_tmp(data_sz);
struct gcm_aes_ctx aes_d;
gcm_aes_set_key(&aes_d, key.size(), key.data());
gcm_aes_set_iv(&aes_d, GCM_IV_SIZE, data);
gcm_aes_update(&aes_d, ret.size(), ret.data());
gcm_aes_encrypt(&aes_d, ret.size(), ret_tmp.data(), ret.data());
gcm_aes_digest(&aes_d, GCM_DIGEST_SIZE, digest.data());

if (not std::equal(digest.begin(), digest.end(), data + data_length - GCM_DIGEST_SIZE))
throw DecryptError("Can't decrypt data");
#else
throw DecryptError("Can't decrypt data");
#endif
}

return ret;
Expand Down

0 comments on commit acde8fa

Please sign in to comment.