Why does SignHash need to know what hash algorithm was used?

前端 未结 2 1388
北恋
北恋 2021-01-12 09:51

This may be a question for http://crypto.stackexchange.com, but I thought I\'d try it here first as the answer may relate to .NET rather than the encryption algorithm itself

2条回答
  •  清歌不尽
    2021-01-12 10:16

    Thanks to Iridium for getting me thinking along the right lines here.

    The recipient gets two things:

    • The message
    • The signature (encrypted by sender's private key)

    To verify the message, the recipient is required to decrypt the signature using the sender's public key, and check that against the hash of the message.

    If the hash algorithm isn't specified to the recipient, they have no way of knowing how to hash the message, so they can't verify it.

    So the algorithm must be specified to the recipient.

    In order for the hash algorithm to be specified by the sender (who knows how the signature was created), and not modifiable by anyone else, it needs to be included inside the signature, and encrypted alongside the hash.

    So in order to create a useful signature, the hashing algorithm needs to be specified when encrypting the hash.

提交回复
热议问题