Question
I'm looking for a better way to make raw binary of signature & public key when I'm making a secure bootloader.
Hello,
When I'm learning "STM32 security in practice MOOC". I ran into the below scripts to make raw binary of signature and public key.
I thought it was not easy to use and explain to others.
Is there a better way to make a raw binary of signature and public key?
Thank you in advance.
PostBuild_sig.bat
ECHO ########## Convert signature from asn1 to raw binary ############
IF EXIST temp.txt DEL temp.txt
FOR /F "tokens=4 delims=:" %%A IN ('%OPENSSL% asn1parse -in %tmp_sigfile% -inform=DER') DO >>temp.txt ECHO(%%A
CERTUTIL -f -decodehex temp.txt %tmp_sigfile% >nul
IF EXIST temp.txt DEL temp.txt
ECHO FW Signature
%HEXDUMP% %tmp_sigfile%
ECHO "################# Generate public key from private ecc key "
%OPENSSL% pkey -in ecc.key -pubout -out ecc_pub.key
ECHO "################# Convert public key to binary "
%OPENSSL% ec -pubin -in ecc_pub.key -text -noout |%GREP% ":"|%GREP% " "|%SED% 's/ /-/g'|%SED% 's/:/,:/g'|%AWK% -F ":" "{ print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15}"|%SED% 's/-04,//'|%SED% 's/ //g' >> temp.txt
CERTUTIL -f -decodehex temp.txt %tmp_keypub% >nul
IF EXIST temp.txt DEL temp.txt
ECHO Public Key
%HEXDUMP% %tmp_keypub%