-
Notifications
You must be signed in to change notification settings - Fork 133
Improve user settings detection #635
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,51 @@ | ||
| # Key Tools for signing and key generation | ||
|
|
||
| See documentation [here](../../docs/Signing.md). | ||
| ## Sign | ||
|
|
||
| See [code file `./tools/keytools/sign.c`](./sign.c) and documentation in [docs/Signing.md](../../docs/Signing.md). | ||
|
|
||
| ## KeyGen and KeyStore | ||
|
|
||
| See [code file `./tools/keytools/keygen.c`](./keygen.c) and documentation [docs/keystore.md](../../docs/keystore.md). | ||
|
|
||
| ## Flash OTP Keystore Generation, Primer, Startup | ||
|
|
||
| See documentation [docs/flash-OTP.md](../../docs/flash-OTP.md). | ||
|
|
||
| ### Keystore Generation | ||
|
|
||
| Pack public keys into a single binary (`otp.bin`) formatted the way wolfBoot expects for | ||
| provisioning the device�s OTP/NVM keystore. No signing, no encryption�just a correctly laid-out image | ||
| with a header plus fixed-size "slots" for each key. | ||
|
|
||
| See [code file `./tools/keytools/otp/otp-keystore-gen.c`](./otp/otp-keystore-gen.c) | ||
|
|
||
| ### Flash OTP Primer | ||
|
|
||
| See [code file `./tools/keytools/otp/otp-keystore-primer.c`](./otp/otp-keystore-primer.c) | ||
|
|
||
| ## Flash OTP Startup | ||
|
|
||
| See [code file `./tools/keytools/otp/startup.c`](./otp/startup.c) | ||
|
|
||
|
|
||
| ## Quick Start (Linux) | ||
|
|
||
| ``` | ||
| make wolfboot_signing_private_key.der SIGN=ED25519 | ||
|
|
||
| # or | ||
|
|
||
| ./tools/keytools/keygen --ed25519 -g wolfboot_signing_private_key.der | ||
| ``` | ||
|
|
||
| ## Debugging and Development | ||
|
|
||
| ### `DEBUG_SIGNTOOL` | ||
|
|
||
| Enables additional diagnostic messages that may be useful during development and initial bring-up. | ||
|
|
||
| ### `WOLFBOOT_SHOW_INCLUDE` | ||
|
|
||
| Enables compile-time verbosity to indicate which `user_settings.h` file is being used. | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,26 @@ | |
| #endif | ||
|
|
||
| #include "wolfboot/wolfboot.h" | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this section, do not touch otp-keystore-gen tool, as discussed. No mixing user_settings.h is happening here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, I previously misunderstood; I thought it was only the primer: I'll also leave alone
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll close #634 that is only related to otp. |
||
| /* During development in new environment, ensure the expected user settings is used: */ | ||
| #ifdef DEBUG_SIGNTOOL | ||
| #ifdef __WOLFBOOT | ||
| # ifndef WOLFBOOT_USER_SETTINGS_H | ||
| # error "otp-keystore-gen encountered unexpected user settings, expected [WOLFBOOT_ROOT]/include/user_settings.h" | ||
| # endif | ||
| # ifdef WOLFBOOT_KEYTOOLS_USER_SETTINGS_H | ||
| # error "Detected keytools user settings, expected [WOLFBOOT_ROOT]/include/user_settings.hh" | ||
| # endif | ||
| #else | ||
| # ifdef WOLFBOOT_KEYTOOLS_USER_SETTINGS_H | ||
| # error "Detected keytools user settings, otp-keystore-gen does not expect any user_settings.h" | ||
| # endif | ||
| # ifdef WOLFBOOT_USER_SETTINGS_H | ||
| # error "Detected wolfboot user settings, otp-keystore-gen does not expect any user_settings.h" | ||
| # endif | ||
| #endif | ||
| #endif /* optional user settings check */ | ||
|
|
||
| #include "keystore.h" | ||
| #include "otp_keystore.h" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,9 +22,11 @@ | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA | ||
| */ | ||
|
|
||
| /* Beware of wolfCrypt user settings in [WOLFBOOT_ROOT]/include/user_settings.h */ | ||
|
|
||
| /* Option to enable sign tool debugging */ | ||
| /* Must also define DEBUG_WOLFSSL in user_settings.h */ | ||
| //#define DEBUG_SIGNTOOL | ||
| /* Must also define DEBUG_WOLFSSL in /tools/keytools/user_settings.h */ | ||
| /* #define DEBUG_SIGNTOOL */ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a proper options via tools/config.mk, parsed via tools/keytools/Makefile. You can have a separate "config" in your IDE magic perhaps for first run, while Makefile users can add DEBUG_SIGNTOOL=1 in .config user_settings.h is not meant for being modified. |
||
|
|
||
| #ifdef _WIN32 | ||
| #define _CRT_SECURE_NO_WARNINGS | ||
|
|
@@ -79,6 +81,20 @@ static inline int fp_truncate(FILE *f, size_t len) | |
| #endif | ||
|
|
||
| #include <wolfssl/wolfcrypt/settings.h> | ||
| /* During development in new environment, ensure the expected user settings is used: */ | ||
| #ifdef DEBUG_SIGNTOOL | ||
| #ifdef WOLFBOOT_USER_SETTINGS_H | ||
| # error "signing tool encountered unexpected user settings from [WOLFBOOT_ROOT]/include/user_settings.h" | ||
| #endif | ||
| #ifdef __WOLFBOOT | ||
| /* wolfBoot otherwise uses a different user_settings */ | ||
| # error "signing tool unexpectedly encountered __WOLFBOOT. Check your config" | ||
| #endif | ||
| #ifndef WOLFBOOT_KEYTOOLS_USER_SETTINGS_H | ||
| # error "signing tool expects settings from [WOLFBOOT_ROOT]/tools/keygen/user_settings.h" | ||
| #endif | ||
| #endif /* DEBUG_SIGNTOOL optional user settings check */ | ||
|
|
||
| #include <wolfssl/wolfcrypt/asn.h> | ||
| #include <wolfssl/wolfcrypt/aes.h> | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,8 +23,31 @@ | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA | ||
| */ | ||
|
|
||
| #ifndef H_USER_SETTINGS_ | ||
| #define H_USER_SETTINGS_ | ||
| #ifndef WOLFBOOT_KEYTOOLS_USER_SETTINGS_H | ||
| #define WOLFBOOT_KEYTOOLS_USER_SETTINGS_H | ||
|
|
||
| /* This is the keytools user settings. | ||
| * | ||
| * See also settings in [WOLFBOOT_ROOT]/include/user_settings.h | ||
| * | ||
| * When in question, define DEBUG_SIGNTOOL and optionally WOLFBOOT_SHOW_INCLUDE | ||
| */ | ||
|
|
||
| /* During development in new environment, ensure the expected user settings is used: */ | ||
| #ifdef WOLFBOOT_SHOW_INCLUDE | ||
| #ifdef __GNUC__ /* GCC compiler */ | ||
| #pragma message "============= keytools/user_settings.h" | ||
| #elif defined(_MSC_VER) /* Microsoft Visual C++ compiler */ | ||
| #pragma message("============= keytools/user_settings.h") | ||
| #else | ||
| #warning "============= keytools/user_settings" | ||
| #endif | ||
| #endif /* optional user settings check */ | ||
|
|
||
| /* Some debug options. See docs. */ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should be proper options via tools/config.mk, parsed in the tools makefile |
||
| /* #define DEBUG_SIGNTOOL */ | ||
| /* #define WOLFBOOT_HASH_SHA256 */ | ||
| /* #define WOLFBOOT_SIGN_ECC256 */ | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually redundant. The check is performed in wolfboot.h . See error at wolfboot.h:225