projects
/
tinc
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
3c90be7
)
Reinitialise block cipher IV each time we encrypt a packet when using libgcrypt.
author
Guus Sliepen
<guus@tinc-vpn.org>
Sat, 19 Dec 2009 19:10:38 +0000
(20:10 +0100)
committer
Guus Sliepen
<guus@tinc-vpn.org>
Sat, 19 Dec 2009 19:10:38 +0000
(20:10 +0100)
src/gcrypt/cipher.c
patch
|
blob
|
history
diff --git
a/src/gcrypt/cipher.c
b/src/gcrypt/cipher.c
index
390959c
..
ad2a950
100644
(file)
--- a/
src/gcrypt/cipher.c
+++ b/
src/gcrypt/cipher.c
@@
-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))) {
logger(LOG_ERR, "Error while encrypting: %s", gcry_strerror(err));
return false;
if((err = gcry_cipher_encrypt(cipher->handle, outdata, *outlen, indata, inlen))) {
logger(LOG_ERR, "Error while encrypting: %s", gcry_strerror(err));
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) {
gcry_error_t err;
bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) {
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))) {
logger(LOG_ERR, "Error while decrypting: %s", gcry_strerror(err));
return false;
if((err = gcry_cipher_decrypt(cipher->handle, outdata, *outlen, indata, inlen))) {
logger(LOG_ERR, "Error while decrypting: %s", gcry_strerror(err));
return false;