-
Notifications
You must be signed in to change notification settings - Fork 147
Fixes 20260330 #740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fixes 20260330 #740
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5d0b224
Fix SDHCI response bit span check
danielinux b28a97e
Fix PKCS11 init state typo
danielinux ae7d23b
Fix stm32h5 OTP readonly block rounding
danielinux 984ee1f
Fix store header search bounds
danielinux 0039c8d
Reject oversized TPM ROT auth input
danielinux 2abf80a
Guard TPM keystore auth in check_rot
danielinux 43b485f
Validate FDT string offsets
danielinux 49106ca
Updated .gitignore: add new unit test binaries
danielinux 918e00c
Rebased, addressed comments
danielinux 02b88c0
Move variable to its usage block
danielinux cfbc3f0
Up to latest emulator container
danielinux 6b6d27d
PKCS11 test: use pre-provisioned key to make test deterministic
danielinux 909fbeb
(review comment) remove hal_otp.h
danielinux d7e56d5
Address copilot comments
danielinux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
mattia-moffa marked this conversation as resolved.
Outdated
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* hal_otp.h | ||
| * | ||
| * OTP helper definitions. | ||
| * | ||
| * Copyright (C) 2026 wolfSSL Inc. | ||
| * | ||
| * This file is part of wolfBoot. | ||
| * | ||
| * wolfBoot is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * wolfBoot is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA | ||
| */ | ||
|
|
||
| #ifndef WOLFBOOT_HAL_OTP_H | ||
| #define WOLFBOOT_HAL_OTP_H | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| static inline uint32_t hal_otp_blocks_for_length(uint32_t length, | ||
| uint32_t block_size) | ||
| { | ||
| return (length + block_size - 1U) / block_size; | ||
| } | ||
|
|
||
|
danielinux marked this conversation as resolved.
Outdated
|
||
| #endif /* WOLFBOOT_HAL_OTP_H */ | ||
|
danielinux marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /* unit-fdt.c | ||
| * | ||
| * Unit tests for flattened device tree helpers. | ||
| * | ||
| * Copyright (C) 2026 wolfSSL Inc. | ||
| * | ||
| * This file is part of wolfBoot. | ||
| * | ||
| * wolfBoot is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * wolfBoot is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA | ||
| */ | ||
|
danielinux marked this conversation as resolved.
|
||
|
|
||
| #include <check.h> | ||
| #include <stdint.h> | ||
| #include <string.h> | ||
|
|
||
| #include "../../include/fdt.h" | ||
|
|
||
| void wolfBoot_printf(const char *fmt, ...) | ||
| { | ||
| (void)fmt; | ||
| } | ||
|
|
||
| START_TEST(test_fdt_get_string_rejects_out_of_range_offset) | ||
| { | ||
| struct { | ||
| struct fdt_header hdr; | ||
| char strings[8]; | ||
| char after[4]; | ||
| } blob; | ||
| int len = 1234; | ||
| const char *s; | ||
|
|
||
| memset(&blob, 0, sizeof(blob)); | ||
| fdt_set_off_dt_strings(&blob, sizeof(blob.hdr)); | ||
| fdt_set_size_dt_strings(&blob, sizeof(blob.strings)); | ||
| memcpy(blob.strings, "chosen", sizeof("chosen")); | ||
| blob.after[0] = 'X'; | ||
| blob.after[1] = '\0'; | ||
|
|
||
| s = fdt_get_string(&blob, (int)sizeof(blob.strings), &len); | ||
|
|
||
| ck_assert_ptr_null(s); | ||
| ck_assert_int_eq(len, -FDT_ERR_BADOFFSET); | ||
| } | ||
| END_TEST | ||
|
|
||
| START_TEST(test_fdt_get_string_returns_string_with_valid_offset) | ||
| { | ||
| struct { | ||
| struct fdt_header hdr; | ||
| char strings[16]; | ||
| } blob; | ||
| int len = -1; | ||
| const char *s; | ||
|
|
||
| memset(&blob, 0, sizeof(blob)); | ||
| fdt_set_off_dt_strings(&blob, sizeof(blob.hdr)); | ||
| fdt_set_size_dt_strings(&blob, sizeof(blob.strings)); | ||
| memcpy(blob.strings, "serial\0console\0", 15); | ||
|
|
||
| s = fdt_get_string(&blob, 7, &len); | ||
|
|
||
| ck_assert_ptr_nonnull(s); | ||
| ck_assert_str_eq(s, "console"); | ||
| ck_assert_int_eq(len, 7); | ||
| } | ||
| END_TEST | ||
|
|
||
| static Suite *fdt_suite(void) | ||
| { | ||
| Suite *s = suite_create("fdt"); | ||
| TCase *tc = tcase_create("fdt"); | ||
|
|
||
| tcase_add_test(tc, test_fdt_get_string_rejects_out_of_range_offset); | ||
| tcase_add_test(tc, test_fdt_get_string_returns_string_with_valid_offset); | ||
| suite_add_tcase(s, tc); | ||
|
|
||
| return s; | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| int fails; | ||
| Suite *s = fdt_suite(); | ||
| SRunner *sr = srunner_create(s); | ||
|
|
||
| srunner_run_all(sr, CK_NORMAL); | ||
| fails = srunner_ntests_failed(sr); | ||
| srunner_free(sr); | ||
|
|
||
| return fails; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.