diff options
author | Andreas Nilsson <andreas.nilsson@10gen.com> | 2015-04-16 11:27:13 -0400 |
---|---|---|
committer | Andreas Nilsson <andreas.nilsson@10gen.com> | 2015-04-16 11:58:17 -0400 |
commit | caa254d914c7ef76b7d0ae2d46402ee2de5ef20a (patch) | |
tree | 4a5f699cac2291117e064737c8b9fe5742acf21b /src/mongo/crypto | |
parent | 7d85928481c882ef9061207020dc225d24d6c2ad (diff) | |
download | mongo-caa254d914c7ef76b7d0ae2d46402ee2de5ef20a.tar.gz |
SERVER-18051 Fix OpenSSL FIPS error when using SCRAM-SHA1
(cherry picked from commit 9958e1ec89110e2dabfd1d7f05a3edcd0ef37d76)
Diffstat (limited to 'src/mongo/crypto')
-rw-r--r-- | src/mongo/crypto/crypto_openssl.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mongo/crypto/crypto_openssl.cpp b/src/mongo/crypto/crypto_openssl.cpp index 576adf9d54e..442ab75518f 100644 --- a/src/mongo/crypto/crypto_openssl.cpp +++ b/src/mongo/crypto/crypto_openssl.cpp @@ -26,6 +26,10 @@ * it in the license file. */ +#include "mongo/platform/basic.h" + +#include "mongo/util/scopeguard.h" + #ifndef MONGO_SSL #error This file should only be included in SSL-enabled builds #endif @@ -44,7 +48,19 @@ namespace crypto { bool sha1(const unsigned char* input, const size_t inputLen, unsigned char* output) { - return SHA1(input, inputLen, output); + + EVP_MD_CTX digestCtx; + EVP_MD_CTX_init(&digestCtx); + + if (1 != EVP_DigestInit_ex(&digestCtx, EVP_sha1(), NULL)) { + return false; + } + + if (1 != EVP_DigestUpdate(&digestCtx, input, inputLen)) { + return false; + } + + return (1 == EVP_DigestFinal_ex(&digestCtx, output, NULL)); } /* |