Hi @se_cguerr,
CC @anda_despotovici, @ZeeFrench,
Following our call yesterday, we were able to successfully simulate your use case, and we have a properly signed image.
To answer your questions above, here is example command to generate CMS signature with OpenSSL:
openssl cms -sign -md sha256 -outform DER -nosmimecap -nocerts -binary -in ${csf_sigreq_file} -out ${csf_sig_file} -signer ${csf_crt} -inkey ${csf_key} -passin file:../keys/key_pass.txt
I assume for this one you have the same command as shown during the call.
As per your request here is the command to verify the generated signature:
openssl cms -verify -in ${csf_sig_file} -inform DER -binary -content ${csf_sigreq_file} -certsout /dev/null -certfile ${csf_crt} -noverify -out verified_csf_output.txt
Duplicate these commands for IMG.
Duplicate signing process for SPL & FIT.
In my case, the size of output signature size is 509 bytes.
Therefore I modify my CSF headers and set
[Header]
<snip>
Signature Size = 509
Regarding the current limitation of your signing room—which only supports signing a provided hash and not raw content, there’s an important update worth noting. As of OpenSSL >= 3.2, an undocumented feature allows you to pass a precomputed hash using the -digest option.
I’ve tested this on my side, and it works as expected.
Updated Signing Process:
Compute the hash of the content externally.
csf_sigreq_digest=$(openssl dgst -sha256 ${csf_sigreq_file} | awk '{printf $2}')
Sign the precomputed hash using the -digest option.
$OPENSSL_PATH/openssl cms -sign -md sha256 -outform DER -nosmimecap -nocerts -binary -digest ${csf_sigreq_digest} -out ${csf_sig_file} -signer ${csf_crt} -inkey ${csf_key} -passin file:../keys/key_pass.txt
Verify:
$OPENSSL_PATH/openssl cms -verify -in ${csf_sig_file} -inform DER -binary -content ${csf_sigreq_file} -certsout /dev/null -certfile ${csf_crt} -noverify -out verified_csf_output.txt
I hope this helps. Let us know if this works for you.
Best
Maro