Closed harrison314 closed 8 months ago
Fix LimitedBuffer.Write(ReadOnlySpan<byte>) method.
LimitedBuffer.Write(ReadOnlySpan<byte>)
The error manifested as System.InvalidOperationException: Incorrect prehash size when using RSA PSS.
System.InvalidOperationException: Incorrect prehash size
Code for replication fixed bug:
SecureRandom secureRandom = new SecureRandom(); Org.BouncyCastle.Crypto.Generators.RsaKeyPairGenerator generator = new Org.BouncyCastle.Crypto.Generators.RsaKeyPairGenerator(); generator.Init(new RsaKeyGenerationParameters(new Org.BouncyCastle.Math.BigInteger(1, new byte[] { 1, 0, 1 }), secureRandom, 2048, 100)); var keyPair = generator.GenerateKeyPair(); IDigest contentDigest = new Sha256Digest(); IDigest mgfDigest = new Sha256Digest(); ISigner signer = PssSigner.CreateRawSigner(new RsaBlindedEngine(), contentDigest, mgfDigest, 32, PssSigner.TrailerImplicit); byte[] hashToSign = new byte[32]; secureRandom.NextBytes(hashToSign); signer.Init(true, keyPair.Private); signer.BlockUpdate(hashToSign); byte[] signature = signer.GenerateSignature();
Merged, thanks. Also added a regression test.
Fix
LimitedBuffer.Write(ReadOnlySpan<byte>)
method.The error manifested as
System.InvalidOperationException: Incorrect prehash size
when using RSA PSS.Code for replication fixed bug: