From 7ef88b174c5e664aa5a310ed0b76694bb82acc7d Mon Sep 17 00:00:00 2001 From: Max Lv Date: Fri, 3 Feb 2017 07:52:26 +0800 Subject: [PATCH] Fix #1154 --- src/stream.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/stream.c b/src/stream.c index 9e399709..ee82f69f 100644 --- a/src/stream.c +++ b/src/stream.c @@ -271,7 +271,7 @@ cipher_ctx_set_nonce(cipher_ctx_t *cipher_ctx, uint8_t *nonce, size_t nonce_len, if (cipher->method == RC4_MD5) { unsigned char key_nonce[32]; memcpy(key_nonce, cipher->key, 16); - memcpy(key_nonce + 16, cipher_ctx->nonce, 16); + memcpy(key_nonce + 16, nonce, 16); true_key = crypto_md5(key_nonce, 32, NULL); nonce_len = 0; } else { @@ -298,6 +298,7 @@ cipher_ctx_set_nonce(cipher_ctx_t *cipher_ctx, uint8_t *nonce, size_t nonce_len, #ifdef DEBUG dump("NONCE", (char *)nonce, nonce_len); + dump("KEY", (char *)true_key, 32); #endif } @@ -350,6 +351,7 @@ stream_encrypt_all(buffer_t *plaintext, cipher_t *cipher, size_t capacity) #ifdef DEBUG dump("PLAIN", plaintext->data, plaintext->len); dump("CIPHER", ciphertext->data + nonce_len, ciphertext->len); + dump("NONCE", ciphertext->data, nonce_len); #endif stream_ctx_release(&cipher_ctx); @@ -471,6 +473,7 @@ stream_decrypt_all(buffer_t *ciphertext, cipher_t *cipher, size_t capacity) #ifdef DEBUG dump("PLAIN", plaintext->data, plaintext->len); dump("CIPHER", ciphertext->data + nonce_len, ciphertext->len - nonce_len); + dump("NONCE", ciphertext->data, nonce_len); #endif stream_ctx_release(&cipher_ctx);