public void Init(ICipherParameters parameters) { var pubKeyParams = parameters as PublicKeyParameter; if (pubKeyParams != null) { SecurityAssert.SAssert(pubKeyParams.Key is RSAPublicKey); pub = (RSAPublicKey)pubKeyParams.Key; return; } var privKeyParams = parameters as PrivateKeyParameter; if (privKeyParams != null) { SecurityAssert.SAssert(privKeyParams.Key is RSAPrivateKey); priv = (RSAPrivateKey)privKeyParams.Key; pub = (RSAPublicKey)priv.PublicKey; return; } throw new InvalidCastException(); }
private static BigInteger VerifyPrimative(BigInteger m, RSAPublicKey key) { return EncryptPrimative(m, key); }
private static BigInteger EncryptPrimative(BigInteger m, RSAPublicKey key) { SecurityAssert.SAssert(m >= 0 && m < key.Modulus); return BigInteger.ModPow(m, key.Exponent, key.Modulus); }