I do this in bash:
head -c 128 <signed_fw_image> > <image_sign>
openssl rsautl -verify -inkey <public_rsa_key> -in <image_sign> -pubin > <out_sign_result>
md5sum <raw_image_bin> | xxd -r -p > <out_orig_result>
diff <out_sign_result> <out_orig_result>
How I can implement this in python and which libraries should I use?
I had a similar problem recently and I came by here on my way to eventually read the
rsautl
source code. It does just a single raw RSA round. The following Python 3 script can be used to reproduce the behavior ofrsautl -verify
and relies on thepycryptodome
package, which I recommend for this task:I assume that this was the tricky part, you can compute the MD5 checksum of your file by using the builtin
hashlib
module.