Skip to content

Commit b677e82

Browse files
titouancjhedberg
authored andcommitted
drivers: crypto: hash_pkt.in_buf is now constant
Previous commit made the input buffer of the hash packet constant. Let's therefore adapt typing where used, and remove inappropriate casts of constant buffers to non-constant ones. All the "backend" hashing functions already take a constant input, these changes only affect the "plumbing" between the Zephyr crypto API and the actual implementation where applicable. Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
1 parent ebad819 commit b677e82

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

drivers/crypto/crypto_mchp_xec_symcr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static int xec_symcr_do_hash(struct hash_ctx *ctx, struct hash_pkt *pkt, bool fi
358358
hs->blklen = 0; /* consumed */
359359
}
360360

361-
ret = mchp_xec_rom_hash_feed_wrapper(c, (const uint8_t *)pkt->in_buf, fill_len);
361+
ret = mchp_xec_rom_hash_feed_wrapper(c, pkt->in_buf, fill_len);
362362
if (ret) {
363363
LOG_ERR("ROM hash feed error %d", ret);
364364
return ret;

drivers/crypto/crypto_rts5912_sha.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static int rts5912_sha256_process(const struct device *dev, uint8_t *input, size
122122
return 0;
123123
}
124124

125-
static int rts5912_sha256_update(const struct device *dev, uint8_t *input, size_t len)
125+
static int rts5912_sha256_update(const struct device *dev, const uint8_t *input, size_t len)
126126
{
127127
struct rts5912_sha256_context *rts5912_sha256_ctx = dev->data;
128128
uint32_t remain, fill, blk_size = 0, ret_val = 0;

drivers/crypto/crypto_smartbond.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static int crypto_smartbond_hash_set_algo(enum hash_algo algo)
390390
return 0;
391391
}
392392

393-
static int crypto_smartbond_set_in_out_buf(uint8_t *in_buf, uint8_t *out_buf, int len)
393+
static int crypto_smartbond_set_in_out_buf(const uint8_t *in_buf, uint8_t *out_buf, int len)
394394
{
395395
if (in_buf == NULL) {
396396
return -EIO;

samples/boards/microchip/mec172xevb_assy6906/rom_api/src/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ static int test_zephyr_hash_chunk_block_size(const struct hash_tp *htbl, size_t
441441
/* SHA algorithms block sizes are powers of 2 */
442442
updatesz = msgsz & ~(blocksz - 1u);
443443
printf(" Update size is %d\n", updatesz);
444-
zhash_pkt.in_buf = (uint8_t *)msgptr;
444+
zhash_pkt.in_buf = msgptr;
445445
zhash_pkt.in_len = updatesz;
446446
zhash_pkt.out_buf = digest;
447447
zhash_pkt.ctx = &zhash_ctx;
@@ -459,7 +459,7 @@ static int test_zephyr_hash_chunk_block_size(const struct hash_tp *htbl, size_t
459459

460460
printf(" Final size is %u\n", msgsz);
461461

462-
zhash_pkt.in_buf = (uint8_t *)msgptr;
462+
zhash_pkt.in_buf = msgptr;
463463
zhash_pkt.in_len = msgsz;
464464
zhash_pkt.out_buf = digest;
465465
zhash_pkt.ctx = &zhash_ctx;
@@ -536,7 +536,7 @@ static int test_zephyr_hash_chunk(const struct hash_tp *htbl, size_t nentries, s
536536
while (chunksz && ((msgsz - total_updatesz) > chunksz)) {
537537
chunk_cnt++;
538538

539-
zhash_pkt.in_buf = (uint8_t *)msgptr;
539+
zhash_pkt.in_buf = msgptr;
540540
zhash_pkt.in_len = updatesz;
541541
zhash_pkt.out_buf = digest;
542542
zhash_pkt.ctx = &zhash_ctx;
@@ -553,7 +553,7 @@ static int test_zephyr_hash_chunk(const struct hash_tp *htbl, size_t nentries, s
553553
}
554554

555555
remsz = msgsz - total_updatesz;
556-
zhash_pkt.in_buf = (uint8_t *)msgptr;
556+
zhash_pkt.in_buf = msgptr;
557557
zhash_pkt.in_len = remsz;
558558
zhash_pkt.out_buf = digest;
559559
zhash_pkt.ctx = &zhash_ctx;

0 commit comments

Comments
 (0)