Cipher problem on Mac OS X
Hi,
I'm sorry for cross-posting, this perhaps should have gone to -devel instead of -users in the first place.
I have a problem running OpenVPN from the git master branch on Mac OS X (checkout 3a90edbd194140eef51c245edfcf9afc0ecb2d13). (It runs fine on FreeBSD). There seems to be a problem with the default Blowfish (BF-CBC) cipher:
% git clone git://openvpn.git.sourceforge.net/gitroot/openvpn/openvpn.git
% cd openvpn
% autoreconf -i -v
% ./configure --with-lzo-headers=/opt/local/include \
--with-lzo-lib=/opt/local/lib
% make
% make check
...
Sat Feb 11 22:46:37 2012 OpenVPN 2.x-master x86_64-apple-darwin11.2.0 [SSL (OpenSSL)] [LZO2] [eurephia] [MH] [PF_INET6] [IPv6 payload 20110522-1 (2.2.0)] built on Feb 11 2012
Sat Feb 11 22:46:37 2012 Cipher 'BF-CBC' uses a mode not supported by OpenVPN in your current configuration. CBC mode is always supported, while CFB and OFB modes are supported only when using SSL/TLS authentication and key exchange mode, and when OpenVPN has been built with ALLOW_NON_CBC_CIPHERS.
Sat Feb 11 22:46:37 2012 Exiting due to fatal error
FAIL: t_lpback.sh
...
On the other hand, BF-CBC cipher seem normally compiled in:
% /usr/local/sbin/openvpn --show-ciphers
...
BF-CBC 128 bit default key (variable)
...
openvpn is compiled with openssl 1.0.0f.
From otool -l:
name /opt/local/lib/libssl.1.0.0.dylib (offset 24)
name /opt/local/lib/libcrypto.1.0.0.dylib (offset 24)
name /opt/local/lib/liblzo2.2.dylib (offset 24)
name /usr/lib/libSystem.B.dylib (offset 24)I just tried to see if this error was always there. It seems to be introduced with the refactoring by Adriaan de Jong last year.
Revision e8c950f12dfd6187f084fb06b6fe6e57c030bdad works fine Revision 670f9dd91aed7ac435b79c0e28e49fa7c256642c fails with the above error.
Revision 670f9dd91aed7ac435b79c0e28e49fa7c256642c has the following log message:
Refactored cipher key types
Is the above intended behaviour or a bug?
Any advise how to further dissect this?
Regards,
Freek Dijkstra
Quoted 4 lines
-----Original Message-----
From: Freek Dijkstra [mailto:[email protected]...]Hi,
Hi Freek,
Sorry for the delay, but I've had some trouble replicating the bug.
Quoted 6 lines
Sat Feb 11 22:46:37 2012 OpenVPN 2.x-master x86_64-apple-darwin11.2.0 [SSL (OpenSSL)] [LZO2] [eurephia] [MH] [
PF_INET6] [IPv6 payload 20110522-1 (2.2.0)] built on Feb 11 2012 Sat Feb 11 22:46:37 2012 Cipher 'BF-CBC' uses a mode not supported by OpenVPN in your current
...
I've tried to replicate the bug on Linux and have been unsuccessful so far. Thankfully a colleague managed to replicate it on a Mac using the stock OpenSSL (v0.9.8.something). I think it's related to the value returned by EVP_cipher_mode(). Unfortunately I don't have direct access to a mac, so could you try compiling and running the following code, please?
--- SNIP ---
#include <stdio.h>
#include <openssl/evp.h>
int main()
{
OpenSSL_add_all_algorithms();
const EVP_CIPHER *ciph = EVP_get_cipherbyname ("BF-CBC");
printf("%p\n", ciph);
printf ("EVP_CIPH_CBC_MODE: %u\n", EVP_CIPH_CBC_MODE);
printf ("Function: %lu\n", EVP_CIPHER_mode (ciph));
return 0;
}--- SNIP ---
The commands would be:
$ gcc <sourcefile.c> -lssl $ ./a.out
Thanks,
Adriaan de Jong
Hi Adriaan,
Thanks a lot for your efforts!
Quoted 16 lines
--- SNIP ---
#include <stdio.h>
#include <openssl/evp.h>int
main(){ OpenSSL_add_all_algorithms(); const EVP_CIPHER *ciph = EVP_get_cipherbyname ("BF-CBC"); printf("%p\n", ciph); printf ("EVP_CIPH_CBC_MODE: %u\n", EVP_CIPH_CBC_MODE); printf ("Function: %lu\n", EVP_CIPHER_mode (ciph)); return 0; }
Quoted 6 lines
--- SNIP ---
The commands would be:
$ gcc <sourcefile.c> -lssl $ ./a.out
I added -lcrypto as well:
% gcc -L/opt/local/lib -I/opt/local/include -lssl -lcrypt sourcefile.c % ./a.out0x100e37d60EVP_CIPH_CBC_MODE: 2
Function: 2
FYI, this is with Openssl 1.0.0f (installed with MacPorts, a package maanger for Mac OS X).
The result with OpenSSL 0.9.8r (that came with Mac OS X) is:
% gcc -L/usr/lib -I/usr/include -lssl -lcrypto sourcefile.c sourcefile.c: In function ‘main’:
sourcefile.c:6: warning: ‘OPENSSL_add_all_algorithms_noconf’ is deprecated (declared at /usr/include/openssl/evp.h:828) sourcefile.c:8: warning: ‘EVP_get_cipherbyname’ is deprecated (declared at /usr/include/openssl/evp.h:848)
sourcefile.c:12: warning: ‘EVP_CIPHER_flags’ is deprecated (declared at /usr/include/openssl/evp.h:496)
% ./a.out0x7fff75d9d000EVP_CIPH_CBC_MODE: 2
Function: 2
Quoted 1 line
Unfortunately I don't have direct access to a mac
If required, I may be able to get you access next weekend.
Freek