Move over to upstream c++ style

This patchset moves bmcweb over to the upstream style naming
conventions for variables, classes, and functions, as well as imposes
the latest clang-format file.

This changeset was mostly built automatically by the included
.clang-tidy file, which has the ability to autoformat and auto rename
variables.  At some point in the future I would like to see this in
greater use, but for now, we will impose it on bmcweb, and see how it
goes.

Tested: Code still compiles, and appears to run, although other issues
are possible and likely.

Change-Id: If422a2e36df924e897736b3feffa89f411d9dac1
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/include/ssl_key_handler.hpp b/include/ssl_key_handler.hpp
index 4db4a8f..4eac803 100644
--- a/include/ssl_key_handler.hpp
+++ b/include/ssl_key_handler.hpp
@@ -1,5 +1,5 @@
 #pragma once
-#ifdef CROW_ENABLE_SSL
+#ifdef BMCWEB_ENABLE_SSL
 
 #include <openssl/bio.h>
 #include <openssl/dh.h>
@@ -14,15 +14,15 @@
 #include <boost/asio.hpp>
 
 namespace ensuressl {
-static void init_openssl();
-static void cleanup_openssl();
-static EVP_PKEY *create_rsa_key();
-static EVP_PKEY *create_ec_key();
-static void handle_openssl_error();
+static void initOpenssl();
+static void cleanupOpenssl();
+static EVP_PKEY *createRsaKey();
+static EVP_PKEY *createEcKey();
+static void handleOpensslError();
 
-inline bool verify_openssl_key_cert(const std::string &filepath) {
-  bool private_key_valid = false;
-  bool cert_valid = false;
+inline bool verifyOpensslKeyCert(const std::string &filepath) {
+  bool privateKeyValid = false;
+  bool certValid = false;
 
   std::cout << "Checking certs in file " << filepath << "\n";
 
@@ -45,7 +45,7 @@
         if (ec != nullptr) {
           std::cout << "Found an EC key\n";
           if (EC_KEY_check_key(ec) == 1) {
-            private_key_valid = true;
+            privateKeyValid = true;
           } else {
             std::cerr << "Key not valid error number " << ERR_get_error()
                       << "\n";
@@ -54,14 +54,14 @@
         }
       }
 
-      if (private_key_valid) {
+      if (privateKeyValid) {
         X509 *x509 = PEM_read_X509(file, NULL, NULL, NULL);
         if (x509 == nullptr) {
           std::cout << "error getting x509 cert " << ERR_get_error() << "\n";
         } else {
           rc = X509_verify(x509, pkey);
           if (rc == 1) {
-            cert_valid = true;
+            certValid = true;
           } else {
             std::cerr << "Error in verifying private key signature "
                       << ERR_get_error() << "\n";
@@ -73,26 +73,26 @@
     }
     fclose(file);
   }
-  return cert_valid;
+  return certValid;
 }
 
-inline void generate_ssl_certificate(const std::string &filepath) {
+inline void generateSslCertificate(const std::string &filepath) {
   FILE *pFile = NULL;
   std::cout << "Generating new keys\n";
-  init_openssl();
+  initOpenssl();
 
   // std::cerr << "Generating RSA key";
   // EVP_PKEY *pRsaPrivKey = create_rsa_key();
 
   std::cerr << "Generating EC key\n";
-  EVP_PKEY *pRsaPrivKey = create_ec_key();
+  EVP_PKEY *pRsaPrivKey = createEcKey();
   if (pRsaPrivKey != nullptr) {
     std::cerr << "Generating x509 Certificate\n";
     // Use this code to directly generate a certificate
     X509 *x509;
     x509 = X509_new();
     if (x509 != nullptr) {
-      // Get a random number from the RNG for the certificate serial number
+      // get a random number from the RNG for the certificate serial number
       // If this is not random, regenerating certs throws broswer errors
       std::random_device rd;
       int serial = rd();
@@ -107,7 +107,7 @@
       // set the public key to the key we just generated
       X509_set_pubkey(x509, pRsaPrivKey);
 
-      // Get the subject name
+      // get the subject name
       X509_NAME *name;
       name = X509_get_subject_name(x509);
 
@@ -146,7 +146,7 @@
   // cleanup_openssl();
 }
 
-EVP_PKEY *create_rsa_key() {
+EVP_PKEY *createRsaKey() {
   RSA *pRSA = NULL;
 #if OPENSSL_VERSION_NUMBER < 0x00908000L
   pRSA = RSA_generate_key(2048, RSA_3, NULL, NULL);
@@ -160,12 +160,12 @@
     /* pKey owns pRSA from now */
     if (RSA_check_key(pRSA) <= 0) {
       fprintf(stderr, "RSA_check_key failed.\n");
-      handle_openssl_error();
+      handleOpensslError();
       EVP_PKEY_free(pKey);
       pKey = NULL;
     }
   } else {
-    handle_openssl_error();
+    handleOpensslError();
     if (pRSA != nullptr) {
       RSA_free(pRSA);
       pRSA = NULL;
@@ -178,7 +178,7 @@
   return pKey;
 }
 
-EVP_PKEY *create_ec_key() {
+EVP_PKEY *createEcKey() {
   EVP_PKEY *pKey = NULL;
   int eccgrp = 0;
   eccgrp = OBJ_txt2nid("prime256v1");
@@ -200,7 +200,7 @@
   return pKey;
 }
 
-void init_openssl() {
+void initOpenssl() {
 #if OPENSSL_VERSION_NUMBER < 0x10100000L
   SSL_load_error_strings();
   OpenSSL_add_all_algorithms();
@@ -208,7 +208,7 @@
 #endif
 }
 
-void cleanup_openssl() {
+void cleanupOpenssl() {
   CRYPTO_cleanup_all_ex_data();
   ERR_free_strings();
 #if OPENSSL_VERSION_NUMBER < 0x10100000L
@@ -217,44 +217,44 @@
   EVP_cleanup();
 }
 
-void handle_openssl_error() { ERR_print_errors_fp(stderr); }
-inline void ensure_openssl_key_present_and_valid(const std::string &filepath) {
-  bool pem_file_valid = false;
+void handleOpensslError() { ERR_print_errors_fp(stderr); }
+inline void ensureOpensslKeyPresentAndValid(const std::string &filepath) {
+  bool pemFileValid = false;
 
-  pem_file_valid = verify_openssl_key_cert(filepath);
+  pemFileValid = verifyOpensslKeyCert(filepath);
 
-  if (!pem_file_valid) {
+  if (!pemFileValid) {
     std::cerr << "Error in verifying signature, regenerating\n";
-    generate_ssl_certificate(filepath);
+    generateSslCertificate(filepath);
   }
 }
 
-inline boost::asio::ssl::context get_ssl_context(
+inline boost::asio::ssl::context getSslContext(
     const std::string &ssl_pem_file) {
-  boost::asio::ssl::context m_ssl_context{boost::asio::ssl::context::sslv23};
-  m_ssl_context.set_options(boost::asio::ssl::context::default_workarounds |
-                            boost::asio::ssl::context::no_sslv2 |
-                            boost::asio::ssl::context::no_sslv3 |
-                            boost::asio::ssl::context::single_dh_use |
-                            boost::asio::ssl::context::no_tlsv1 |
-                            boost::asio::ssl::context::no_tlsv1_1);
+  boost::asio::ssl::context mSslContext{boost::asio::ssl::context::sslv23};
+  mSslContext.set_options(boost::asio::ssl::context::default_workarounds |
+                          boost::asio::ssl::context::no_sslv2 |
+                          boost::asio::ssl::context::no_sslv3 |
+                          boost::asio::ssl::context::single_dh_use |
+                          boost::asio::ssl::context::no_tlsv1 |
+                          boost::asio::ssl::context::no_tlsv1_1);
 
   // m_ssl_context.set_verify_mode(boost::asio::ssl::verify_peer);
-  m_ssl_context.use_certificate_file(ssl_pem_file,
-                                     boost::asio::ssl::context::pem);
-  m_ssl_context.use_private_key_file(ssl_pem_file,
-                                     boost::asio::ssl::context::pem);
+  mSslContext.use_certificate_file(ssl_pem_file,
+                                   boost::asio::ssl::context::pem);
+  mSslContext.use_private_key_file(ssl_pem_file,
+                                   boost::asio::ssl::context::pem);
 
   // Set up EC curves to auto (boost asio doesn't have a method for this)
   // There is a pull request to add this.  Once this is included in an asio
   // drop, use the right way
   // http://stackoverflow.com/questions/18929049/boost-asio-with-ecdsa-certificate-issue
-  if (SSL_CTX_set_ecdh_auto(m_ssl_context.native_handle(), 1) != 1) {
-    CROW_LOG_ERROR << "Error setting tmp ecdh list\n";
+  if (SSL_CTX_set_ecdh_auto(mSslContext.native_handle(), 1) != 1) {
+    BMCWEB_LOG_ERROR << "Error setting tmp ecdh list\n";
   }
 
   // From mozilla "compatibility"
-  std::string mozilla_compatibility_ciphers =
+  std::string mozillaCompatibilityCiphers =
       "ECDHE-ECDSA-CHACHA20-POLY1305:"
       "ECDHE-RSA-CHACHA20-POLY1305:"
       "ECDHE-ECDSA-AES128-GCM-SHA256:"
@@ -288,7 +288,7 @@
       "!DSS";
 
   // From mozilla "modern"
-  std::string mozilla_modern_ciphers =
+  std::string mozillaModernCiphers =
       "ECDHE-ECDSA-AES256-GCM-SHA384:"
       "ECDHE-RSA-AES256-GCM-SHA384:"
       "ECDHE-ECDSA-CHACHA20-POLY1305:"
@@ -300,13 +300,13 @@
       "ECDHE-ECDSA-AES128-SHA256:"
       "ECDHE-RSA-AES128-SHA256";
 
-  std::string aes_only_ciphers = "AES128+EECDH:AES128+EDH:!aNULL:!eNULL";
+  std::string aesOnlyCiphers = "AES128+EECDH:AES128+EDH:!aNULL:!eNULL";
 
-  if (SSL_CTX_set_cipher_list(m_ssl_context.native_handle(),
-                              mozilla_compatibility_ciphers.c_str()) != 1) {
-    CROW_LOG_ERROR << "Error setting cipher list\n";
+  if (SSL_CTX_set_cipher_list(mSslContext.native_handle(),
+                              mozillaCompatibilityCiphers.c_str()) != 1) {
+    BMCWEB_LOG_ERROR << "Error setting cipher list\n";
   }
-  return m_ssl_context;
+  return mSslContext;
 }
 }  // namespace ensuressl