Skip to content

Commit

Permalink
openssl.c: Avoid OpenSSL latent error in FIPS mode (libssh2#528)
Browse files Browse the repository at this point in the history
File:
openssl.c

Notes:
Avoid initing MD5 digest, which is not permitted in OpenSSL FIPS certified cryptography mode.

Credit:
Marc
  • Loading branch information
MarcT512 authored May 3, 2021
1 parent 3569577 commit b853d7a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2221,6 +2221,13 @@ _libssh2_sha512(const unsigned char *message, unsigned long len,
int
_libssh2_md5_init(libssh2_md5_ctx *ctx)
{
/* MD5 digest is not supported in OpenSSL FIPS mode
* Trying to init it will result in a latent OpenSSL error:
* "digital envelope routines:FIPS_DIGESTINIT:disabled for fips"
* So, just return 0 in FIPS mode
*/
if(FIPS_mode() != 0)
return 0;
#ifdef HAVE_OPAQUE_STRUCTS
*ctx = EVP_MD_CTX_new();

Expand Down

0 comments on commit b853d7a

Please sign in to comment.