Don't ASSERT() on stream cipher
PATCH 1/1 Don't ASSERT() on stream cipher
From: Vladimir I. Kobylyanskiy <[email protected]...>
We (Ltd. LISSI, http://www.lissi.ru, info at lissi.ru), are trying to use OpenVPN with stream ciphers, including Russian cipher GOST 28147-89(ALLOW_NON_CBC_CIPHERS flag is set).
And we found the bug:
function EVP_CipherFinal() returns 0, when cipher has block_size == 1(stream cipher). So hear is the patch to fix the bug.
sf.net tracker:
<https://sourceforge.net/tracker/?func=detail&aid=1552062&group_id=48978&atid=454721>
--- crypto.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
crypto.c +2 -1
@@ -159,7 +159,8 @@ openvpn_encrypt (struct buffer *buf, struct buffer work,/* Flush the encryption buffer */ ASSERT (EVP_CipherFinal (ctx->cipher,BPTR (&work) + outlen, &outlen)); work.len += outlen; -ASSERT (outlen == iv_size); +if (mode ==EVP_CIPH_CBC_MODE ) +ASSERT (outlen == iv_size);/* prepend the IV to the ciphertext */ if (opt->flags &CO_USE_IV )
Signature · 1 line
1.6.6.1
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 15 lines · David Sommerseth
From: Vladimir I. Kobylyanskiy <[email protected]...>
We (Ltd. LISSI, http://www.lissi.ru, info at lissi.ru), are trying to use OpenVPN with stream ciphers, including Russian cipher GOST 28147-89(ALLOW_NON_CBC_CIPHERS flag is set).
And we found the bug:
functionEVP_CipherFinal()returns 0, when cipher hasblock_size== 1(stream cipher). So hear is the patch to fix the bug.sf.net tracker:
<https://sourceforge.net/tracker/?func=detail&aid=1552062&group_id=48978&atid=454721>
[...snip...]
crypto.c openvpn_encrypt (struct buffer *buf, struct buffer work, · line 163
Quoted 2 lines
crypto.c +2
-0+if (mode ==EVP_CIPH_CBC_MODE ) +ASSERT (outlen == iv_size);
Could someone please reassure that this is the right way how to solve this issue? This new if statement seems to me to be too invasive. The different cipher modes I found references to are:
#define EVP_CIPH_STREAM_CIPHER 0x0 #define EVP_CIPH_ECB_MODE 0x1 #define EVP_CIPH_CBC_MODE 0x2 #define EVP_CIPH_CFB_MODE 0x3 #define EVP_CIPH_OFB_MODE 0x4 #define EVP_CIPH_MODE 0x7
(Extracts from /usr/include/openssl/evp.h)
I'm not a crypto expert, but for me this change seems to skip the ASSERT() check on too many EVP_CIPH_*_MODEs. On cipher modes supporting streams, that probably need to be skipped.
Any objections or clarifications are highly appreciated.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkuWYWgACgkQDC186MBRfroc9QCbBhd+ZImYE8MO557HPXBdnWMM p/IAn1RlDN7WuKfYpmPkOIiTtH4zZ5Gv
=KX7E
-----END PGP SIGNATURE-----