mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-20 13:03:50 +00:00
Output error log when repeat IV/salt detected
This is useful when checking connection issues, and can be used to check broken random number generator and replay attacks. Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
This commit is contained in:
@@ -635,6 +635,7 @@ aead_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
|
||||
aead_cipher_ctx_set_key(cipher_ctx, 0);
|
||||
|
||||
if (cache_key_exist(nonce_cache, (char *)cipher_ctx->salt, salt_len)) {
|
||||
LOGE("crypto: AEAD: repeat salt detected");
|
||||
bfree(ciphertext);
|
||||
return CRYPTO_ERROR;
|
||||
} else {
|
||||
|
||||
@@ -507,6 +507,7 @@ stream_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
|
||||
|
||||
if (cipher->method >= RC4_MD5) {
|
||||
if (cache_key_exist(nonce_cache, (char *)nonce, nonce_len)) {
|
||||
LOGE("crypto: stream: repeat IV detected");
|
||||
bfree(ciphertext);
|
||||
return -1;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user