summaryrefslogtreecommitdiff
path: root/src/mongo/crypto/crypto_openssl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/crypto/crypto_openssl.cpp')
-rw-r--r--src/mongo/crypto/crypto_openssl.cpp65
1 files changed, 28 insertions, 37 deletions
diff --git a/src/mongo/crypto/crypto_openssl.cpp b/src/mongo/crypto/crypto_openssl.cpp
index 53e898ae487..4dc1e5d02c4 100644
--- a/src/mongo/crypto/crypto_openssl.cpp
+++ b/src/mongo/crypto/crypto_openssl.cpp
@@ -41,45 +41,36 @@
namespace mongo {
namespace crypto {
- /*
- * Computes a SHA-1 hash of 'input'.
- */
- bool sha1(const unsigned char* input,
- const size_t inputLen,
- unsigned char* output) {
-
- EVP_MD_CTX digestCtx;
- EVP_MD_CTX_init(&digestCtx);
- ON_BLOCK_EXIT(EVP_MD_CTX_cleanup, &digestCtx);
-
- if (1 != EVP_DigestInit_ex(&digestCtx, EVP_sha1(), NULL)) {
- return false;
- }
-
- if (1 != EVP_DigestUpdate(&digestCtx, input, inputLen)) {
- return false;
- }
+/*
+ * Computes a SHA-1 hash of 'input'.
+ */
+bool sha1(const unsigned char* input, const size_t inputLen, unsigned char* output) {
+ EVP_MD_CTX digestCtx;
+ EVP_MD_CTX_init(&digestCtx);
+ ON_BLOCK_EXIT(EVP_MD_CTX_cleanup, &digestCtx);
- return (1 == EVP_DigestFinal_ex(&digestCtx, output, NULL));
+ if (1 != EVP_DigestInit_ex(&digestCtx, EVP_sha1(), NULL)) {
+ return false;
}
- /*
- * Computes a HMAC SHA-1 keyed hash of 'input' using the key 'key'
- */
- bool hmacSha1(const unsigned char* key,
- const size_t keyLen,
- const unsigned char* input,
- const size_t inputLen,
- unsigned char* output,
- unsigned int* outputLen) {
- return HMAC(EVP_sha1(),
- key,
- keyLen,
- input,
- inputLen,
- output,
- outputLen);
+ if (1 != EVP_DigestUpdate(&digestCtx, input, inputLen)) {
+ return false;
}
-} // namespace crypto
-} // namespace mongo
+ return (1 == EVP_DigestFinal_ex(&digestCtx, output, NULL));
+}
+
+/*
+ * Computes a HMAC SHA-1 keyed hash of 'input' using the key 'key'
+ */
+bool hmacSha1(const unsigned char* key,
+ const size_t keyLen,
+ const unsigned char* input,
+ const size_t inputLen,
+ unsigned char* output,
+ unsigned int* outputLen) {
+ return HMAC(EVP_sha1(), key, keyLen, input, inputLen, output, outputLen);
+}
+
+} // namespace crypto
+} // namespace mongo