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

            return BigInteger.ModPow(c, key.PrivateExponent, key.Modulus);
        }