I am trying to understand the RSA algorithm for digital signatures . Follow this scheme:

Signature :

  1. Take plaintext m
  2. Digitally sign s with your private key [d, n] : enter image description here
  3. Send a pair [m, s] , consisting of a message and a signature.

Verification / verification :

  1. Take a pair [m, s]
  2. Take the public key [e, n]
  3. Calculate the preimage of the message from the signature:

    enter image description here

  4. Verify the authenticity of the signature (and the immutability of the message) by comparing m and m '

Source: Digital Signature with RSA


But I also wanted to use hashing . I'm going to sign not the message, but its “hash image”: enter image description here . The signature algorithm may change this way:

Signature :

  1. Take plaintext m
  2. Generate message hash: enter image description here
  3. Digitally sign s with your private key [d, n] : enter image description here
  4. Send a pair [m, s] , consisting of a message and a signature.

Verification / verification :

  1. Take a pair [m, s]
  2. Take the public key [e, n]
  3. Calculate the preimage of the message from the signature: enter image description here
  4. Verify the authenticity of the signature (and the immutability of the message) by comparing m and m ' ???

Before using hashing, we could verify the authenticity of the signature (and the immutability of the message) by comparing m and m ' . But now after the 3rd step we get m ' in a hashed form (not the original text). After all, it is impossible to compare the original message m and the hashed version of m ' (considering that the hashing is irreversible and it is impossible to recover the message from the hash). What to do in this situation?


My question is: What is the correct RSA algorithm with a digital signature with hashing?

  • 3
    During verification, you receive both the message itself and its signature. Hash the message just as it did at the time of the signature and verify the received hash with the incoming, signed - Mike
  • Use two values ​​for verification: the first is just a hash, the second is a signed hash (that is, you sign a copy of the first hash created), then where it is needed, you decrypt the signed hash using the public key (public key) and compare two hashes if they are equal means everything OK. - Timur Gazaleev

0