Skip to content

Commit 3ea0cd6

Browse files
committed
clang-tidy and clang-format
1 parent 6917a1d commit 3ea0cd6

File tree

21 files changed

+238
-129
lines changed

21 files changed

+238
-129
lines changed

cmd/api_example/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
using namespace mls;
1111

12-
const auto suite = CipherSuite{CipherSuite::ID::X25519_AES128GCM_SHA256_Ed25519};
12+
const auto suite =
13+
CipherSuite{ CipherSuite::ID::X25519_AES128GCM_SHA256_Ed25519 };
1314

1415
class User
1516
{

cmd/test_gen/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ generate_crypto()
6060

6161
std::vector<CipherSuite> suites{
6262
{ CipherSuite::ID::P256_AES128GCM_SHA256_P256 },
63-
{ CipherSuite::ID::X25519_AES128GCM_SHA256_Ed25519 },
63+
{ CipherSuite::ID::X25519_AES128GCM_SHA256_Ed25519 },
6464
};
6565

6666
tv.kdf_extract_salt = { 0, 1, 2, 3 };
@@ -266,7 +266,7 @@ generate_messages()
266266

267267
std::vector<CipherSuite> suites{
268268
{ CipherSuite::ID::P256_AES128GCM_SHA256_P256 },
269-
{ CipherSuite::ID::X25519_AES128GCM_SHA256_Ed25519 },
269+
{ CipherSuite::ID::X25519_AES128GCM_SHA256_Ed25519 },
270270
};
271271

272272
// Set the inputs

include/mls/crypto.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace mls {
1313

1414
/// Cipher suites
1515

16-
1716
struct CipherSuite
1817
{
1918
enum struct ID : uint16_t
@@ -27,7 +26,8 @@ struct CipherSuite
2726
X448_CHACHA20POLY1305_SHA512_Ed448 = 0x0006,
2827
};
2928

30-
struct Ciphers {
29+
struct Ciphers
30+
{
3131
hpke::HPKE hpke;
3232
const hpke::Digest& digest;
3333
const hpke::Signature& sig;
@@ -40,11 +40,11 @@ struct CipherSuite
4040
bytes expand_with_label(const bytes& secret,
4141
const std::string& label,
4242
const bytes& context,
43-
size_t size) const;
43+
size_t length) const;
4444

4545
TLS_SERIALIZABLE(id)
4646

47-
private:
47+
private:
4848
template<CipherSuite::ID>
4949
static const Ciphers ciphers;
5050
};

lib/hpke/src/aead_cipher.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@
55

66
namespace hpke {
77

8-
AEADCipher make_aead(AEAD::ID cipher_in)
8+
AEADCipher
9+
make_aead(AEAD::ID cipher_in)
910
{
1011
return AEADCipher(cipher_in);
1112
}
1213

1314
template<>
14-
const AEADCipher AEADCipher::instance<AEAD::ID::AES_128_GCM> = make_aead(AEAD::ID::AES_128_GCM);
15+
const AEADCipher AEADCipher::instance<AEAD::ID::AES_128_GCM> =
16+
make_aead(AEAD::ID::AES_128_GCM);
1517

1618
template<>
17-
const AEADCipher AEADCipher::instance<AEAD::ID::AES_256_GCM> = make_aead(AEAD::ID::AES_256_GCM);
19+
const AEADCipher AEADCipher::instance<AEAD::ID::AES_256_GCM> =
20+
make_aead(AEAD::ID::AES_256_GCM);
1821

1922
template<>
20-
const AEADCipher AEADCipher::instance<AEAD::ID::CHACHA20_POLY1305> = make_aead(AEAD::ID::CHACHA20_POLY1305);
21-
23+
const AEADCipher AEADCipher::instance<AEAD::ID::CHACHA20_POLY1305> =
24+
make_aead(AEAD::ID::CHACHA20_POLY1305);
2225

2326
template<>
2427
const AEADCipher&

lib/hpke/src/dhkem.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,41 @@ DHKEM::PrivateKey::public_key() const
1717
return group_priv->public_key();
1818
}
1919

20-
DHKEM make_dhkem(KEM::ID kem_id_in, const Group& group_in, const KDF& kdf_in)
20+
DHKEM
21+
make_dhkem(KEM::ID kem_id_in, const Group& group_in, const KDF& kdf_in)
2122
{
2223
return DHKEM(kem_id_in, group_in, kdf_in);
2324
}
2425

2526
template<>
2627
const DHKEM DHKEM::instance<KEM::ID::DHKEM_P256_SHA256> =
27-
make_dhkem(KEM::ID::DHKEM_P256_SHA256, Group::get<Group::ID::P256>(), KDF::get<KDF::ID::HKDF_SHA256>());
28+
make_dhkem(KEM::ID::DHKEM_P256_SHA256,
29+
Group::get<Group::ID::P256>(),
30+
KDF::get<KDF::ID::HKDF_SHA256>());
2831

2932
template<>
3033
const DHKEM DHKEM::instance<KEM::ID::DHKEM_P384_SHA384> =
31-
make_dhkem(KEM::ID::DHKEM_P384_SHA384, Group::get<Group::ID::P384>(), KDF::get<KDF::ID::HKDF_SHA384>());
34+
make_dhkem(KEM::ID::DHKEM_P384_SHA384,
35+
Group::get<Group::ID::P384>(),
36+
KDF::get<KDF::ID::HKDF_SHA384>());
3237

3338
template<>
3439
const DHKEM DHKEM::instance<KEM::ID::DHKEM_P521_SHA512> =
35-
make_dhkem(KEM::ID::DHKEM_P521_SHA512, Group::get<Group::ID::P521>(), KDF::get<KDF::ID::HKDF_SHA512>());
40+
make_dhkem(KEM::ID::DHKEM_P521_SHA512,
41+
Group::get<Group::ID::P521>(),
42+
KDF::get<KDF::ID::HKDF_SHA512>());
3643

3744
template<>
3845
const DHKEM DHKEM::instance<KEM::ID::DHKEM_X25519_SHA256> =
39-
make_dhkem(KEM::ID::DHKEM_X25519_SHA256, Group::get<Group::ID::X25519>(), KDF::get<KDF::ID::HKDF_SHA256>());
46+
make_dhkem(KEM::ID::DHKEM_X25519_SHA256,
47+
Group::get<Group::ID::X25519>(),
48+
KDF::get<KDF::ID::HKDF_SHA256>());
4049

4150
template<>
4251
const DHKEM DHKEM::instance<KEM::ID::DHKEM_X448_SHA512> =
43-
make_dhkem(KEM::ID::DHKEM_X448_SHA512, Group::get<Group::ID::X448>(), KDF::get<KDF::ID::HKDF_SHA512>());
44-
52+
make_dhkem(KEM::ID::DHKEM_X448_SHA512,
53+
Group::get<Group::ID::X448>(),
54+
KDF::get<KDF::ID::HKDF_SHA512>());
4555

4656
template<>
4757
const DHKEM&
@@ -78,7 +88,6 @@ DHKEM::get<KEM::ID::DHKEM_X448_SHA512>()
7888
return DHKEM::instance<KEM::ID::DHKEM_X448_SHA512>;
7989
}
8090

81-
8291
DHKEM::DHKEM(KEM::ID kem_id_in, const Group& group_in, const KDF& kdf_in)
8392
: group(group_in)
8493
, kdf(kdf_in)
@@ -124,8 +133,7 @@ DHKEM::serialize_private(const KEM::PrivateKey& sk) const
124133
std::unique_ptr<KEM::PrivateKey>
125134
DHKEM::deserialize_private(const bytes& skm) const
126135
{
127-
return std::make_unique<PrivateKey>(
128-
group.deserialize_private(skm).release());
136+
return std::make_unique<PrivateKey>(group.deserialize_private(skm).release());
129137
}
130138

131139
std::pair<bytes, bytes>

lib/hpke/src/dhkem.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ struct DHKEM : public KEM
5454
bytes extract_and_expand(const bytes& dh, const bytes& kem_context) const;
5555

5656
DHKEM(KEM::ID kem_id_in, const Group& group_in, const KDF& kdf_in);
57-
friend DHKEM make_dhkem(KEM::ID kem_id_in, const Group& group_in, const KDF& kdf_in);
57+
friend DHKEM make_dhkem(KEM::ID kem_id_in,
58+
const Group& group_in,
59+
const KDF& kdf_in);
5860

5961
template<KEM::ID id>
6062
static const DHKEM instance;

lib/hpke/src/digest.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,41 @@ openssl_digest_type(Digest::ID digest)
2525
}
2626
}
2727

28-
Digest make_digest(Digest::ID id) {
28+
Digest
29+
make_digest(Digest::ID id)
30+
{
2931
return Digest(id);
3032
}
3133

3234
template<>
33-
const Digest Digest::instance<Digest::ID::SHA256> = make_digest(Digest::ID::SHA256);
35+
const Digest Digest::instance<Digest::ID::SHA256> =
36+
make_digest(Digest::ID::SHA256);
3437

3538
template<>
36-
const Digest Digest::instance<Digest::ID::SHA384> = make_digest(Digest::ID::SHA384);
39+
const Digest Digest::instance<Digest::ID::SHA384> =
40+
make_digest(Digest::ID::SHA384);
3741

3842
template<>
39-
const Digest Digest::instance<Digest::ID::SHA512> = make_digest(Digest::ID::SHA512);
43+
const Digest Digest::instance<Digest::ID::SHA512> =
44+
make_digest(Digest::ID::SHA512);
4045

4146
template<>
42-
const Digest& Digest::get<Digest::ID::SHA256>()
47+
const Digest&
48+
Digest::get<Digest::ID::SHA256>()
4349
{
4450
return Digest::instance<Digest::ID::SHA256>;
4551
}
4652

4753
template<>
48-
const Digest& Digest::get<Digest::ID::SHA384>()
54+
const Digest&
55+
Digest::get<Digest::ID::SHA384>()
4956
{
5057
return Digest::instance<Digest::ID::SHA384>;
5158
}
5259

5360
template<>
54-
const Digest& Digest::get<Digest::ID::SHA512>()
61+
const Digest&
62+
Digest::get<Digest::ID::SHA512>()
5563
{
5664
return Digest::instance<Digest::ID::SHA512>;
5765
}

lib/hpke/src/group.cpp

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ struct ECKeyGroup : public EVPGroup
163163
static const ECKeyGroup instance;
164164

165165
std::unique_ptr<Group::PrivateKey> derive_key_pair(
166-
const bytes& suite_id,
167-
const bytes& ikm) const override
166+
const bytes& suite_id,
167+
const bytes& ikm) const override
168168
{
169169
static const int retry_limit = 255;
170170
static const auto label_dkp_prk = to_bytes("dkp_prk");
@@ -313,13 +313,16 @@ struct ECKeyGroup : public EVPGroup
313313
};
314314

315315
template<>
316-
const ECKeyGroup ECKeyGroup::instance<Group::ID::P256> = ECKeyGroup(Group::ID::P256, KDF::get<KDF::ID::HKDF_SHA256>());
316+
const ECKeyGroup ECKeyGroup::instance<Group::ID::P256> =
317+
ECKeyGroup(Group::ID::P256, KDF::get<KDF::ID::HKDF_SHA256>());
317318

318319
template<>
319-
const ECKeyGroup ECKeyGroup::instance<Group::ID::P384> = ECKeyGroup(Group::ID::P384, KDF::get<KDF::ID::HKDF_SHA384>());
320+
const ECKeyGroup ECKeyGroup::instance<Group::ID::P384> =
321+
ECKeyGroup(Group::ID::P384, KDF::get<KDF::ID::HKDF_SHA384>());
320322

321323
template<>
322-
const ECKeyGroup ECKeyGroup::instance<Group::ID::P521> = ECKeyGroup(Group::ID::P521, KDF::get<KDF::ID::HKDF_SHA512>());
324+
const ECKeyGroup ECKeyGroup::instance<Group::ID::P521> =
325+
ECKeyGroup(Group::ID::P521, KDF::get<KDF::ID::HKDF_SHA512>());
323326

324327
///
325328
/// DH over "raw" curves
@@ -418,35 +421,73 @@ struct RawKeyGroup : public EVPGroup
418421
};
419422

420423
template<>
421-
const RawKeyGroup RawKeyGroup::instance<Group::ID::X25519> = RawKeyGroup(Group::ID::X25519, KDF::get<KDF::ID::HKDF_SHA256>());
424+
const RawKeyGroup RawKeyGroup::instance<Group::ID::X25519> =
425+
RawKeyGroup(Group::ID::X25519, KDF::get<KDF::ID::HKDF_SHA256>());
422426

423427
template<>
424-
const RawKeyGroup RawKeyGroup::instance<Group::ID::Ed25519> = RawKeyGroup(Group::ID::Ed25519, KDF::get<KDF::ID::HKDF_SHA256>());
428+
const RawKeyGroup RawKeyGroup::instance<Group::ID::Ed25519> =
429+
RawKeyGroup(Group::ID::Ed25519, KDF::get<KDF::ID::HKDF_SHA256>());
425430

426431
template<>
427-
const RawKeyGroup RawKeyGroup::instance<Group::ID::X448> = RawKeyGroup(Group::ID::X448, KDF::get<KDF::ID::HKDF_SHA512>());
432+
const RawKeyGroup RawKeyGroup::instance<Group::ID::X448> =
433+
RawKeyGroup(Group::ID::X448, KDF::get<KDF::ID::HKDF_SHA512>());
428434

429435
template<>
430-
const RawKeyGroup RawKeyGroup::instance<Group::ID::Ed448> = RawKeyGroup(Group::ID::Ed448, KDF::get<KDF::ID::HKDF_SHA512>());
436+
const RawKeyGroup RawKeyGroup::instance<Group::ID::Ed448> =
437+
RawKeyGroup(Group::ID::Ed448, KDF::get<KDF::ID::HKDF_SHA512>());
431438

432439
///
433440
/// General DH group
434441
///
435442

443+
template<>
444+
const Group&
445+
Group::get<Group::ID::P256>()
446+
{
447+
return ECKeyGroup::instance<Group::ID::P256>;
448+
}
436449

437-
template<> const Group& Group::get<Group::ID::P256>() { return ECKeyGroup::instance<Group::ID::P256>; }
438-
439-
template<> const Group& Group::get<Group::ID::P384>() { return ECKeyGroup::instance<Group::ID::P384>; }
450+
template<>
451+
const Group&
452+
Group::get<Group::ID::P384>()
453+
{
454+
return ECKeyGroup::instance<Group::ID::P384>;
455+
}
440456

441-
template<> const Group& Group::get<Group::ID::P521>() { return ECKeyGroup::instance<Group::ID::P521>; }
457+
template<>
458+
const Group&
459+
Group::get<Group::ID::P521>()
460+
{
461+
return ECKeyGroup::instance<Group::ID::P521>;
462+
}
442463

443-
template<> const Group& Group::get<Group::ID::X25519>() { return RawKeyGroup::instance<Group::ID::X25519>; }
464+
template<>
465+
const Group&
466+
Group::get<Group::ID::X25519>()
467+
{
468+
return RawKeyGroup::instance<Group::ID::X25519>;
469+
}
444470

445-
template<> const Group& Group::get<Group::ID::Ed25519>() { return RawKeyGroup::instance<Group::ID::Ed25519>; }
471+
template<>
472+
const Group&
473+
Group::get<Group::ID::Ed25519>()
474+
{
475+
return RawKeyGroup::instance<Group::ID::Ed25519>;
476+
}
446477

447-
template<> const Group& Group::get<Group::ID::X448>() { return RawKeyGroup::instance<Group::ID::X448>; }
478+
template<>
479+
const Group&
480+
Group::get<Group::ID::X448>()
481+
{
482+
return RawKeyGroup::instance<Group::ID::X448>;
483+
}
448484

449-
template<> const Group& Group::get<Group::ID::Ed448>() { return RawKeyGroup::instance<Group::ID::Ed448>; }
485+
template<>
486+
const Group&
487+
Group::get<Group::ID::Ed448>()
488+
{
489+
return RawKeyGroup::instance<Group::ID::Ed448>;
490+
}
450491

451492
size_t
452493
Group::dh_size() const

lib/hpke/src/hkdf.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,41 @@
88

99
namespace hpke {
1010

11-
HKDF make_hkdf(const Digest& digest) {
11+
HKDF
12+
make_hkdf(const Digest& digest)
13+
{
1214
return HKDF(digest);
1315
}
1416

1517
template<>
16-
const HKDF HKDF::instance<Digest::ID::SHA256> = make_hkdf(Digest::get<Digest::ID::SHA256>());
18+
const HKDF HKDF::instance<Digest::ID::SHA256> =
19+
make_hkdf(Digest::get<Digest::ID::SHA256>());
1720

1821
template<>
19-
const HKDF HKDF::instance<Digest::ID::SHA384> = make_hkdf(Digest::get<Digest::ID::SHA384>());
22+
const HKDF HKDF::instance<Digest::ID::SHA384> =
23+
make_hkdf(Digest::get<Digest::ID::SHA384>());
2024

2125
template<>
22-
const HKDF HKDF::instance<Digest::ID::SHA512> = make_hkdf(Digest::get<Digest::ID::SHA512>());
26+
const HKDF HKDF::instance<Digest::ID::SHA512> =
27+
make_hkdf(Digest::get<Digest::ID::SHA512>());
2328

2429
template<>
25-
const HKDF& HKDF::get<Digest::ID::SHA256>()
30+
const HKDF&
31+
HKDF::get<Digest::ID::SHA256>()
2632
{
2733
return HKDF::instance<Digest::ID::SHA256>;
2834
}
2935

3036
template<>
31-
const HKDF& HKDF::get<Digest::ID::SHA384>()
37+
const HKDF&
38+
HKDF::get<Digest::ID::SHA384>()
3239
{
3340
return HKDF::instance<Digest::ID::SHA384>;
3441
}
3542

3643
template<>
37-
const HKDF& HKDF::get<Digest::ID::SHA512>()
44+
const HKDF&
45+
HKDF::get<Digest::ID::SHA512>()
3846
{
3947
return HKDF::instance<Digest::ID::SHA512>;
4048
}

0 commit comments

Comments
 (0)