示例#1
0
文件: RSA.cs 项目: will14smith/Crypto
        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();
        }
示例#2
0
文件: RSA.cs 项目: will14smith/Crypto
 private static BigInteger VerifyPrimative(BigInteger m, RSAPublicKey key)
 {
     return EncryptPrimative(m, key);
 }
示例#3
0
文件: RSA.cs 项目: will14smith/Crypto
        private static BigInteger EncryptPrimative(BigInteger m, RSAPublicKey key)
        {
            SecurityAssert.SAssert(m >= 0 && m < key.Modulus);

            return BigInteger.ModPow(m, key.Exponent, key.Modulus);
        }