|
@ -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) { |
|
|
if (cipher->method == RC4_MD5) { |
|
|
unsigned char key_nonce[32]; |
|
|
unsigned char key_nonce[32]; |
|
|
memcpy(key_nonce, cipher->key, 16); |
|
|
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); |
|
|
true_key = crypto_md5(key_nonce, 32, NULL); |
|
|
nonce_len = 0; |
|
|
nonce_len = 0; |
|
|
} else { |
|
|
} else { |
|
@ -298,6 +298,7 @@ cipher_ctx_set_nonce(cipher_ctx_t *cipher_ctx, uint8_t *nonce, size_t nonce_len, |
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
#ifdef DEBUG |
|
|
dump("NONCE", (char *)nonce, nonce_len); |
|
|
dump("NONCE", (char *)nonce, nonce_len); |
|
|
|
|
|
dump("KEY", (char *)true_key, 32); |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -350,6 +351,7 @@ stream_encrypt_all(buffer_t *plaintext, cipher_t *cipher, size_t capacity) |
|
|
#ifdef DEBUG |
|
|
#ifdef DEBUG |
|
|
dump("PLAIN", plaintext->data, plaintext->len); |
|
|
dump("PLAIN", plaintext->data, plaintext->len); |
|
|
dump("CIPHER", ciphertext->data + nonce_len, ciphertext->len); |
|
|
dump("CIPHER", ciphertext->data + nonce_len, ciphertext->len); |
|
|
|
|
|
dump("NONCE", ciphertext->data, nonce_len); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
stream_ctx_release(&cipher_ctx); |
|
|
stream_ctx_release(&cipher_ctx); |
|
@ -471,6 +473,7 @@ stream_decrypt_all(buffer_t *ciphertext, cipher_t *cipher, size_t capacity) |
|
|
#ifdef DEBUG |
|
|
#ifdef DEBUG |
|
|
dump("PLAIN", plaintext->data, plaintext->len); |
|
|
dump("PLAIN", plaintext->data, plaintext->len); |
|
|
dump("CIPHER", ciphertext->data + nonce_len, ciphertext->len - nonce_len); |
|
|
dump("CIPHER", ciphertext->data + nonce_len, ciphertext->len - nonce_len); |
|
|
|
|
|
dump("NONCE", ciphertext->data, nonce_len); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
stream_ctx_release(&cipher_ctx); |
|
|
stream_ctx_release(&cipher_ctx); |
|
|