@@ -70,15 +70,20 @@ if BOOT_USE_PSA_CRYPTO
7070
7171config BOOT_PSA_IMG_HASH_ALG_SHA256_DEPENDENCIES
7272 bool
73- default y if BOOT_IMG_HASH_ALG_SHA256
73+ default y if BOOT_SOMETHING_USES_SHA256
7474 select PSA_WANT_ALG_SHA_256
7575 help
7676 Dependencies for hashing with SHA256
7777
78- config BOOT_ED25519_PSA_DEPENDENCIES
78+ config BOOT_PSA_IMG_HASH_ALG_SHA512_DEPENDENCIES
7979 bool
80- select PSA_WANT_ALG_SHA_256
80+ default y if BOOT_SOMETHING_USES_SHA512
8181 select PSA_WANT_ALG_SHA_512
82+ help
83+ Dependencies for hashing with SHA512
84+
85+ config BOOT_ED25519_PSA_DEPENDENCIES
86+ bool
8287 select PSA_WANT_ALG_PURE_EDDSA
8388 # Seems that upstream mbedTLS does not have TE
8489 #select PSA_WANT_ECC_TWISTED_EDWARDS_255
@@ -129,6 +134,30 @@ config SINGLE_APPLICATION_SLOT
129134 uploading a new application overwrites the one that previously
130135 occupied the area.
131136
137+ config BOOT_SOMETHING_USES_SHA256
138+ bool
139+ help
140+ Hidden option that should be selected when something requires
141+ SHA256 implementation in any form. It should be used by crypto
142+ backends to enable support for SHA256 in code and/or hardware
143+ drivers.
144+
145+ config BOOT_SOMETHING_USES_SHA384
146+ bool
147+ help
148+ Hidden option that should be selected when something requires
149+ SHA384 implementation in any form. It should be used by crypto
150+ backends to enable support for SHA384 in code and/or hardware
151+ drivers.
152+
153+ config BOOT_SOMETHING_USES_SHA512
154+ bool
155+ help
156+ Hidden option that should be selected when something requires
157+ SHA512 implementation in any form. It should be used by crypto
158+ backends to enable support for SHA512 in code and/or hardware
159+ drivers.
160+
132161config BOOT_IMG_HASH_ALG_SHA256_ALLOW
133162 bool
134163 help
@@ -173,18 +202,21 @@ choice BOOT_IMG_HASH_ALG
173202config BOOT_IMG_HASH_ALG_SHA256
174203 bool "SHA256"
175204 depends on BOOT_IMG_HASH_ALG_SHA256_ALLOW
205+ select BOOT_SOMETHING_USES_SHA256
176206 help
177207 SHA256 algorithm
178208
179209config BOOT_IMG_HASH_ALG_SHA384
180210 bool "SHA384"
181211 depends on BOOT_IMG_HASH_ALG_SHA384_ALLOW
212+ select BOOT_SOMETHING_USES_SHA384
182213 help
183214 SHA384 algorithm
184215
185216config BOOT_IMG_HASH_ALG_SHA512
186217 bool "SHA512"
187218 depends on BOOT_IMG_HASH_ALG_SHA512_ALLOW
219+ select BOOT_SOMETHING_USES_SHA512
188220 help
189221 SHA512 algorithm
190222
@@ -628,14 +660,34 @@ config BOOT_ENCRYPT_X25519
628660 help
629661 Hidden option selecting x25519 encryption.
630662
663+ if BOOT_ENCRYPT_X25519 && BOOT_USE_PSA_CRYPTO
664+
665+ choice BOOT_HMAC_SHA
666+ prompt "SHA used for HMAC and HKDF in encryption key exchange"
667+ default BOOT_HMAC_SHA256
668+ help
669+ HMAC/HKDF sha algorithm may be selected to synchronize sha
670+ usage with other places in code and reduce compiled in
671+ implementations.
672+
673+ config BOOT_HMAC_SHA256
674+ bool "Use SHA256 for HMAC/HKDF"
675+ select BOOT_SOMETHING_USES_SHA256
676+ help
677+ This is default for ED25519.
678+
631679config BOOT_HMAC_SHA512
632680 bool "Use SHA512 for HMAC/HKDF"
633681 depends on BOOT_ENCRYPT_X25519
634682 depends on BOOT_USE_PSA_CRYPTO
683+ select BOOT_SOMETHING_USES_SHA512
635684 help
636- By default SHA256 is used for HKDF/HMAC in key exchange expansion
637- and verification. This options switches to SHA512. The option is
638- mainly useful to reduce numer of compiled in SHA algorithms.
685+ With ED25519, this option is worth selecting when SHA512 is used
686+ for hashing of an image to reduce number of compiled sha algorithms.
687+
688+ endchoice # BOOT_HMAC_SHA
689+
690+ endif # BOOT_ENCRYPT_X25519 && BOOT_USE_PSA_CRYPTO
639691
640692config BOOT_ENCRYPTION_KEY_FILE
641693 string "Encryption key file"
0 commit comments