Reinitialise block cipher IV each time we encrypt a packet when using libgcrypt.
This commit is contained in:
parent
3c90be7678
commit
0ff44fc241
1 changed files with 6 additions and 0 deletions
|
@ -207,6 +207,9 @@ bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *ou
|
||||||
pad[i] = padbyte;
|
pad[i] = padbyte;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(oneshot)
|
||||||
|
gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen);
|
||||||
|
|
||||||
if((err = gcry_cipher_encrypt(cipher->handle, outdata, *outlen, indata, inlen))) {
|
if((err = gcry_cipher_encrypt(cipher->handle, outdata, *outlen, indata, inlen))) {
|
||||||
logger(LOG_ERR, "Error while encrypting: %s", gcry_strerror(err));
|
logger(LOG_ERR, "Error while encrypting: %s", gcry_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
|
@ -228,6 +231,9 @@ bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *ou
|
||||||
bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) {
|
bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) {
|
||||||
gcry_error_t err;
|
gcry_error_t err;
|
||||||
|
|
||||||
|
if(oneshot)
|
||||||
|
gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen);
|
||||||
|
|
||||||
if((err = gcry_cipher_decrypt(cipher->handle, outdata, *outlen, indata, inlen))) {
|
if((err = gcry_cipher_decrypt(cipher->handle, outdata, *outlen, indata, inlen))) {
|
||||||
logger(LOG_ERR, "Error while decrypting: %s", gcry_strerror(err));
|
logger(LOG_ERR, "Error while decrypting: %s", gcry_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue