To the best of my knowledge OpenSSL's function FIPS_mode_set
should not affect encryption. All it does is terminating the program if a weak cipher is used.
I have a piece of code that uses EVP_aes_128
encryption:
EVP_CIPHER_CTX ctx;// = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_init(&ctx);
const EVP_CIPHER *cipher = EVP_aes_128_cbc();
EVP_EncryptInit(&ctx, cipher, key, IV);
EVP_CIPHER_CTX_set_padding (&ctx, 0);
EVP_EncryptUpdate(&ctx, encrypted.get(), &encrypted_size, paddedPlain.get(), encrypted_size);
return encrypted;
This code is consistent (I get the same output on every run) and working always as expected (decryption function is decrypting it back with no problems). But when I call FIPS_mode_set
(1) on the beginning of the run, I get an inconsistent (different output on every run) output in the output buffer.
the encryption output without 'FIPS_mode_set'(1):
the encryption output with 'FIPS_mode_set'(1):
I'm using OpenSSL version 1.0.2k.
What could possibly cause such behavior?