Skip to content

Commit

Permalink
Minor changes from comments
Browse files Browse the repository at this point in the history
Makes minor changes as suggested by review comments to the
following files:
- build.rs
- c.rs
- config-add-psa-crypto.h
- config-rsa-kw.h
  • Loading branch information
Matthew Dalzell committed Jun 13, 2023
1 parent bd21dda commit 2f5b17a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 3 additions & 1 deletion sim/mcuboot-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ fn main() {
}

if psa_crypto_api {
if sig_ecdsa || enc_ec256 || enc_x25519 || enc_aes256_ec256 || sig_ecdsa_mbedtls || enc_aes256_x25519 || enc_kw || enc_aes256_kw {
if sig_ecdsa || enc_ec256 || enc_x25519 ||
enc_aes256_ec256 || sig_ecdsa_mbedtls || enc_aes256_x25519 ||
enc_kw || enc_aes256_kw {
conf.file("csupport/psa_crypto_init_stub.c");
} else {
conf.conf.define("MCUBOOT_USE_PSA_CRYPTO", None);
Expand Down
9 changes: 3 additions & 6 deletions sim/mcuboot-sys/csupport/config-add-psa-crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,21 @@

#if defined(MCUBOOT_ENCRYPT_RSA) || defined(MCUBOOT_SIGN_RSA)
#define MBEDTLS_PK_C
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_CTR_DRBG_C
#define MBEDTLS_CIPHER_C
#define MBEDTLS_ENTROPY_C
#define MBEDTLS_PK_PARSE_C
#define MBEDTLS_PK_WRITE_C
#endif /* defined(MCUBOOT_ENCRYPT_RSA) */
#endif /* MCUBOOT_ENCRYPT_RSA || MCUBOOT_SIGN_RSA */

#if defined(MCUBOOT_ENCRYPT_EC256) || defined(MCUBOOT_ENCRYPT_X25519)
#define MBEDTLS_CIPHER_MODE_CTR
#define MBEDTLS_PLATFORM_FREE_MACRO free
#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc
#define MBEDTLS_AES_C
#endif /* defined(MCUBOOT_ENCRYPT_RSA) */
#endif /* MCUBOOT_ENCRYPT_EC256 || MCUBOOT_ENCRYPT_X25519 */

#if !defined(MCUBOOT_ENCRYPT_X25519)
#define MBEDTLS_PSA_BUILTIN_CIPHER 1
#endif
#endif /* MCUBOOT_ENCRYPT_X25519 */

#if defined(MCUBOOT_ENCRYPT_KW)
#define MBEDTLS_PSA_CRYPTO_CONFIG
Expand Down
1 change: 0 additions & 1 deletion sim/mcuboot-sys/csupport/config-rsa-kw.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "config-add-psa-crypto.h"
#endif /* defined(MCUBOOT_USE_PSA_CRYPTO) */


#ifdef CONFIG_MCUBOOT_SERIAL
/* Mcuboot uses mbedts-base64 for serial protocol encoding. */
#define MBEDTLS_BASE64_C
Expand Down
6 changes: 3 additions & 3 deletions sim/mcuboot-sys/src/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl BootGoResult {
pub fn boot_go(multiflash: &mut SimMultiFlash, areadesc: &AreaDesc,
counter: Option<&mut i32>, image_index: Option<i32>,
catch_asserts: bool) -> BootGoResult {
init_psa();
init_crypto();

for (&dev_id, flash) in multiflash.iter_mut() {
api::set_flash(dev_id, flash);
Expand Down Expand Up @@ -194,7 +194,7 @@ static PSA_INIT_SYNC: Once = Once::new();
static MBEDTLS_EXTERNAL_RNG_ENABLE_SYNC: Once = Once::new();

#[cfg(feature = "psa-crypto-api")]
fn init_psa() {
fn init_crypto() {
PSA_INIT_SYNC.call_once(|| {
assert_eq!(unsafe { raw::psa_crypto_init() }, 0);
});
Expand All @@ -210,6 +210,6 @@ fn init_psa() {
}

#[cfg(not(feature = "psa-crypto-api"))]
fn init_psa() {
fn init_crypto() {
// When the feature is not enabled, the init is just empty
}

0 comments on commit 2f5b17a

Please sign in to comment.