@@ -53,6 +53,12 @@ define_property(TARGET
53
53
BRIEF_DOCS "Embed decryption stage into encrypted binary"
54
54
FULL_DOCS "Embed decryption stage into encrypted binary"
55
55
)
56
+ define_property (TARGET
57
+ PROPERTY PICOTOOL_USE_MBEDTLS_DECRYPTION
58
+ INHERITED
59
+ BRIEF_DOCS "Use MbedTLS based decryption stage - this is faster, but not secure against power snooping"
60
+ FULL_DOCS "Use MbedTLS based decryption stage - this is faster, but not secure against power snooping"
61
+ )
56
62
define_property (TARGET
57
63
PROPERTY PICOTOOL_OTP_KEY_PAGE
58
64
INHERITED
@@ -438,7 +444,7 @@ function(pico_embed_pt_in_binary TARGET PTFILE)
438
444
)
439
445
endfunction ()
440
446
441
- # pico_encrypt_binary(TARGET AESFILE IVFILE [SIGFILE <file>] [EMBED] [OTP_KEY_PAGE <page>])
447
+ # pico_encrypt_binary(TARGET AESFILE IVFILE [SIGFILE <file>] [EMBED] [MBEDTLS] [ OTP_KEY_PAGE <page>])
442
448
# \brief_nodesc\ Encrypt the taget binary
443
449
#
444
450
# Encrypt the target binary with the given AES key (should be a binary
@@ -453,15 +459,21 @@ endfunction()
453
459
# Optionally, use EMBED to embed a decryption stage into the encrypted binary.
454
460
# This sets the target property PICOTOOL_EMBED_DECRYPTION to TRUE.
455
461
#
462
+ # Optionally, use MBEDTLS to to use the MbedTLS based decryption stage - this
463
+ # is faster, but less secure.
464
+ # This sets the target property PICOTOOL_USE_MBEDTLS_DECRYPTION to TRUE.
465
+ #
456
466
# Optionally, use OTP_KEY_PAGE to specify the OTP page storing the AES key.
457
467
# This sets the target property PICOTOOL_OTP_KEY_PAGE to OTP_KEY_PAGE.
458
468
#
459
469
# \param\ AESFILE The AES key file to use
470
+ # \param\ IVFILE The IV file to use
460
471
# \param\ SIGFILE The PEM signature file to use
461
472
# \param\ EMBED Embed a decryption stage into the encrypted binary
473
+ # \param\ MBEDTLS Use MbedTLS based decryption stage (faster, but less secure)
462
474
# \param\ OTP_KEY_PAGE The OTP page storing the AES key
463
475
function (pico_encrypt_binary TARGET AESFILE IVFILE)
464
- set (options EMBED)
476
+ set (options EMBED MBEDTLS )
465
477
set (oneValueArgs OTP_KEY_PAGE SIGFILE)
466
478
# set(multiValueArgs )
467
479
cmake_parse_arguments (PARSE_ARGV 3 ENC "${options} " "${oneValueArgs} " "${multiValueArgs} " )
@@ -479,6 +491,12 @@ function(pico_encrypt_binary TARGET AESFILE IVFILE)
479
491
)
480
492
endif ()
481
493
494
+ if (ENC_MBEDTLS)
495
+ set_target_properties (${TARGET} PROPERTIES
496
+ PICOTOOL_USE_MBEDTLS_DECRYPTION TRUE
497
+ )
498
+ endif ()
499
+
482
500
if (ENC_OTP_KEY_PAGE)
483
501
set_target_properties (${TARGET} PROPERTIES
484
502
PICOTOOL_OTP_KEY_PAGE ${ENC_OTP_KEY_PAGE}
@@ -653,6 +671,11 @@ function(picotool_postprocess_binary TARGET)
653
671
list (APPEND picotool_encrypt_args "--embed" )
654
672
endif ()
655
673
674
+ get_target_property (picotool_mbedtls_decryption ${TARGET} PICOTOOL_USE_MBEDTLS_DECRYPTION)
675
+ if (picotool_mbedtls_decryption)
676
+ list (APPEND picotool_encrypt_args "--use-mbedtls" )
677
+ endif ()
678
+
656
679
get_target_property (otp_key_page ${TARGET} PICOTOOL_OTP_KEY_PAGE)
657
680
if (otp_key_page)
658
681
list (APPEND picotool_encrypt_args "--otp-key-page" ${otp_key_page} )
0 commit comments