X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fopenssl%2Fcipher.c;h=5172d82e69b81c3cd439f8d48b263e4b44345f55;hp=b01f5267c04c17456f16f55646b95d18a2758906;hb=9b2eaebdf6eb46321403bfc6af1145d051d3bbdc;hpb=0da07280882253b792ddf9c6bd8b6690ba585b7a diff --git a/src/openssl/cipher.c b/src/openssl/cipher.c index b01f5267..5172d82e 100644 --- a/src/openssl/cipher.c +++ b/src/openssl/cipher.c @@ -160,7 +160,7 @@ bool cipher_gcm_encrypt_start(cipher_t *cipher, const void *indata, size_t inlen bool cipher_gcm_encrypt_finish(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen) { int len = 0, pad = 0; - if(!(inlen && EVP_EncryptUpdate(&cipher->ctx, (unsigned char *)outdata, &len, (unsigned char *)indata, inlen)) + if((inlen && !EVP_EncryptUpdate(&cipher->ctx, (unsigned char *)outdata, &len, (unsigned char *)indata, inlen)) || !EVP_EncryptFinal(&cipher->ctx, (unsigned char *)outdata + len, &pad)) { logger(DEBUG_ALWAYS, LOG_ERR, "Error while encrypting: %s", ERR_error_string(ERR_get_error(), NULL)); return false;