Skip to content

Commit bba7323

Browse files
avivkelleraduh95
authored andcommitted
build: apply cpp linting and formatting to ncrypto
PR-URL: #55362 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 3cfacd3 commit bba7323

File tree

5 files changed

+439
-340
lines changed

5 files changed

+439
-340
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,11 @@ LINT_CPP_EXCLUDE += $(LINT_CPP_ADDON_DOC_FILES)
14141414
# These files were copied more or less verbatim from V8.
14151415
LINT_CPP_EXCLUDE += src/tracing/trace_event.h src/tracing/trace_event_common.h
14161416

1417+
# deps/ncrypto is included in this list, as it is maintained in
1418+
# this repository, and should be linted. Eventually it should move
1419+
# to its own repo, at which point we should remove it from this list.
1420+
LINT_CPP_DEPS = deps/ncrypto/*.cc deps/ncrypto/*.h
1421+
14171422
LINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \
14181423
benchmark/napi/*/*.cc \
14191424
src/*.c \
@@ -1438,6 +1443,7 @@ LINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \
14381443
tools/code_cache/*.h \
14391444
tools/snapshot/*.cc \
14401445
tools/snapshot/*.h \
1446+
$(LINT_CPP_DEPS) \
14411447
))
14421448

14431449
FORMAT_CPP_FILES ?=

deps/ncrypto/dh-primes.h

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,19 @@
5050
* (eay@cryptsoft.com). This product includes software written by Tim
5151
* Hudson (tjh@cryptsoft.com). */
5252

53+
#ifndef DEPS_NCRYPTO_DH_PRIMES_H_
54+
#define DEPS_NCRYPTO_DH_PRIMES_H_
55+
5356
#include <openssl/dh.h>
5457

5558
#include <openssl/bn.h>
5659
#include <openssl/err.h>
5760
#include <openssl/mem.h>
5861

59-
extern "C" int bn_set_words(BIGNUM *bn, const BN_ULONG *words, size_t num);
62+
extern "C" int bn_set_words(BIGNUM* bn, const BN_ULONG* words, size_t num);
6063

61-
// Backporting primes that may not be supported in earlier boringssl versions. Intentionally
62-
// keeping the existing C-style formatting.
64+
// Backporting primes that may not be supported in earlier boringssl versions.
65+
// Intentionally keeping the existing C-style formatting.
6366

6467
#define OPENSSL_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
6568

@@ -71,25 +74,27 @@ extern "C" int bn_set_words(BIGNUM *bn, const BN_ULONG *words, size_t num);
7174
#error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
7275
#endif
7376

74-
static BIGNUM *get_params(BIGNUM *ret, const BN_ULONG *words, size_t num_words) {
75-
BIGNUM *alloc = NULL;
76-
if (ret == NULL) {
77+
static BIGNUM* get_params(BIGNUM* ret,
78+
const BN_ULONG* words,
79+
size_t num_words) {
80+
BIGNUM* alloc = nullptr;
81+
if (ret == nullptr) {
7782
alloc = BN_new();
78-
if (alloc == NULL) {
79-
return NULL;
83+
if (alloc == nullptr) {
84+
return nullptr;
8085
}
8186
ret = alloc;
8287
}
8388

8489
if (!bn_set_words(ret, words, num_words)) {
8590
BN_free(alloc);
86-
return NULL;
91+
return nullptr;
8792
}
8893

8994
return ret;
9095
}
9196

92-
BIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *ret) {
97+
BIGNUM* BN_get_rfc3526_prime_2048(BIGNUM* ret) {
9398
static const BN_ULONG kWords[] = {
9499
TOBN(0xffffffff, 0xffffffff), TOBN(0x15728e5a, 0x8aacaa68),
95100
TOBN(0x15d22618, 0x98fa0510), TOBN(0x3995497c, 0xea956ae5),
@@ -111,7 +116,7 @@ BIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *ret) {
111116
return get_params(ret, kWords, OPENSSL_ARRAY_SIZE(kWords));
112117
}
113118

114-
BIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *ret) {
119+
BIGNUM* BN_get_rfc3526_prime_3072(BIGNUM* ret) {
115120
static const BN_ULONG kWords[] = {
116121
TOBN(0xffffffff, 0xffffffff), TOBN(0x4b82d120, 0xa93ad2ca),
117122
TOBN(0x43db5bfc, 0xe0fd108e), TOBN(0x08e24fa0, 0x74e5ab31),
@@ -141,7 +146,7 @@ BIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *ret) {
141146
return get_params(ret, kWords, OPENSSL_ARRAY_SIZE(kWords));
142147
}
143148

144-
BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *ret) {
149+
BIGNUM* BN_get_rfc3526_prime_4096(BIGNUM* ret) {
145150
static const BN_ULONG kWords[] = {
146151
TOBN(0xffffffff, 0xffffffff), TOBN(0x4df435c9, 0x34063199),
147152
TOBN(0x86ffb7dc, 0x90a6c08f), TOBN(0x93b4ea98, 0x8d8fddc1),
@@ -179,7 +184,7 @@ BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *ret) {
179184
return get_params(ret, kWords, OPENSSL_ARRAY_SIZE(kWords));
180185
}
181186

182-
BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *ret) {
187+
BIGNUM* BN_get_rfc3526_prime_6144(BIGNUM* ret) {
183188
static const BN_ULONG kWords[] = {
184189
TOBN(0xffffffff, 0xffffffff), TOBN(0xe694f91e, 0x6dcc4024),
185190
TOBN(0x12bf2d5b, 0x0b7474d6), TOBN(0x043e8f66, 0x3f4860ee),
@@ -233,7 +238,7 @@ BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *ret) {
233238
return get_params(ret, kWords, OPENSSL_ARRAY_SIZE(kWords));
234239
}
235240

236-
BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *ret) {
241+
BIGNUM* BN_get_rfc3526_prime_8192(BIGNUM* ret) {
237242
static const BN_ULONG kWords[] = {
238243
TOBN(0xffffffff, 0xffffffff), TOBN(0x60c980dd, 0x98edd3df),
239244
TOBN(0xc81f56e8, 0x80b96e71), TOBN(0x9e3050e2, 0x765694df),
@@ -302,3 +307,5 @@ BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *ret) {
302307
};
303308
return get_params(ret, kWords, OPENSSL_ARRAY_SIZE(kWords));
304309
}
310+
311+
#endif // DEPS_NCRYPTO_DH_PRIMES_H_

deps/ncrypto/engine.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ namespace ncrypto {
77

88
#ifndef OPENSSL_NO_ENGINE
99
EnginePointer::EnginePointer(ENGINE* engine_, bool finish_on_exit_)
10-
: engine(engine_),
11-
finish_on_exit(finish_on_exit_) {}
10+
: engine(engine_), finish_on_exit(finish_on_exit_) {}
1211

1312
EnginePointer::EnginePointer(EnginePointer&& other) noexcept
14-
: engine(other.engine),
15-
finish_on_exit(other.finish_on_exit) {
13+
: engine(other.engine), finish_on_exit(other.finish_on_exit) {
1614
other.release();
1715
}
1816

19-
EnginePointer::~EnginePointer() { reset(); }
17+
EnginePointer::~EnginePointer() {
18+
reset();
19+
}
2020

2121
EnginePointer& EnginePointer::operator=(EnginePointer&& other) noexcept {
2222
if (this == &other) return *this;
@@ -75,7 +75,8 @@ bool EnginePointer::init(bool finish_on_exit) {
7575

7676
EVPKeyPointer EnginePointer::loadPrivateKey(const std::string_view key_name) {
7777
if (engine == nullptr) return EVPKeyPointer();
78-
return EVPKeyPointer(ENGINE_load_private_key(engine, key_name.data(), nullptr, nullptr));
78+
return EVPKeyPointer(
79+
ENGINE_load_private_key(engine, key_name.data(), nullptr, nullptr));
7980
}
8081

8182
void EnginePointer::initEnginesOnce() {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy