summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chip/g/crypto_api.c8
-rw-r--r--chip/g/dcrypto/app_cipher.c5
-rw-r--r--chip/g/upgrade_fw.c2
-rw-r--r--chip/host/dcrypto/app_cipher.c8
-rw-r--r--include/crypto_api.h4
-rw-r--r--test/nvmem.c6
6 files changed, 16 insertions, 17 deletions
diff --git a/chip/g/crypto_api.c b/chip/g/crypto_api.c
index 9c0c7bb8f5..075472238d 100644
--- a/chip/g/crypto_api.c
+++ b/chip/g/crypto_api.c
@@ -7,8 +7,8 @@
#include "crypto_api.h"
#include "dcrypto.h"
-void app_compute_hash(uint8_t *p_buf, size_t num_bytes,
- uint8_t *p_hash, size_t hash_len)
+void app_compute_hash(const void *p_buf, size_t num_bytes, void *p_hash,
+ size_t hash_len)
{
uint8_t sha1_digest[SHA_DIGEST_SIZE];
@@ -16,12 +16,12 @@ void app_compute_hash(uint8_t *p_buf, size_t num_bytes,
* Use the built in dcrypto engine to generate the sha1 hash of the
* buffer.
*/
- DCRYPTO_SHA1_hash((uint8_t *)p_buf, num_bytes, sha1_digest);
+ DCRYPTO_SHA1_hash(p_buf, num_bytes, sha1_digest);
memcpy(p_hash, sha1_digest, MIN(hash_len, sizeof(sha1_digest)));
if (hash_len > sizeof(sha1_digest))
- memset(p_hash + sizeof(sha1_digest), 0,
+ memset((uint8_t *)p_hash + sizeof(sha1_digest), 0,
hash_len - sizeof(sha1_digest));
}
diff --git a/chip/g/dcrypto/app_cipher.c b/chip/g/dcrypto/app_cipher.c
index e465598718..125b443ee6 100644
--- a/chip/g/dcrypto/app_cipher.c
+++ b/chip/g/dcrypto/app_cipher.c
@@ -323,7 +323,7 @@ static int command_loop(struct test_info *pinfo)
* Prepare the hash of the original data to be able to verify
* results.
*/
- DCRYPTO_SHA1_hash((uint8_t *)(pinfo->p), pinfo->test_blob_size, sha);
+ DCRYPTO_SHA1_hash(pinfo->p, pinfo->test_blob_size, sha);
/* Use the hash as an IV for the cipher. */
memcpy(sha_after, sha, sizeof(sha_after));
@@ -369,8 +369,7 @@ static int command_loop(struct test_info *pinfo)
return EC_ERROR_UNKNOWN;
}
- DCRYPTO_SHA1_hash((uint8_t *)(pinfo->p),
- pinfo->test_blob_size, sha_after);
+ DCRYPTO_SHA1_hash(pinfo->p, pinfo->test_blob_size, sha_after);
if (memcmp(sha, sha_after, sizeof(sha))) {
ccprintf("\n"
"sha1 before and after mismatch, %d to go!\n",
diff --git a/chip/g/upgrade_fw.c b/chip/g/upgrade_fw.c
index 276eac8f92..727af4b7d9 100644
--- a/chip/g/upgrade_fw.c
+++ b/chip/g/upgrade_fw.c
@@ -148,7 +148,7 @@ int usb_pdu_valid(struct upgrade_command *cmd_body, size_t cmd_size)
cmd.block_base);
/* Check if the block was received properly. */
- DCRYPTO_SHA1_hash((uint8_t *)&cmd_body->block_base,
+ DCRYPTO_SHA1_hash(&cmd_body->block_base,
body_size + sizeof(cmd_body->block_base),
sha1_digest);
if (memcmp(sha1_digest, &cmd_body->block_digest,
diff --git a/chip/host/dcrypto/app_cipher.c b/chip/host/dcrypto/app_cipher.c
index ab52484753..4c4809005c 100644
--- a/chip/host/dcrypto/app_cipher.c
+++ b/chip/host/dcrypto/app_cipher.c
@@ -6,8 +6,8 @@
#include "dcrypto.h"
#include "util.h"
-void app_compute_hash(uint8_t *p_buf, size_t num_bytes,
- uint8_t *p_hash, size_t hash_len)
+void app_compute_hash(const void *p_buf, size_t num_bytes, void *p_hash,
+ size_t hash_len)
{
uint8_t digest[SHA256_DIGEST_SIZE];
@@ -15,12 +15,12 @@ void app_compute_hash(uint8_t *p_buf, size_t num_bytes,
* Use the built in dcrypto engine to generate the sha1 hash of the
* buffer.
*/
- DCRYPTO_SHA256_hash((uint8_t *)p_buf, num_bytes, digest);
+ DCRYPTO_SHA256_hash(p_buf, num_bytes, digest);
memcpy(p_hash, digest, MIN(hash_len, sizeof(digest)));
if (hash_len > sizeof(digest))
- memset(p_hash + sizeof(digest), 0,
+ memset((uint8_t *)p_hash + sizeof(digest), 0,
hash_len - sizeof(digest));
}
diff --git a/include/crypto_api.h b/include/crypto_api.h
index 8a8ccacf99..d3e3cfaa4a 100644
--- a/include/crypto_api.h
+++ b/include/crypto_api.h
@@ -26,8 +26,8 @@ extern "C" {
* value exceeds SHA1 size (20 bytes), the rest of the
* hash is filled up with zeros.
*/
-void app_compute_hash(uint8_t *p_buf, size_t num_bytes,
- uint8_t *p_hash, size_t hash_len);
+void app_compute_hash(const void *p_buf, size_t num_bytes, void *p_hash,
+ size_t hash_len);
#define CIPHER_SALT_SIZE 16
diff --git a/test/nvmem.c b/test/nvmem.c
index c07637e8de..80ea75479b 100644
--- a/test/nvmem.c
+++ b/test/nvmem.c
@@ -63,8 +63,8 @@ int app_cipher(const void *salt_p, void *out_p, const void *in_p, size_t size)
return 1;
}
-void app_compute_hash(uint8_t *p_buf, size_t num_bytes,
- uint8_t *p_hash, size_t hash_bytes)
+void app_compute_hash(const void *p_buf, size_t num_bytes, void *p_hash,
+ size_t hash_bytes)
{
uint32_t crc;
uint32_t *p_data;
@@ -95,7 +95,7 @@ void app_compute_hash(uint8_t *p_buf, size_t num_bytes,
for (n = 0; n < hash_bytes; n += sizeof(crc)) {
size_t copy_bytes = MIN(sizeof(crc), hash_bytes - n);
- memcpy(p_hash + n, &crc, copy_bytes);
+ memcpy((uint8_t *)p_hash + n, &crc, copy_bytes);
}
}