Commit 1fd03592 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Apply clang-format to folly/ssl/

Summary: [Folly] Apply `clang-format` to `folly/ssl/`.

Reviewed By: Orvid

Differential Revision: D5366760

fbshipit-source-id: ad4ec0570050f80d69c78626906e18b5892a999f
parent d34ef77f
...@@ -31,6 +31,5 @@ namespace ssl { ...@@ -31,6 +31,5 @@ namespace ssl {
[[noreturn]] void OpenSSLHash::check_libssl_result_throw() { [[noreturn]] void OpenSSLHash::check_libssl_result_throw() {
throw std::runtime_error("openssl crypto function failed"); throw std::runtime_error("openssl crypto function failed");
} }
} }
} }
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include <folly/Range.h> #include <folly/Range.h>
#include <folly/io/IOBuf.h> #include <folly/io/IOBuf.h>
#include <folly/ssl/OpenSSLPtrTypes.h>
#include <folly/portability/OpenSSL.h> #include <folly/portability/OpenSSL.h>
#include <folly/ssl/OpenSSLPtrTypes.h>
namespace folly { namespace folly {
namespace ssl { namespace ssl {
...@@ -28,7 +28,6 @@ namespace ssl { ...@@ -28,7 +28,6 @@ namespace ssl {
/// These functions are not thread-safe unless you initialize OpenSSL. /// These functions are not thread-safe unless you initialize OpenSSL.
class OpenSSLHash { class OpenSSLHash {
public: public:
class Digest { class Digest {
public: public:
Digest() : ctx_(EVP_MD_CTX_new()) {} Digest() : ctx_(EVP_MD_CTX_new()) {}
...@@ -74,19 +73,13 @@ class OpenSSLHash { ...@@ -74,19 +73,13 @@ class OpenSSLHash {
EvpMdCtxUniquePtr ctx_{nullptr}; EvpMdCtxUniquePtr ctx_{nullptr};
}; };
static void hash( static void hash(MutableByteRange out, const EVP_MD* md, ByteRange data) {
MutableByteRange out,
const EVP_MD* md,
ByteRange data) {
Digest hash; Digest hash;
hash.hash_init(md); hash.hash_init(md);
hash.hash_update(data); hash.hash_update(data);
hash.hash_final(out); hash.hash_final(out);
} }
static void hash( static void hash(MutableByteRange out, const EVP_MD* md, const IOBuf& data) {
MutableByteRange out,
const EVP_MD* md,
const IOBuf& data) {
Digest hash; Digest hash;
hash.hash_init(md); hash.hash_init(md);
hash.hash_update(data); hash.hash_update(data);
...@@ -131,16 +124,14 @@ class OpenSSLHash { ...@@ -131,16 +124,14 @@ class OpenSSLHash {
check_libssl_result(size, int(len)); check_libssl_result(size, int(len));
md_ = nullptr; md_ = nullptr;
} }
private: private:
const EVP_MD* md_ = nullptr; const EVP_MD* md_ = nullptr;
HmacCtxUniquePtr ctx_{nullptr}; HmacCtxUniquePtr ctx_{nullptr};
}; };
static void hmac( static void
MutableByteRange out, hmac(MutableByteRange out, const EVP_MD* md, ByteRange key, ByteRange data) {
const EVP_MD* md,
ByteRange key,
ByteRange data) {
Hmac hmac; Hmac hmac;
hmac.hash_init(md, key); hmac.hash_init(md, key);
hmac.hash_update(data); hmac.hash_update(data);
...@@ -156,20 +147,18 @@ class OpenSSLHash { ...@@ -156,20 +147,18 @@ class OpenSSLHash {
hmac.hash_update(data); hmac.hash_update(data);
hmac.hash_final(out); hmac.hash_final(out);
} }
static void hmac_sha1( static void hmac_sha1(MutableByteRange out, ByteRange key, ByteRange data) {
MutableByteRange out, ByteRange key, ByteRange data) {
hmac(out, EVP_sha1(), key, data); hmac(out, EVP_sha1(), key, data);
} }
static void hmac_sha1( static void
MutableByteRange out, ByteRange key, const IOBuf& data) { hmac_sha1(MutableByteRange out, ByteRange key, const IOBuf& data) {
hmac(out, EVP_sha1(), key, data); hmac(out, EVP_sha1(), key, data);
} }
static void hmac_sha256( static void hmac_sha256(MutableByteRange out, ByteRange key, ByteRange data) {
MutableByteRange out, ByteRange key, ByteRange data) {
hmac(out, EVP_sha256(), key, data); hmac(out, EVP_sha256(), key, data);
} }
static void hmac_sha256( static void
MutableByteRange out, ByteRange key, const IOBuf& data) { hmac_sha256(MutableByteRange out, ByteRange key, const IOBuf& data) {
hmac(out, EVP_sha256(), key, data); hmac(out, EVP_sha256(), key, data);
} }
...@@ -192,6 +181,5 @@ class OpenSSLHash { ...@@ -192,6 +181,5 @@ class OpenSSLHash {
} }
[[noreturn]] static void check_libssl_result_throw(); [[noreturn]] static void check_libssl_result_throw();
}; };
} }
} }
...@@ -71,7 +71,9 @@ using BioDeleter = folly::static_function_deleter<BIO, &BIO_vfree>; ...@@ -71,7 +71,9 @@ using BioDeleter = folly::static_function_deleter<BIO, &BIO_vfree>;
using BioUniquePtr = std::unique_ptr<BIO, BioDeleter>; using BioUniquePtr = std::unique_ptr<BIO, BioDeleter>;
using BioChainDeleter = folly::static_function_deleter<BIO, &BIO_free_all>; using BioChainDeleter = folly::static_function_deleter<BIO, &BIO_free_all>;
using BioChainUniquePtr = std::unique_ptr<BIO, BioChainDeleter>; using BioChainUniquePtr = std::unique_ptr<BIO, BioChainDeleter>;
inline void BIO_free_fb(BIO* bio) { CHECK_EQ(1, BIO_free(bio)); } inline void BIO_free_fb(BIO* bio) {
CHECK_EQ(1, BIO_free(bio));
}
using BioDeleterFb = folly::static_function_deleter<BIO, &BIO_free_fb>; using BioDeleterFb = folly::static_function_deleter<BIO, &BIO_free_fb>;
using BioUniquePtrFb = std::unique_ptr<BIO, BioDeleterFb>; using BioUniquePtrFb = std::unique_ptr<BIO, BioDeleterFb>;
......
...@@ -26,7 +26,6 @@ using namespace folly::ssl; ...@@ -26,7 +26,6 @@ using namespace folly::ssl;
namespace { namespace {
class OpenSSLHashTest : public testing::Test {}; class OpenSSLHashTest : public testing::Test {};
} }
TEST_F(OpenSSLHashTest, sha256) { TEST_F(OpenSSLHashTest, sha256) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment