Uh oh!
There was an error while loading. Please reload this page.
Abstract out the hash algorithm from RsaDigitalSignature - #1170
Conversation
| // The following fails due to the _isPrivate decision in RsaCipher.Transform. Is that really correct? | ||
| //Assert.IsTrue(digitalSignature.Verify(data, signedBytes)); |
There was a problem hiding this comment.
This is surely a bug, but I would rather wait until the test migrations are done before looking at it.
The Encrypt and Decrypt methods on RsaCipher both call the private Transform method which changes its behaviour based (only) upon whether the RsaKey member has private key information:
So Encrypt and Decrypt both perform encryption (m ^ e mod N) when given a key with only public information, and both perform decryption when given a key with private key information. They only differ by some processing of padding.
It works because the base class CipherDigitalSignature calls Encrypt when signing, when really the signing operation is 'decryption' and the verification operation is to encrypt (but Verify calls Decrypt).
WojciechNagorski
left a comment
There was a problem hiding this comment.
Overall it looks good, but I don't know why digitalSignature.Verify(data, signedBytes) doesn't work. Any idea?
| // The following fails due to the _isPrivate decision in RsaCipher.Transform. Is that really correct? | ||
| //Assert.IsTrue(digitalSignature.Verify(data, signedBytes)); |
There was a problem hiding this comment.
Any idea why this isn't working?
| }, signedBytes); | ||
| // The following fails due to the _isPrivate decision in RsaCipher.Transform. Is that really correct? | ||
| //Assert.IsTrue(digitalSignature.Verify(data, signedBytes)); |
There was a problem hiding this comment.
Any idea why this isn't working?
| CollectionAssert.AreEqual(expectedSignedBytes, rsaKey.Sign(data)); | ||
| // The following fails due to the _isPrivate decision in RsaCipher.Transform. Is that really correct? | ||
| //Assert.IsTrue(digitalSignature.Verify(data, signedBytes)); |
There was a problem hiding this comment.
Any idea why this isn't working?
Rob-Hague
commented
Sep 13, 2023
Yes, see my comment above. The encrypt/decrypt methods change based on whether the key has private key information. I think it should be changed, but it seems like long-standing behaviour, and I would rather not change it here. |
WojciechNagorski
commented
Sep 13, 2023
I'm afraid to merge without further changes. I agree to these changes, but I don't know if they will fit nicely into further changes. Maybe you want to complete the entire ssh-sha256 and ssh-sha-512 implementation on this PR? |
Rob-Hague
commented
Sep 13, 2023
Sure, the rest of the changes are based on this so the PR will include this either way. |
WojciechNagorski
commented
Sep 13, 2023
I know. Great! |
Rob-Hague
commented
Sep 16, 2023
Included in #1177 |
WojciechNagorski
commented
Oct 10, 2023
Version 2023.0.0 has been published https://www.nuget.org/packages/SSH.NET/2023.0.0 |
1 similar comment
WojciechNagorski
commented
Oct 10, 2023
Version 2023.0.0 has been published https://www.nuget.org/packages/SSH.NET/2023.0.0 |
This is a step towards implementing the rsa-sha2 key host algorithms