Skip to content

Commit 3f9332f

Browse files
committed
Make hw_crypto functions static
As the hw_crypto functions are only referenced in the init function at the end of the file, we can make them static.
1 parent 5dc0138 commit 3f9332f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

examples/esp32/components/hw_crypto/hw_crypto.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
#include <mbedtls/sha256.h>
1818
#include <mbedtls/sha512.h>
1919

20-
void sha256(const uint8_t *data, size_t data_len, uint8_t *hash) {
20+
static void sha256(const uint8_t *data, size_t data_len, uint8_t *hash) {
2121
int r = mbedtls_sha256(data, data_len, hash, 0);
2222
if (r != 0) {
2323
printf("sha256 failed with %d\n", r);
2424
}
2525
}
2626

27-
void sha512(const uint8_t *data, size_t data_len, uint8_t *hash) {
27+
static void sha512(const uint8_t *data, size_t data_len, uint8_t *hash) {
2828
int r = mbedtls_sha512(data, data_len, hash, 0);
2929
if (r != 0) {
3030
printf("sha512 failed with %d\n", r);
3131
}
3232
}
3333

34-
int aes_gcm_encrypt(
34+
static int aes_gcm_encrypt(
3535
const uint8_t *key, size_t key_len,
3636
const uint8_t *iv, size_t iv_len,
3737
const uint8_t *plaintext, size_t plaintext_len,
@@ -68,7 +68,7 @@ int aes_gcm_encrypt(
6868
return 0;
6969
}
7070

71-
int aes_gcm_decrypt(
71+
static int aes_gcm_decrypt(
7272
const uint8_t *key, size_t key_len,
7373
const uint8_t *iv, size_t iv_len,
7474
const uint8_t *ciphertext, size_t ciphertext_len,

examples/nrf52/hw_crypto/hw_crypto.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#ifdef USE_HW_CRYPTO
2121

22-
void sha256(const uint8_t *data, size_t data_len, uint8_t *hash) {
22+
static void sha256(const uint8_t *data, size_t data_len, uint8_t *hash) {
2323
size_t olen; // We actually do not do anything with this parameter, but the API requires it.
2424
psa_status_t status = psa_hash_compute(
2525
PSA_ALG_SHA_256,
@@ -32,7 +32,7 @@ void sha256(const uint8_t *data, size_t data_len, uint8_t *hash) {
3232
assert(status == PSA_SUCCESS);
3333
}
3434

35-
void sha512(const uint8_t *data, size_t data_len, uint8_t *hash) {
35+
static void sha512(const uint8_t *data, size_t data_len, uint8_t *hash) {
3636
size_t olen; // We actually do not do anything with this parameter, but the API requires it.
3737
psa_status_t status = psa_hash_compute(
3838
PSA_ALG_SHA_512,
@@ -45,7 +45,7 @@ void sha512(const uint8_t *data, size_t data_len, uint8_t *hash) {
4545
assert(status == PSA_SUCCESS);
4646
}
4747

48-
int aes_gcm_encrypt(
48+
static int aes_gcm_encrypt(
4949
const uint8_t *key, size_t key_len,
5050
const uint8_t *iv, size_t iv_len,
5151
const uint8_t *plaintext, size_t plaintext_len,
@@ -111,7 +111,7 @@ int aes_gcm_encrypt(
111111
return ret;
112112
}
113113

114-
int aes_gcm_decrypt(
114+
static int aes_gcm_decrypt(
115115
const uint8_t *key, size_t key_len,
116116
const uint8_t *iv, size_t iv_len,
117117
const uint8_t *ciphertext, size_t ciphertext_len,
@@ -187,7 +187,7 @@ int aes_gcm_decrypt(
187187
return ret;
188188
}
189189

190-
void ed25519_sign(
190+
static void ed25519_sign(
191191
uint8_t *signature,
192192
const uint8_t *secret_key,
193193
const uint8_t *message,
@@ -243,7 +243,7 @@ void ed25519_sign(
243243
assert(ret == 0);
244244
}
245245

246-
int ed25519_verify(
246+
static int ed25519_verify(
247247
const uint8_t *signature,
248248
const uint8_t *public_key,
249249
const uint8_t *message,

0 commit comments

Comments
 (0)