예제 #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);
        }