public virtual byte[] GenerateSignature()
{
contentDigest1.DoFinal(mDash, mDash.Length - hLen - sLen);
if (sLen != 0)
{
random.NextBytes(salt);
salt.CopyTo(mDash, mDash.Length - sLen);
}
byte[] h = new byte[hLen];
contentDigest2.BlockUpdate(mDash, 0, mDash.Length);
contentDigest2.DoFinal(h, 0);
block[block.Length - sLen - 1 - hLen - 1] = (byte) (0x01);
salt.CopyTo(block, block.Length - sLen - hLen - 1);
byte[] dbMask = MaskGeneratorFunction1(h, 0, h.Length, block.Length - hLen - 1);
for (int i = 0; i != dbMask.Length; i++)
{
block[i] ^= dbMask[i];
}
block[0] &= (byte) ((0xff >> ((block.Length * 8) - emBits)));
h.CopyTo(block, block.Length - hLen - 1);
block[block.Length - 1] = trailer;
byte[] b = cipher.ProcessBlock(block, 0, block.Length);
ClearBlock(block);
//jbonilla
currentSignature = b;
return currentSignature;
}
private void doTestSig( int id, RsaKeyParameters pub, RsaKeyParameters prv, byte[] slt, byte[] msg, byte[] sig) { PssSigner eng = new PssSigner(new RsaEngine(), new Sha1Digest(), 20); eng.Init(true, new ParametersWithRandom(prv, new FixedRandom(slt))); eng.BlockUpdate(msg, 0, msg.Length); byte[] s = eng.GenerateSignature(); if (!AreEqual(s, sig)) { Fail("test " + id + " failed generation"); } eng.Init(false, pub); eng.BlockUpdate(msg, 0, msg.Length); if (!eng.VerifySignature(s)) { Fail("test " + id + " failed verification"); } }