Skip to content

Commit acde8fa

Browse files
author
Adrien Béraud
committed
crypto: remove legacy decrypt
1 parent c8b5611 commit acde8fa

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

src/crypto.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ static std::uniform_int_distribution<int> rand_byte{ 0, std::numeric_limits<uint
4343
static std::uniform_int_distribution<uint8_t> rand_byte;
4444
#endif
4545

46-
#define DHT_AES_LEGACY_DECRYPT 1
47-
4846
namespace dht {
4947
namespace crypto {
5048

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

132130
if (not std::equal(digest.begin(), digest.end(), data + data_length - GCM_DIGEST_SIZE)) {
133-
#if DHT_AES_LEGACY_DECRYPT
134-
//gcm_aes_decrypt(&aes, data_sz, ret.data(), data + GCM_IV_SIZE);
135-
Blob ret_tmp(data_sz);
136-
struct gcm_aes_ctx aes_d;
137-
gcm_aes_set_key(&aes_d, key.size(), key.data());
138-
gcm_aes_set_iv(&aes_d, GCM_IV_SIZE, data);
139-
gcm_aes_update(&aes_d, ret.size(), ret.data());
140-
gcm_aes_encrypt(&aes_d, ret.size(), ret_tmp.data(), ret.data());
141-
gcm_aes_digest(&aes_d, GCM_DIGEST_SIZE, digest.data());
142-
143-
if (not std::equal(digest.begin(), digest.end(), data + data_length - GCM_DIGEST_SIZE))
144-
throw DecryptError("Can't decrypt data");
145-
#else
146131
throw DecryptError("Can't decrypt data");
147-
#endif
148132
}
149133

150134
return ret;

0 commit comments

Comments
 (0)