Well guys I am trying to encrypt (actually sign) data using Public and Private exponent and modulus, It is in C#.NET and I can't use RSACryptoServiceProvider
because it needs also both prime numbers and other CRT stuff.
So I am trying to do following:
private Byte[] signData()
{
BigInteger biPrivEx = new BigInteger(this.privEx); // Those are byte[]
BigInteger biPubEx = new BigInteger(this.pubEx);
BigInteger biMod = new BigInteger(this.mod);
BigInteger cyph = BigInteger.ModPow(new BigInteger(pkcs11), biPrivEx, biMod); // This raise exception
return cyph.ToByteArray();;
}
But the problem is I am getting Out Of Range Exception
because my private exponent is negative number.
What am I doing wrong? Or is possible to easily recovery CRT from this? Or maybe is there any better way how to do it? In different program I am able to this with data I am using, so I have got reference to verify it.