Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 15440b2

Browse files
ci(pre-commit): Apply automatic fixes
1 parent 50a3db2 commit 15440b2

File tree

13 files changed

+576
-591
lines changed

13 files changed

+576
-591
lines changed

‎cores/esp32/HashBuilder.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@
2828
* try go a bit further by storing the first octet (now zero) to make this even
2929
* a bit more difficult to optimize out. Once memset_s() is available, that
3030
* could be used here instead. */
31-
static void * (* const volatile memset_func)(void *, int, size_t) = memset;
31+
static void *(*const volatile memset_func)(void *, int, size_t) = memset;
3232
static uint8_t forced_memzero_val;
3333

34-
static inline void forced_memzero(void *ptr, size_t len)
35-
{
34+
static inline void forced_memzero(void *ptr, size_t len) {
3635
memset_func(ptr, 0, len);
3736
if (len) {
38-
forced_memzero_val = ((uint8_t *)ptr)[0];
37+
forced_memzero_val = ((uint8_t *)ptr)[0];
3938
}
4039
}
4140

‎cores/esp32/MD5Builder.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class MD5Builder : public HashBuilder {
4444
void getBytes(uint8_t *output) override;
4545
void getChars(char *output) override;
4646
String toString(void) override;
47-
size_t getHashSize() const override { return ESP_ROM_MD5_DIGEST_LEN; }
47+
size_t getHashSize() const override {
48+
return ESP_ROM_MD5_DIGEST_LEN;
49+
}
4850
};
4951

5052
#endif

‎libraries/Hash/examples/PBKDF2_HMAC/PBKDF2_HMAC.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ void setup() {
5959
SHA1Builder sha1;
6060
PBKDF2_HMACBuilder pbkdf2(&sha1);
6161

62-
const char* password = "password";
63-
const char* salt = "salt";
62+
const char *password = "password";
63+
const char *salt = "salt";
6464

6565
pbkdf2.begin();
6666
pbkdf2.setPassword(password);
@@ -128,11 +128,11 @@ void setup() {
128128
// Test 4: PBKDF2-HMAC-SHA1 with byte arrays
129129
Serial.println("\n4. PBKDF2-HMAC-SHA1 Test (byte arrays)");
130130
{
131-
SHA1Builder sha1; // or any other hash algorithm based on HashBuilder
131+
SHA1Builder sha1; // or any other hash algorithm based on HashBuilder
132132
PBKDF2_HMACBuilder pbkdf2(&sha1);
133133

134-
uint8_t password[] = {0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64}; // "password" in bytes
135-
uint8_t salt[] = {0x73, 0x61, 0x6c, 0x74}; // "salt" in bytes
134+
uint8_t password[] = {0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64}; // "password" in bytes
135+
uint8_t salt[] = {0x73, 0x61, 0x6c, 0x74}; // "salt" in bytes
136136

137137
pbkdf2.begin();
138138
pbkdf2.setPassword(password, sizeof(password));

‎libraries/Hash/examples/SHA2/SHA2.ino

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
#include <SHA2Builder.h>
1616

1717
// Expected hash values for validation
18-
const char* EXPECTED_HELLO_WORLD_SHA256 = "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e";
19-
const char* EXPECTED_HELLO_WORLD_SHA512 = "2c74fd17edafd80e8447b0d46741ee243b7eb74dd2149a0ab1b9246fb30382f27e853d8585719e0e67cbda0daa8f51671064615d645ae27acb15bfb1447f459b";
20-
const char* EXPECTED_TEST_MESSAGE_SHA224 = "155b033d801d4dd59b783d76ac3059053c00b2c28340a5a36a427a76";
21-
const char* EXPECTED_TEST_MESSAGE_SHA384 = "efd336618cbc96551936e5897e6af391d2480513ff8d4fc744e34462edb3111477d2b889c4d5e80e23b5f9d1b636fbd7";
18+
const char *EXPECTED_HELLO_WORLD_SHA256 = "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e";
19+
const char *EXPECTED_HELLO_WORLD_SHA512 =
20+
"2c74fd17edafd80e8447b0d46741ee243b7eb74dd2149a0ab1b9246fb30382f27e853d8585719e0e67cbda0daa8f51671064615d645ae27acb15bfb1447f459b";
21+
const char *EXPECTED_TEST_MESSAGE_SHA224 = "155b033d801d4dd59b783d76ac3059053c00b2c28340a5a36a427a76";
22+
const char *EXPECTED_TEST_MESSAGE_SHA384 = "efd336618cbc96551936e5897e6af391d2480513ff8d4fc744e34462edb3111477d2b889c4d5e80e23b5f9d1b636fbd7";
2223

2324
// Validation function
24-
bool validateHash(const String& calculated, const char* expected, const String& test_name) {
25+
bool validateHash(const String &calculated, const char *expected, const String &test_name) {
2526
bool passed = (calculated == expected);
2627
Serial.print(test_name);
2728
Serial.print(": ");

‎libraries/Hash/examples/SHA3/SHA3.ino

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
#include <SHA3Builder.h>
1616

1717
// Expected hash values for validation
18-
const char* EXPECTED_HELLO_WORLD_SHA3_256 = "e167f68d6563d75bb25f3aa49c29ef612d41352dc00606de7cbd630bb2665f51";
19-
const char* EXPECTED_HELLO_WORLD_SHA3_512 = "3d58a719c6866b0214f96b0a67b37e51a91e233ce0be126a08f35fdf4c043c6126f40139bfbc338d44eb2a03de9f7bb8eff0ac260b3629811e389a5fbee8a894";
20-
const char* EXPECTED_TEST_MESSAGE_SHA3_224 = "27af391bcb3b86f21b73c42c4abbde4791c395dc650243eede85de0c";
21-
const char* EXPECTED_TEST_MESSAGE_SHA3_384 = "adb18f6b164672c566950bfefa48c5a851d48ee184f249a19e723d753b7536fcd048c3443aff7ebe433fce63c81726ea";
18+
const char *EXPECTED_HELLO_WORLD_SHA3_256 = "e167f68d6563d75bb25f3aa49c29ef612d41352dc00606de7cbd630bb2665f51";
19+
const char *EXPECTED_HELLO_WORLD_SHA3_512 =
20+
"3d58a719c6866b0214f96b0a67b37e51a91e233ce0be126a08f35fdf4c043c6126f40139bfbc338d44eb2a03de9f7bb8eff0ac260b3629811e389a5fbee8a894";
21+
const char *EXPECTED_TEST_MESSAGE_SHA3_224 = "27af391bcb3b86f21b73c42c4abbde4791c395dc650243eede85de0c";
22+
const char *EXPECTED_TEST_MESSAGE_SHA3_384 = "adb18f6b164672c566950bfefa48c5a851d48ee184f249a19e723d753b7536fcd048c3443aff7ebe433fce63c81726ea";
2223

2324
// Validation function
24-
bool validateHash(const String& calculated, const char* expected, const String& test_name) {
25+
bool validateHash(const String &calculated, const char *expected, const String &test_name) {
2526
bool passed = (calculated == expected);
2627
Serial.print(test_name);
2728
Serial.print(": ");

‎libraries/Hash/examples/SHA3Stream/SHA3Stream.ino

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
#include <Stream.h>
2121

2222
// Expected hash values for validation
23-
const char* EXPECTED_STREAM_TEST_SHA3_256 = "7094efc774885c7a785b408c5da86636cb8adc79156c0f162c6fd7e49f4c505e";
24-
const char* EXPECTED_MAX_SHA3_224_FULL = "ad0e69e04a7258d7cab4272a08ac69f8b43f4e45f9c49c9abb0628af";
25-
const char* EXPECTED_MAX_SHA3_224_10 = "9b55096e998cda6b96d3f2828c4ccda8c9964a1ad98989fb8b0fcd26";
26-
const char* EXPECTED_COMBINED_SHA3_256 = "4a32307fe03bf9f600c5d124419985fd4d42c1639e6a23ab044f107c3b95a189";
23+
const char *EXPECTED_STREAM_TEST_SHA3_256 = "7094efc774885c7a785b408c5da86636cb8adc79156c0f162c6fd7e49f4c505e";
24+
const char *EXPECTED_MAX_SHA3_224_FULL = "ad0e69e04a7258d7cab4272a08ac69f8b43f4e45f9c49c9abb0628af";
25+
const char *EXPECTED_MAX_SHA3_224_10 = "9b55096e998cda6b96d3f2828c4ccda8c9964a1ad98989fb8b0fcd26";
26+
const char *EXPECTED_COMBINED_SHA3_256 = "4a32307fe03bf9f600c5d124419985fd4d42c1639e6a23ab044f107c3b95a189";
2727

2828
// Validation function
29-
bool validateHash(const String& calculated, const char* expected, const String& test_name) {
29+
bool validateHash(const String &calculated, const char *expected, const String &test_name) {
3030
bool passed = (calculated == expected);
3131
Serial.print(test_name);
3232
Serial.print(": ");
@@ -66,7 +66,7 @@ public:
6666
}
6767

6868
virtual size_t write(uint8_t) override {
69-
return 0; // Read-only stream
69+
return 0; // Read-only stream
7070
}
7171

7272
size_t length() {
@@ -91,9 +91,9 @@ void setup() {
9191
{
9292
Serial.println("\n1. Hashing data from a custom stream:");
9393

94-
const char* test_data = "This is a test message for streaming hash calculation. "
95-
"It contains multiple sentences to demonstrate how the "
96-
"addStream method processes data in chunks.";
94+
const char *test_data = "This is a test message for streaming hash calculation. "
95+
"It contains multiple sentences to demonstrate how the "
96+
"addStream method processes data in chunks.";
9797

9898
TestStream stream(test_data);
9999

@@ -112,7 +112,7 @@ void setup() {
112112
{
113113
Serial.println("\n2. Comparing different maximum lengths with streams:");
114114

115-
const char* test_data = "Streaming hash test with different maximum lengths";
115+
const char *test_data = "Streaming hash test with different maximum lengths";
116116
TestStream stream(test_data);
117117

118118
// SHA3-224 with a hardcoded maximum length
@@ -138,7 +138,7 @@ void setup() {
138138
{
139139
Serial.println("\n3. Combining add() and addStream():");
140140

141-
const char* stream_data = "Additional data from stream";
141+
const char *stream_data = "Additional data from stream";
142142
TestStream stream(stream_data);
143143

144144
SHA3_256Builder sha3_256;

‎libraries/Hash/src/PBKDF2_HMACBuilder.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// Block size for HMAC (64 bytes for SHA-1, SHA-256, SHA-512)
1919
#define HMAC_BLOCK_SIZE 64
2020

21-
PBKDF2_HMACBuilder::PBKDF2_HMACBuilder(HashBuilder* hash, String password, String salt, uint32_t iterations) {
21+
PBKDF2_HMACBuilder::PBKDF2_HMACBuilder(HashBuilder *hash, String password, String salt, uint32_t iterations) {
2222
this->hashBuilder = hash;
2323
this->hashSize = hashBuilder->getHashSize();
2424
this->iterations = iterations;
@@ -55,10 +55,10 @@ void PBKDF2_HMACBuilder::clearData() {
5555
calculated = false;
5656
}
5757

58-
void PBKDF2_HMACBuilder::hmac(const uint8_t* key, size_t keyLen, const uint8_t* data, size_t dataLen, uint8_t* output) {
58+
void PBKDF2_HMACBuilder::hmac(const uint8_t *key, size_t keyLen, const uint8_t *data, size_t dataLen, uint8_t *output) {
5959
uint8_t keyPad[HMAC_BLOCK_SIZE];
6060
uint8_t outerPad[HMAC_BLOCK_SIZE];
61-
uint8_t innerHash[64]; // Large enough for any hash
61+
uint8_t innerHash[64]; // Large enough for any hash
6262

6363
// Prepare key
6464
if (keyLen > HMAC_BLOCK_SIZE) {
@@ -166,7 +166,7 @@ String PBKDF2_HMACBuilder::toString() {
166166
}
167167

168168
// PBKDF2 specific methods
169-
void PBKDF2_HMACBuilder::setPassword(const uint8_t* password, size_t len) {
169+
void PBKDF2_HMACBuilder::setPassword(const uint8_t *password, size_t len) {
170170
if (this->password != nullptr) {
171171
forced_memzero(this->password, len);
172172
delete[] this->password;
@@ -177,15 +177,15 @@ void PBKDF2_HMACBuilder::setPassword(const uint8_t* password, size_t len) {
177177
calculated = false;
178178
}
179179

180-
void PBKDF2_HMACBuilder::setPassword(const char* password) {
181-
setPassword((const uint8_t*)password, strlen(password));
180+
void PBKDF2_HMACBuilder::setPassword(const char *password) {
181+
setPassword((const uint8_t*)password, strlen(password));
182182
}
183183

184184
void PBKDF2_HMACBuilder::setPassword(String password) {
185-
setPassword((const uint8_t*)password.c_str(), password.length());
185+
setPassword((const uint8_t*)password.c_str(), password.length());
186186
}
187187

188-
void PBKDF2_HMACBuilder::setSalt(const uint8_t* salt, size_t len) {
188+
void PBKDF2_HMACBuilder::setSalt(const uint8_t *salt, size_t len) {
189189
if (this->salt != nullptr) {
190190
forced_memzero(this->salt, len);
191191
delete[] this->salt;
@@ -196,32 +196,32 @@ void PBKDF2_HMACBuilder::setSalt(const uint8_t* salt, size_t len) {
196196
calculated = false;
197197
}
198198

199-
void PBKDF2_HMACBuilder::setSalt(const char* salt) {
200-
setSalt((const uint8_t*)salt, strlen(salt));
199+
void PBKDF2_HMACBuilder::setSalt(const char *salt) {
200+
setSalt((const uint8_t*)salt, strlen(salt));
201201
}
202202

203203
void PBKDF2_HMACBuilder::setSalt(String salt) {
204-
setSalt((const uint8_t*)salt.c_str(), salt.length());
204+
setSalt((const uint8_t*)salt.c_str(), salt.length());
205205
}
206206

207207
void PBKDF2_HMACBuilder::setIterations(uint32_t iterations) {
208208
this->iterations = iterations;
209209
}
210210

211-
void PBKDF2_HMACBuilder::setHashAlgorithm(HashBuilder* hash) {
211+
void PBKDF2_HMACBuilder::setHashAlgorithm(HashBuilder *hash) {
212212
// Set the hash algorithm to use for the HMAC
213213
// Note: We don't delete hashBuilder here as it might be owned by the caller
214214
// The caller is responsible for managing the hashBuilder lifetime
215215
hashBuilder = hash;
216216
hashSize = hashBuilder->getHashSize();
217217
}
218218

219-
void PBKDF2_HMACBuilder::pbkdf2_hmac(constuint8_t* password, size_t passwordLen,
220-
constuint8_t* salt, size_t saltLen,
221-
uint32_t iterations, uint8_t* output, size_t outputLen) {
222-
uint8_t u1[64]; // Large enough for any hash
219+
void PBKDF2_HMACBuilder::pbkdf2_hmac(
220+
constuint8_t *password, size_t passwordLen, constuint8_t *salt, size_t saltLen, uint32_t iterations, uint8_t *output, size_t outputLen
221+
) {
222+
uint8_t u1[64]; // Large enough for any hash
223223
uint8_t u2[64];
224-
uint8_t saltWithBlock[256]; // Salt + block number
224+
uint8_t saltWithBlock[256]; // Salt + block number
225225
uint8_t block[64];
226226

227227
size_t blocks = (outputLen + hashSize - 1) / hashSize;

‎libraries/Hash/src/PBKDF2_HMACBuilder.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,30 @@
2121

2222
class PBKDF2_HMACBuilder : public HashBuilder {
2323
private:
24-
HashBuilder* hashBuilder;
24+
HashBuilder *hashBuilder;
2525
size_t hashSize;
2626
uint32_t iterations;
2727

2828
// Password and salt storage
29-
uint8_t* password;
29+
uint8_t *password;
3030
size_t passwordLen;
31-
uint8_t* salt;
31+
uint8_t *salt;
3232
size_t saltLen;
3333

3434
// Output storage
35-
uint8_t* derivedKey;
35+
uint8_t *derivedKey;
3636
size_t derivedKeyLen;
3737
bool calculated;
3838

39-
void hmac(const uint8_t* key, size_t keyLen, const uint8_t* data, size_t dataLen, uint8_t* output);
40-
void pbkdf2_hmac(const uint8_t* password, size_t passwordLen,
41-
const uint8_t* salt, size_t saltLen,
42-
uint32_t iterations, uint8_t* output, size_t outputLen);
39+
void hmac(const uint8_t *key, size_t keyLen, const uint8_t *data, size_t dataLen, uint8_t *output);
40+
void pbkdf2_hmac(const uint8_t *password, size_t passwordLen, const uint8_t *salt, size_t saltLen, uint32_t iterations, uint8_t *output, size_t outputLen);
4341
void clearData();
4442

4543
public:
4644
using HashBuilder::add;
4745

4846
// Constructor takes a hash builder instance
49-
PBKDF2_HMACBuilder(HashBuilder* hash, String password = "", String salt = "", uint32_t iterations = 10000);
47+
PBKDF2_HMACBuilder(HashBuilder *hash, String password = "", String salt = "", uint32_t iterations = 10000);
5048
~PBKDF2_HMACBuilder();
5149

5250
// Standard HashBuilder interface
@@ -57,17 +55,19 @@ class PBKDF2_HMACBuilder : public HashBuilder {
5755
void getBytes(uint8_t *output) override;
5856
void getChars(char *output) override;
5957
String toString() override;
60-
size_t getHashSize() const override { return derivedKeyLen; }
58+
size_t getHashSize() const override {
59+
return derivedKeyLen;
60+
}
6161

6262
// PBKDF2 specific methods
63-
void setPassword(const uint8_t* password, size_t len);
64-
void setPassword(const char* password);
63+
void setPassword(const uint8_t *password, size_t len);
64+
void setPassword(const char *password);
6565
void setPassword(String password);
66-
void setSalt(const uint8_t* salt, size_t len);
67-
void setSalt(const char* salt);
66+
void setSalt(const uint8_t *salt, size_t len);
67+
void setSalt(const char *salt);
6868
void setSalt(String salt);
6969
void setIterations(uint32_t iterations);
70-
void setHashAlgorithm(HashBuilder* hash);
70+
void setHashAlgorithm(HashBuilder *hash);
7171
};
7272

7373
#endif

‎libraries/Hash/src/SHA1Builder.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ class SHA1Builder : public HashBuilder {
4343
void getBytes(uint8_t *output) override;
4444
void getChars(char *output) override;
4545
String toString() override;
46-
size_t getHashSize() const override { return SHA1_HASH_SIZE; }
46+
size_t getHashSize() const override {
47+
return SHA1_HASH_SIZE;
48+
}
4749
};
4850

4951
#endif

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /