projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix CTR mode.
[tinc]
/
src
/
openssl
/
cipher.c
diff --git
a/src/openssl/cipher.c
b/src/openssl/cipher.c
index
7f73cb1
..
5d9bebc
100644
(file)
--- a/
src/openssl/cipher.c
+++ b/
src/openssl/cipher.c
@@
-81,6
+81,9
@@
void cipher_close(cipher_t *cipher) {
}
size_t cipher_keylength(const cipher_t *cipher) {
}
size_t cipher_keylength(const cipher_t *cipher) {
+ if(!cipher || !cipher->cipher)
+ return 0;
+
return cipher->cipher->key_len + cipher->cipher->block_size;
}
return cipher->cipher->key_len + cipher->cipher->block_size;
}
@@
-168,7
+171,7
@@
bool cipher_counter_xor(cipher_t *cipher, const void *indata, size_t inlen, void
break;
}
break;
}
- *out++ = *in++ ^ cipher->counter->
counter
[cipher->counter->n++];
+ *out++ = *in++ ^ cipher->counter->
block
[cipher->counter->n++];
if(cipher->counter->n >= cipher->cipher->block_size)
cipher->counter->n = 0;
if(cipher->counter->n >= cipher->cipher->block_size)
cipher->counter->n = 0;
@@
-221,7
+224,10
@@
bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *ou
}
int cipher_get_nid(const cipher_t *cipher) {
}
int cipher_get_nid(const cipher_t *cipher) {
- return cipher->cipher ? cipher->cipher->nid : 0;
+ if(!cipher || !cipher->cipher)
+ return 0;
+
+ return cipher->cipher->nid;
}
bool cipher_active(const cipher_t *cipher) {
}
bool cipher_active(const cipher_t *cipher) {