Пример #1
0
        public void AsymmetricCrypto_ValidateKey()
        {
            string privateKey;
            string publicKey;

            privateKey = AsymmetricCrypto.CreatePrivateKey(CryptoAlgorithm.RSA, 1024);
            publicKey  = AsymmetricCrypto.GetPublicKey(CryptoAlgorithm.RSA, privateKey);

            Assert.IsTrue(AsymmetricCrypto.IsValidKey(CryptoAlgorithm.RSA, privateKey));
            Assert.IsTrue(AsymmetricCrypto.IsValidKey(CryptoAlgorithm.RSA, publicKey));
            Assert.IsTrue(AsymmetricCrypto.IsXmlKey(CryptoAlgorithm.RSA, privateKey));
            Assert.IsTrue(AsymmetricCrypto.IsXmlKey(CryptoAlgorithm.RSA, publicKey));

            Assert.IsFalse(AsymmetricCrypto.IsXmlKey(CryptoAlgorithm.RSA, KeyContainer));
            Assert.IsFalse(AsymmetricCrypto.IsValidKey(CryptoAlgorithm.RSA, string.Empty));
            Assert.IsFalse(AsymmetricCrypto.IsValidKey(CryptoAlgorithm.RSA, "xxxx > << "));
        }