user3548990
user3548990

Reputation: 1

Can't get OpenSSL to run on Windows (same code works fine on Linux)

I recently wrote a desktop app for Linux(VirtualBox) that employs openSSL. I’m just using the libraries for encrypting and decrypting files (no network) and it works great. Now, I’m trying to create a Windows version and it’s one of the most frustrating things I’ve ever done.

The online community hasn’t been much help (dozens of proposed solutions, all completely different, and none of them work for me).

Specifics:

The app compiles and runs, but when I get to this line:

EVP_EncryptInit(&ctxE, EVP_aes_256_cbc(), constKey, constIv);

It crashes with a segmentation fault.

This has been a nightmarish goose chase. Any help will be greatly appreciated. Thanks.

Upvotes: 0

Views: 504

Answers (1)

jariq
jariq

Reputation: 12108

You did not post any code so I can only guess but if your program is working fine on Linux and exactly the same code segfaults on Windows then you should look at these most common problems:

  • Your application must link against the same version of the C runtime libraries against which your openssl was linked and/or you need to include OpenSSL_Applink. There is also a FAQ entry about this topic: I've compiled a program under Windows and it crashes: why?
  • 64-bit Windows and 64-bit Linux are two different platforms and as such they require proper handling in your C/C++ code i.e. long takes 8 bytes on 64-bit Linux but only 4 bytes on 64-bit Windows so one bad malloc without the sizeof(long) can cause a serious problem etc.

Upvotes: 2

Related Questions