开发者

SSL certificate signature verification

开发者 https://www.devze.com 2023-04-12 02:45 出处:网络
I\'m trying to verify certificate on an embedded board manually because it doesn\'t support Openssl or other libraries.However it does have libraries for MD5 and SHA1 hashes and RSA encryption.

I'm trying to verify certificate on an embedded board manually because it doesn't support Openssl or other libraries. However it does have libraries for MD5 and SHA1 hashes and RSA encryption.

From what I understand to verify the certificate, first compute the SHA1 hash (or MD5) of the certificate; then decode the signature using CA's public key to obtain a hashed value.开发者_运维问答 These two hash values should be the same.

SHA1 hash produces a 20 byte value and MD5 produces 16 byte value. However, RSA decoding of the signature does not. If the CA's key is 1024 bits, the decode signature will be 80bytes; if the CA's key is 512 bits, the decoded signature will be 40 bytes. So I can't really compare the 20 bytes SHA1 value against the 40 or 80 bytes Decoded Signature.

Am I doing something wrong? Or am I missing a step?


The missing bit is the padding algorithm.

You use RSA with a specific padding algorithm, and the same algorithm also tells you how to take the result (when you decrypt the signature) and extract from it the actual data (the hash).

0

精彩评论

暂无评论...
验证码 换一张
取 消