예제 #1
0
 public void Setup()
 {
     _rsa       = new SystemAsymmetricEncryptionProvider();
     _rsaPublic = new SystemAsymmetricEncryptionProvider();
     _rsaPublic.SetKeyPair(_rsa.GetPublicKey());
     Assert.IsFalse(_rsa.PublicOnly);
     Assert.IsTrue(_rsaPublic.PublicOnly);
 }
예제 #2
0
        public async Task GetPrivateExponentAsyncTest()
        {
            var     password = "******";
            Keypair kp       = _rsa.GetPrivateKey(password);
            await kp.GetPrivateExponentAsync(password);

            kp = _rsa.GetPublicKey();
            Assert.Throws <InvalidOperationException>(() =>
                                                      kp.GetPrivateExponentAsync(password).RunSynchronously());
        }
예제 #3
0
        public void GetPublicKeyTest()
        {
            Keypair key  = _rsa.GetPublicKey();
            Keypair key2 = _rsaPublic.GetPublicKey();

            Assert.AreEqual(key.Modulus, key2.Modulus);
            Assert.AreEqual(key.Exponent, key2.Exponent);
            Assert.IsNull(key.PrivateExponent);
            Assert.AreEqual(key.PrivateExponent, key2.PrivateExponent);
        }