コード例 #1
0
        public static void TestExtensions_AccountKeyToUserAsymmetricKeysWithWrongPassphrase(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            UserKeyPair originalKeys  = new UserKeyPair(EmailAddress.Parse("*****@*****.**"), 512);
            AccountKey  accountKey    = originalKeys.ToAccountKey(new Passphrase("password"));
            UserKeyPair roundtripKeys = accountKey.ToUserKeyPair(new Passphrase("wrong password"));

            Assert.That(roundtripKeys, Is.Null);
        }
コード例 #2
0
        public static void TestExtensions_UserAsymmetricKeysToAccountKeyAndBackUsingDataProtection(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            UserKeyPair originalKeys  = new UserKeyPair(EmailAddress.Parse("*****@*****.**"), 512);
            AccountKey  accountKey    = originalKeys.ToAccountKey(Passphrase.Empty);
            UserKeyPair roundtripKeys = accountKey.ToUserKeyPair(Passphrase.Empty);

            Assert.That(accountKey.KeyPair.PrivateEncryptedPem.Length, Is.GreaterThan(0));
            Assert.That(originalKeys, Is.EqualTo(roundtripKeys));
        }
コード例 #3
0
        public static void TestExtensions_AccountKeyToUserAsymmericKeysWithOnlyPublicKey(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            UserKeyPair        originalKeys        = new UserKeyPair(EmailAddress.Parse("*****@*****.**"), 512);
            IAsymmetricKeyPair partialKeyPair      = Resolve.AsymmetricFactory.CreateKeyPair(originalKeys.KeyPair.PublicKey.ToString(), String.Empty);
            UserKeyPair        originalPartialKeys = new UserKeyPair(originalKeys.UserEmail, originalKeys.Timestamp, partialKeyPair);

            AccountKey  accountKey    = originalPartialKeys.ToAccountKey(Passphrase.Empty);
            UserKeyPair roundtripKeys = accountKey.ToUserKeyPair(Passphrase.Empty);

            Assert.That(roundtripKeys, Is.EqualTo(originalPartialKeys));
        }