Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mereacre committed Jan 23, 2024
1 parent 5d590f6 commit d404e38
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
15 changes: 9 additions & 6 deletions src/brski/brski.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ void log_lock_fun(bool lock);
#include "version.h"

const std::string OPT_STRING = ":c:i:o:p:a:dvh";
const std::string USAGE_STRING = "\t%s [-c filename] [-i filename] [-o filename] [-p port] "
"[-a address] [-d] [-h] [-v] <command>\n";
const std::string USAGE_STRING =
"\t%s [-c filename] [-i filename] [-o filename] [-p port] "
"[-a address] [-d] [-h] [-v] <command>\n";

enum class CommandId {
COMMAND_EXPORT_PVR = 1,
Expand All @@ -50,7 +51,8 @@ const std::array<struct command_config, 6> command_list = {{
"\tpreq\t\tSend a pledge-voucher request to the registrar and\n"
"\t\t\t return the pinned-domain-cert."},
{"sign", CommandId::COMMAND_SIGN_CERT, "\tsign\t\tSign a certificate\n"},
{"serial", CommandId::COMMAND_GET_SERIAL, "\tserial\t\tReturns the serial number of a certificate\n"},
{"serial", CommandId::COMMAND_GET_SERIAL,
"\tserial\t\tReturns the serial number of a certificate\n"},
{"registrar", CommandId::COMMAND_START_REGISTRAR,
"\tregistrar\tStarts the registrar"},
{"masa", CommandId::COMMAND_START_MASA, "\tmasa\t\tStarts the MASA"},
Expand Down Expand Up @@ -127,9 +129,10 @@ static CommandId get_command_id(const std::string &command_label) {
}

static void process_options(int argc, char *const argv[], int &verbose,
std::string &config_filename, std::string &in_filename,
std::string &out_filename, unsigned int *port,
std::string &address, CommandId &command_id) {
std::string &config_filename,
std::string &in_filename, std::string &out_filename,
unsigned int *port, std::string &address,
CommandId &command_id) {
int opt;

while ((opt = getopt(argc, argv, OPT_STRING.c_str())) != -1) {
Expand Down
11 changes: 7 additions & 4 deletions src/brski/http/httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -8874,8 +8874,8 @@ static SSLInit sslinit_;

// Accepty the client certificate as it is, vrefication not needed
int SSL_verify_fn(int preverify_ok, X509_STORE_CTX *x509_ctx) {
(void) preverify_ok;
(void) x509_ctx;
(void)preverify_ok;
(void)x509_ctx;
return 1;
}

Expand Down Expand Up @@ -8913,8 +8913,11 @@ inline SSLServer::SSLServer(const char *cert_path, const char *private_key_path,
ctx_, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, nullptr);
}

if (client_ca_cert_file_path == nullptr && client_ca_cert_dir_path == nullptr) {
SSL_CTX_set_verify(ctx_, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, SSL_verify_fn);
if (client_ca_cert_file_path == nullptr &&
client_ca_cert_dir_path == nullptr) {
SSL_CTX_set_verify(ctx_,
SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
SSL_verify_fn);
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/brski/pledge/pledge_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int generate_sign_cert(struct BinaryArray *scert_cert,
uint8_t rand[8];
char rands[17];
struct BinaryArray buf = {.array = rand, .length = 8};

struct crypto_cert_meta sign_cert_meta = {
.serial_number = 12345,
.not_before = 0,
Expand Down Expand Up @@ -237,9 +237,8 @@ int generate_sign_cert(struct BinaryArray *scert_cert,
goto generate_sign_cert_err;
}

if (push_keyvalue_list(sign_cert_meta.subject,
(char *)"serialNumber", rands) < 0)
{
if (push_keyvalue_list(sign_cert_meta.subject, (char *)"serialNumber",
rands) < 0) {
log_error("push_keyvalue_list fail");
goto generate_sign_cert_err;
}
Expand Down
2 changes: 1 addition & 1 deletion src/voucher/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ crypto_getcert_issuer(CRYPTO_CERT cert);
* @param[in] meta The input certificate metadata
* @return The serial number string or NULL on failure
*/
char* crypto_getcert_serial(struct crypto_cert_meta *meta);
char *crypto_getcert_serial(struct crypto_cert_meta *meta);

/**
* @brief Generate a private RSA key for a given number of bits
Expand Down
9 changes: 4 additions & 5 deletions src/voucher/crypto_ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1679,10 +1679,9 @@ ssize_t crypto_verify_cms(const struct BinaryArray *cms,
return -1;
}

int crypto_getrand(struct BinaryArray *buf)
{
int crypto_getrand(struct BinaryArray *buf) {
int ret;

if (buf == NULL)
return -1;

Expand All @@ -1691,9 +1690,9 @@ int crypto_getrand(struct BinaryArray *buf)

ret = RAND_bytes(buf->array, buf->length);

if(ret != 1) {
if (ret != 1) {
log_error("RAND_bytes fail with code=%s",
ERR_error_string(ERR_get_error(), NULL));
ERR_error_string(ERR_get_error(), NULL));
return -1;
}

Expand Down

0 comments on commit d404e38

Please sign in to comment.