From 1fd0359279523a37524c03323428c94a8022c730 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Mon, 3 Jul 2017 20:01:32 -0700 Subject: [PATCH] Apply clang-format to folly/ssl/ Summary: [Folly] Apply `clang-format` to `folly/ssl/`. Reviewed By: Orvid Differential Revision: D5366760 fbshipit-source-id: ad4ec0570050f80d69c78626906e18b5892a999f --- folly/ssl/OpenSSLHash.cpp | 1 - folly/ssl/OpenSSLHash.h | 36 ++++++++++-------------------- folly/ssl/OpenSSLPtrTypes.h | 4 +++- folly/ssl/test/OpenSSLHashTest.cpp | 1 - 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/folly/ssl/OpenSSLHash.cpp b/folly/ssl/OpenSSLHash.cpp index 4c3beee4..cfe886ac 100644 --- a/folly/ssl/OpenSSLHash.cpp +++ b/folly/ssl/OpenSSLHash.cpp @@ -31,6 +31,5 @@ namespace ssl { [[noreturn]] void OpenSSLHash::check_libssl_result_throw() { throw std::runtime_error("openssl crypto function failed"); } - } } diff --git a/folly/ssl/OpenSSLHash.h b/folly/ssl/OpenSSLHash.h index 10e3e561..b783cdc1 100644 --- a/folly/ssl/OpenSSLHash.h +++ b/folly/ssl/OpenSSLHash.h @@ -18,8 +18,8 @@ #include #include -#include #include +#include namespace folly { namespace ssl { @@ -28,7 +28,6 @@ namespace ssl { /// These functions are not thread-safe unless you initialize OpenSSL. class OpenSSLHash { public: - class Digest { public: Digest() : ctx_(EVP_MD_CTX_new()) {} @@ -74,19 +73,13 @@ class OpenSSLHash { EvpMdCtxUniquePtr ctx_{nullptr}; }; - static void hash( - MutableByteRange out, - const EVP_MD* md, - ByteRange data) { + static void hash(MutableByteRange out, const EVP_MD* md, ByteRange data) { Digest hash; hash.hash_init(md); hash.hash_update(data); hash.hash_final(out); } - static void hash( - MutableByteRange out, - const EVP_MD* md, - const IOBuf& data) { + static void hash(MutableByteRange out, const EVP_MD* md, const IOBuf& data) { Digest hash; hash.hash_init(md); hash.hash_update(data); @@ -131,16 +124,14 @@ class OpenSSLHash { check_libssl_result(size, int(len)); md_ = nullptr; } + private: const EVP_MD* md_ = nullptr; HmacCtxUniquePtr ctx_{nullptr}; }; - static void hmac( - MutableByteRange out, - const EVP_MD* md, - ByteRange key, - ByteRange data) { + static void + hmac(MutableByteRange out, const EVP_MD* md, ByteRange key, ByteRange data) { Hmac hmac; hmac.hash_init(md, key); hmac.hash_update(data); @@ -156,20 +147,18 @@ class OpenSSLHash { hmac.hash_update(data); hmac.hash_final(out); } - static void hmac_sha1( - MutableByteRange out, ByteRange key, ByteRange data) { + static void hmac_sha1(MutableByteRange out, ByteRange key, ByteRange data) { hmac(out, EVP_sha1(), key, data); } - static void hmac_sha1( - MutableByteRange out, ByteRange key, const IOBuf& data) { + static void + hmac_sha1(MutableByteRange out, ByteRange key, const IOBuf& data) { hmac(out, EVP_sha1(), key, data); } - static void hmac_sha256( - MutableByteRange out, ByteRange key, ByteRange data) { + static void hmac_sha256(MutableByteRange out, ByteRange key, ByteRange data) { hmac(out, EVP_sha256(), key, data); } - static void hmac_sha256( - MutableByteRange out, ByteRange key, const IOBuf& data) { + static void + hmac_sha256(MutableByteRange out, ByteRange key, const IOBuf& data) { hmac(out, EVP_sha256(), key, data); } @@ -192,6 +181,5 @@ class OpenSSLHash { } [[noreturn]] static void check_libssl_result_throw(); }; - } } diff --git a/folly/ssl/OpenSSLPtrTypes.h b/folly/ssl/OpenSSLPtrTypes.h index c465fc13..45f47774 100644 --- a/folly/ssl/OpenSSLPtrTypes.h +++ b/folly/ssl/OpenSSLPtrTypes.h @@ -71,7 +71,9 @@ using BioDeleter = folly::static_function_deleter; using BioUniquePtr = std::unique_ptr; using BioChainDeleter = folly::static_function_deleter; using BioChainUniquePtr = std::unique_ptr; -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; using BioUniquePtrFb = std::unique_ptr; diff --git a/folly/ssl/test/OpenSSLHashTest.cpp b/folly/ssl/test/OpenSSLHashTest.cpp index b9f6a7b6..c2722caa 100644 --- a/folly/ssl/test/OpenSSLHashTest.cpp +++ b/folly/ssl/test/OpenSSLHashTest.cpp @@ -26,7 +26,6 @@ using namespace folly::ssl; namespace { class OpenSSLHashTest : public testing::Test {}; - } TEST_F(OpenSSLHashTest, sha256) { -- 2.34.1