summaryrefslogtreecommitdiff
path: root/src/mongo/crypto
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2016-05-28 17:55:12 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2016-05-28 17:55:12 -0400
commit6dcdd23dd37ef12c87e71cf59ef01cd82432efe0 (patch)
treec8cfb5acb62c80f375bc37e7d4350382deea6a37 /src/mongo/crypto
parentd4ac5673ea3f6cef4ce9dbcec90e31813997a528 (diff)
downloadmongo-6dcdd23dd37ef12c87e71cf59ef01cd82432efe0.tar.gz
SERVER-23971 Clang-Format code
Diffstat (limited to 'src/mongo/crypto')
-rw-r--r--src/mongo/crypto/crypto_openssl.cpp2
-rw-r--r--src/mongo/crypto/crypto_test.cpp456
-rw-r--r--src/mongo/crypto/mechanism_scram.cpp6
-rw-r--r--src/mongo/crypto/tom/tomcrypt.h6
-rw-r--r--src/mongo/crypto/tom/tomcrypt_cfg.h6
5 files changed, 48 insertions, 428 deletions
diff --git a/src/mongo/crypto/crypto_openssl.cpp b/src/mongo/crypto/crypto_openssl.cpp
index 4dc1e5d02c4..ca6844acb9e 100644
--- a/src/mongo/crypto/crypto_openssl.cpp
+++ b/src/mongo/crypto/crypto_openssl.cpp
@@ -35,9 +35,9 @@
#error This file should only be included in SSL-enabled builds
#endif
-#include <openssl/sha.h>
#include <openssl/evp.h>
#include <openssl/hmac.h>
+#include <openssl/sha.h>
namespace mongo {
namespace crypto {
diff --git a/src/mongo/crypto/crypto_test.cpp b/src/mongo/crypto/crypto_test.cpp
index 52d488b92cf..b3a1a6badb7 100644
--- a/src/mongo/crypto/crypto_test.cpp
+++ b/src/mongo/crypto/crypto_test.cpp
@@ -37,49 +37,12 @@ const int digestLen = 20;
const struct {
const char* msg;
unsigned char hash[digestLen];
-} sha1Tests[] = {{"abc",
- {0xa9,
- 0x99,
- 0x3e,
- 0x36,
- 0x47,
- 0x06,
- 0x81,
- 0x6a,
- 0xba,
- 0x3e,
- 0x25,
- 0x71,
- 0x78,
- 0x50,
- 0xc2,
- 0x6c,
- 0x9c,
- 0xd0,
- 0xd8,
- 0x9d}},
+} sha1Tests[] = {{"abc", {0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e,
+ 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d}},
{"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- {0x84,
- 0x98,
- 0x3E,
- 0x44,
- 0x1C,
- 0x3B,
- 0xD2,
- 0x6E,
- 0xBA,
- 0xAE,
- 0x4A,
- 0xA1,
- 0xF9,
- 0x51,
- 0x29,
- 0xE5,
- 0xE5,
- 0x46,
- 0x70,
- 0xF1}}};
+ {0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE,
+ 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1}}};
TEST(CryptoVectors, SHA1) {
unsigned char sha1Result[digestLen];
@@ -105,400 +68,53 @@ const struct {
unsigned char hash[digestLen];
} hmacSha1Tests[] = {
// RFC test case 1
- {{0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b,
- 0x0b},
+ {{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b},
20,
{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65},
8,
- {0xb6,
- 0x17,
- 0x31,
- 0x86,
- 0x55,
- 0x05,
- 0x72,
- 0x64,
- 0xe2,
- 0x8b,
- 0xc0,
- 0x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20,
- 0x42,
- 0x6c,
- 0x6f,
- 0x63,
- 0x6b,
- 0x2d,
- 0x53,
- 0x69,
- 0x7a,
- 0x65,
- 0x20,
- 0x4b,
- 0x65,
- 0x79,
- 0x20,
- 0x2d,
- 0x20,
- 0x48,
- 0x61,
- 0x73,
- 0x68,
- 0x20,
- 0x4b,
- 0x65,
- 0x79,
- 0x20,
- 0x46,
- 0x69,
- 0x72,
- 0x73,
- 0x74},
+ {0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x4c, 0x61, 0x72,
+ 0x67, 0x65, 0x72, 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x42, 0x6c, 0x6f, 0x63, 0x6b,
+ 0x2d, 0x53, 0x69, 0x7a, 0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x2d, 0x20, 0x48, 0x61,
+ 0x73, 0x68, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x46, 0x69, 0x72, 0x73, 0x74},
54,
- {0xaa,
- 0x4a,
- 0xe5,
- 0xe1,
- 0x52,
- 0x72,
- 0xd0,
- 0x0e,
- 0x95,
- 0x70,
- 0x56,
- 0x37,
- 0xce,
- 0x8a,
- 0x3b,
- 0x55,
- 0xed,
- 0x40,
- 0x21,
- 0x12}}};
+ {0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e, 0x95, 0x70,
+ 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55, 0xed, 0x40, 0x21, 0x12}}};
TEST(CryptoVectors, HMACSHA1) {
unsigned char hmacSha1Result[digestLen];
diff --git a/src/mongo/crypto/mechanism_scram.cpp b/src/mongo/crypto/mechanism_scram.cpp
index 086e9943c4c..329da56c9f8 100644
--- a/src/mongo/crypto/mechanism_scram.cpp
+++ b/src/mongo/crypto/mechanism_scram.cpp
@@ -156,8 +156,10 @@ BSONObj generateCredentials(const std::string& hashedPassword, int iterationCoun
std::string encodedServerKey = base64::encode(reinterpret_cast<char*>(serverKey), hashSize);
return BSON(iterationCountFieldName << iterationCount << saltFieldName << encodedUserSalt
- << storedKeyFieldName << encodedStoredKey
- << serverKeyFieldName << encodedServerKey);
+ << storedKeyFieldName
+ << encodedStoredKey
+ << serverKeyFieldName
+ << encodedServerKey);
}
std::string generateClientProof(const unsigned char saltedPassword[hashSize],
diff --git a/src/mongo/crypto/tom/tomcrypt.h b/src/mongo/crypto/tom/tomcrypt.h
index f707cbef616..aa4d5c02df5 100644
--- a/src/mongo/crypto/tom/tomcrypt.h
+++ b/src/mongo/crypto/tom/tomcrypt.h
@@ -16,12 +16,12 @@
#ifndef TOMCRYPT_H_
#define TOMCRYPT_H_
#include <assert.h>
+#include <ctype.h>
+#include <limits.h>
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include <time.h>
-#include <ctype.h>
-#include <limits.h>
/* use configuration data */
#include "tomcrypt_custom.h"
diff --git a/src/mongo/crypto/tom/tomcrypt_cfg.h b/src/mongo/crypto/tom/tomcrypt_cfg.h
index c599bab88ca..37dc04780d9 100644
--- a/src/mongo/crypto/tom/tomcrypt_cfg.h
+++ b/src/mongo/crypto/tom/tomcrypt_cfg.h
@@ -43,8 +43,10 @@ LTC_EXPORT void* LTC_CALL XREALLOC(void* p, size_t n);
LTC_EXPORT void* LTC_CALL XCALLOC(size_t n, size_t s);
LTC_EXPORT void LTC_CALL XFREE(void* p);
-LTC_EXPORT void LTC_CALL
-XQSORT(void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*));
+LTC_EXPORT void LTC_CALL XQSORT(void* base,
+ size_t nmemb,
+ size_t size,
+ int (*compar)(const void*, const void*));
/* change the clock function too */