Skip to content

Commit

Permalink
Refs 11914. linters
Browse files Browse the repository at this point in the history
Signed-off-by: Iker Luengo <ikerluengo@eprosima.com>
  • Loading branch information
IkerLuengo committed Sep 22, 2021
1 parent b3dd1e9 commit b187d17
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 37 deletions.
3 changes: 2 additions & 1 deletion src/cpp/security/accesscontrol/Permissions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ static X509_STORE* load_permissions_ca(
{
if (permissions_ca.size() >= 7 && permissions_ca.compare(0, 7, "file://") == 0)
{
return detail::FileProvider::load_ca(permissions_ca, there_are_crls, ca_sn, ca_algo, get_signature_algorithm, exception);
return detail::FileProvider::load_ca(permissions_ca, there_are_crls, ca_sn, ca_algo, get_signature_algorithm,
exception);
}

exception = _SecurityException_(std::string("Unsupported URI format ") + permissions_ca);
Expand Down
28 changes: 14 additions & 14 deletions src/cpp/security/artifact_providers/FileProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@ class FileProvider
public:

static X509_STORE* load_ca(
const std::string& ca,
bool& there_are_crls,
std::string& ca_sn,
std::string& ca_algo,
std::function<bool(X509*, std::string&, SecurityException&)> get_signature_algorithm,
SecurityException& exception);
const std::string& ca,
bool& there_are_crls,
std::string& ca_sn,
std::string& ca_algo,
std::function<bool(X509*, std::string&, SecurityException&)> get_signature_algorithm,
SecurityException& exception);

static EVP_PKEY* load_private_key(
X509* certificate,
const std::string& file,
const std::string& password,
SecurityException& exception);
X509* certificate,
const std::string& file,
const std::string& password,
SecurityException& exception);

static X509* load_certificate(
const std::string& identity_cert,
SecurityException& exception);
const std::string& identity_cert,
SecurityException& exception);

static X509_CRL* load_crl(
const std::string& identity_crl,
SecurityException& exception);
const std::string& identity_crl,
SecurityException& exception);

};

Expand Down
30 changes: 17 additions & 13 deletions src/cpp/security/artifact_providers/Pkcs11Provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,25 @@ namespace detail {
constexpr const char* FASTDDS_PKCS11_PIN = "FASTDDS_PKCS11_PIN";
constexpr const char* PKCS11_ENGINE_ID = "pkcs11";

static int ui_open(UI *ui)
static int ui_open(
UI* ui)
{
return UI_method_get_opener(UI_OpenSSL())(ui);
}

static int ui_read(UI *ui, UI_STRING *uis)
static int ui_read(
UI* ui,
UI_STRING* uis)
{
switch(UI_get_string_type(uis))
switch (UI_get_string_type(uis))
{
case UIT_PROMPT:
case UIT_VERIFY:
{
logWarning(PKCS11_PROVIDER, "PKCS#11 engine is asking: " << UI_get0_output_string(uis));
// Return an empty password without asking the user
UI_set_result(ui, uis, "");
return 1;
logWarning(PKCS11_PROVIDER, "PKCS#11 engine is asking: " << UI_get0_output_string(uis));
// Return an empty password without asking the user
UI_set_result(ui, uis, "");
return 1;
}
default:
break;
Expand All @@ -65,8 +68,8 @@ static int ui_read(UI *ui, UI_STRING *uis)
return UI_method_get_reader(UI_OpenSSL())(ui, uis);
}


static int ui_close(UI *ui)
static int ui_close(
UI* ui)
{
return UI_method_get_closer(UI_OpenSSL())(ui);
}
Expand Down Expand Up @@ -99,13 +102,14 @@ Pkcs11Provider::Pkcs11Provider()
if (!ENGINE_ctrl_cmd_string( pkcs11_, "PIN", pin, 0))
{
has_initialization_error_ = true;
initialization_exception_ = _SecurityException_(std::string("Error setting the PIN in the 'pkcs11' engine"));
initialization_exception_ =
_SecurityException_(std::string("Error setting the PIN in the 'pkcs11' engine"));
ENGINE_free(pkcs11_);
}
}

// Init the engine with the PIN (if any)
if(!ENGINE_init(pkcs11_))
if (!ENGINE_init(pkcs11_))
{
has_initialization_error_ = true;
initialization_exception_ = _SecurityException_(std::string("Error initializeing the HSM provider library"));
Expand All @@ -118,7 +122,7 @@ Pkcs11Provider::~Pkcs11Provider()
ENGINE_finish(pkcs11_);
ENGINE_free(pkcs11_);

if(ui_method_)
if (ui_method_)
{
UI_destroy_method(ui_method_);
}
Expand Down Expand Up @@ -156,7 +160,7 @@ EVP_PKEY* Pkcs11Provider::load_private_key_impl(
if (!X509_check_private_key(certificate, returnedValue))
{
exception = _SecurityException_(std::string("Error verifying private key ") + pkey.substr(7)
+ "\n ERROR: " + ERR_error_string(ERR_get_error(), nullptr));
+ "\n ERROR: " + ERR_error_string(ERR_get_error(), nullptr));
EVP_PKEY_free(returnedValue);
returnedValue = nullptr;
}
Expand Down
16 changes: 8 additions & 8 deletions src/cpp/security/artifact_providers/Pkcs11Provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class Pkcs11Provider
public:

static EVP_PKEY* load_private_key(
X509* certificate,
const std::string& file,
const std::string& password,
SecurityException& exception);
X509* certificate,
const std::string& file,
const std::string& password,
SecurityException& exception);

~Pkcs11Provider();

Expand All @@ -58,10 +58,10 @@ class Pkcs11Provider
Pkcs11Provider();

EVP_PKEY* load_private_key_impl(
X509* certificate,
const std::string& file,
const std::string& password,
SecurityException& exception);
X509* certificate,
const std::string& file,
const std::string& password,
SecurityException& exception);

SecurityException initialization_exception_;
bool has_initialization_error_ = false;
Expand Down
3 changes: 2 additions & 1 deletion src/cpp/security/authentication/PKIDH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ static X509_STORE* load_identity_ca(
{
if (identity_ca.size() >= 7 && identity_ca.compare(0, 7, "file://") == 0)
{
return detail::FileProvider::load_ca(identity_ca, there_are_crls, ca_sn, ca_algo, get_signature_algorithm, exception);
return detail::FileProvider::load_ca(identity_ca, there_are_crls, ca_sn, ca_algo, get_signature_algorithm,
exception);
}

exception = _SecurityException_(std::string("Unsupported URI format ") + identity_ca);
Expand Down

0 comments on commit b187d17

Please sign in to comment.