Skip to content

Commit ebad819

Browse files
titouancjhedberg
authored andcommitted
crypto: hash: in_buf should be constant
Hashing takes an input buffer, and writes the result in a separate output buffer. Therefore, the input can be marked as constant, so that constants can be supplied directly to the hashing context without any intermediate copy, and without having to perform a type-unsafe cast from (const uint8_t *) to (uint8_t *) Signed-off-by: Titouan Christophe <[email protected]>
1 parent c21b6d9 commit ebad819

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

doc/releases/migration-guide-4.3.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,13 @@ Cellular
334334
* :c:enum:`cellular_access_technology` values have been redefined to align with 3GPP TS 27.007.
335335
* :c:enum:`cellular_registration_status` values have been extended to align with 3GPP TS 27.007.
336336

337+
Crypto
338+
======
339+
340+
* Hashing operations now require a constant input in the :c:struct:`hash_pkt`.
341+
This shouldn't affect any existing code, unless an out-of-tree hashing backend actually
342+
performs that operation in-place (see :github:`94218`)
343+
337344
Flash Map
338345
=========
339346

doc/releases/release-notes-4.3.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ API Changes
5151
..
5252
Only removed, deprecated and new APIs, changes go in migration guide.
5353
54+
* Crypto
55+
56+
* The input buffer in :c:struct:`hash_pkt` is now constant
57+
5458
Removed APIs and options
5559
========================
5660

include/zephyr/crypto/hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct hash_ctx {
8888
struct hash_pkt {
8989

9090
/** Start address of input buffer */
91-
uint8_t *in_buf;
91+
const uint8_t *in_buf;
9292

9393
/** Bytes to be operated upon */
9494
size_t in_len;

0 commit comments

Comments
 (0)