this question arised because I'm working with Windows' CNG library and it has 4 functions for RSA:
- BCryptEncrypt (private key, message)
- BCryptDecrypt (public key, message)
- BCryptSignHash (private key, hashed message)
- BCryptVerifySignature (public key, signature, hashed message)
So I was wondering, is there any difference between "Encrypting + Decrypting" and "Signing + Verifying"? I mean, if I hash the message and then encrypt it, wouldn't that be the same as Signing it? or Am I missing some logic that is behind that function? (talking about RSA in general, not about how windows' CNG work).
The only visible difference I see is:
- For Encryption and Decryption I can use OAEP and PKCS1 padding.
- For Signing and Verifying I can use PKCS1 and PSS padding.
But again, is this because of how those functions are made in this library? or because the "operation" and the output are done in different ways depending on if it is Signing or Encryption?
If they are different, then why do we need the Signing part? Isn't encrypting with private and decrypting with public secure enough to "sign" it?