public void TestComparisons() { Passphrase key1 = new Passphrase("samekey"); Passphrase key2 = new Passphrase("samekey"); Salt salt1 = new Salt(512); Salt salt2 = new Salt(512); SymmetricKeyThumbprint thumbprint1a = new SymmetricKeyThumbprint(key1, salt1, 13); SymmetricKeyThumbprint thumbprint1a_alias = thumbprint1a; SymmetricKeyThumbprint thumbprint1b = new SymmetricKeyThumbprint(key1, salt2, 25); SymmetricKeyThumbprint thumbprint2a = new SymmetricKeyThumbprint(key2, salt2, 25); SymmetricKeyThumbprint thumbprint2b = new SymmetricKeyThumbprint(key2, salt1, 13); SymmetricKeyThumbprint nullThumbprint = null; Assert.That(thumbprint1a == thumbprint1a_alias, "Same instance should of course compare equal."); Assert.That(nullThumbprint != thumbprint1a, "A null should not compare equal to any other instance."); Assert.That(thumbprint1a != nullThumbprint, "A null should not compare equal to any other instance."); Assert.That(thumbprint1a == thumbprint2b, "Same raw key and salt, but different instance, should compare equal."); Assert.That(thumbprint1b == thumbprint2a, "Same raw key and salt, but different instance, should compare equal."); Assert.That(thumbprint1a != thumbprint1b, "Same raw key but different salt, should compare inequal."); Assert.That(thumbprint2a != thumbprint2b, "Same raw key but different salt, should compare inequal."); object object1a = thumbprint1a; object object2b = thumbprint2b; Assert.That(object1a.Equals(nullThumbprint), Is.False, "An instance does not equals null."); Assert.That(object1a.Equals(object2b), Is.True, "The two instances are equivalent."); object badTypeObject = key1; Assert.That(object1a.Equals(badTypeObject), Is.False, "The object being compared to is of the wrong type."); }
public IdentityPublicTag(LogOnIdentity identity) { if (identity == null) { throw new ArgumentNullException("identity"); } _thumbprint = identity.Passphrase.Thumbprint; _email = identity.ActiveEncryptionKeyPair.UserEmail; }
private void Initialize(IDataStore encryptedFileInfo, IDataStore decryptedFileInfo, LogOnIdentity identity, SymmetricKeyThumbprint thumbprint, ActiveFileStatus status, ActiveFileProperties properties) { EncryptedFileInfo = New <IDataStore>(encryptedFileInfo.FullName); DecryptedFileInfo = New <IDataStore>(decryptedFileInfo.FullName); Identity = identity; Thumbprint = thumbprint; Status = status; Properties = new ActiveFileProperties(New <INow>().Utc, properties.LastEncryptionWriteTimeUtc, properties.CryptoId); IsShared = EncryptedFileInfo.IsKeyShared(Identity); }
public static void TestThumbprint(CryptoImplementation cryptoImplementation) { SetupAssembly.AssemblySetupCrypto(cryptoImplementation); Passphrase key1 = new Passphrase("genericPassphrase"); SymmetricKeyThumbprint originalThumbprint = key1.Thumbprint; Assert.That(originalThumbprint, Is.EqualTo(key1.Thumbprint), "The thumbprints should be the same."); }
private bool IsKnownIdentity() { SymmetricKeyThumbprint thumbprint = Passphrase.Thumbprint; Passphrase passphrase = Resolve.FileSystemState.KnownPassphrases.FirstOrDefault(id => id.Thumbprint == thumbprint); if (passphrase != null) { return(true); } return(false); }
public void TestGetHashCode() { Passphrase key1 = new Passphrase("samekey"); Passphrase key2 = new Passphrase("samekey"); Salt salt1 = new Salt(512); Salt salt2 = new Salt(512); SymmetricKeyThumbprint thumbprint1a = new SymmetricKeyThumbprint(key1, salt1, 17); SymmetricKeyThumbprint thumbprint1b = new SymmetricKeyThumbprint(key1, salt2, 17); SymmetricKeyThumbprint thumbprint2a = new SymmetricKeyThumbprint(key2, salt2, 17); Assert.That(thumbprint1a.GetHashCode() != thumbprint1b.GetHashCode(), "The salt is different, so the hash code should be different."); Assert.That(thumbprint1b.GetHashCode() == thumbprint2a.GetHashCode(), "The keys are equivalent, and the salt the same, so the hash code should be different."); }
public void TestAesKeyThumbprintMethods() { Passphrase key1 = new Passphrase("key"); Passphrase key2 = new Passphrase("key"); Salt salt1 = new Salt(512); Salt salt2 = new Salt(salt1.GetBytes()); SymmetricKeyThumbprint thumbprint1 = new SymmetricKeyThumbprint(key1, salt1, 10); SymmetricKeyThumbprint thumbprint2 = new SymmetricKeyThumbprint(key2, salt2, 10); Assert.That(thumbprint1 == thumbprint2, "Two thumb prints made from the same key and salt bytes, although different AesKey instances should be equivalent."); SymmetricKeyThumbprint thumbprint3 = new SymmetricKeyThumbprint(new Passphrase("passphrase"), new Salt(512), 10); Assert.That(thumbprint2 != thumbprint3, "Two very different keys and salts should not be equivalent."); }
private IdentityPublicTag(SymmetricKeyThumbprint thumbprint, EmailAddress emailAddress) { _thumbprint = thumbprint; _email = emailAddress; }