public void EncryptionOfALookupFieldIsDeterministic() { const string input = "*****@*****.**"; var keyRing = new KeyRing(); var lookupProtector = new AspNetCoreIdentityEncryption.LookupProtector(keyRing); string output1 = lookupProtector.Protect(keyRing.CurrentKeyId, input); string output2 = lookupProtector.Protect(keyRing.CurrentKeyId, input); Assert.Equal(output1, output2); }
public void EncryptionTwoDifferentPlainTextsDoesNotProduceTheSameResult() { const string input1 = "*****@*****.**"; const string input2 = "*****@*****.**"; var keyRing = new KeyRing(); var lookupProtector = new AspNetCoreIdentityEncryption.LookupProtector(keyRing); string output1 = lookupProtector.Protect(keyRing.CurrentKeyId, input1); string output2 = lookupProtector.Protect(keyRing.CurrentKeyId, input2); Assert.NotEqual(output1, output2); }
public void RoatingTheKeyRingProducesDifferentResultsFromEncryption() { const string input = "*****@*****.**"; var keyRing = new KeyRing(); var lookupProtector = new AspNetCoreIdentityEncryption.LookupProtector(keyRing); var keyId = keyRing.CurrentKeyId; var result1 = lookupProtector.Protect(keyId, input); keyRing.CreateAndActivateNewKey(); var newKeyId = keyRing.CurrentKeyId; var result2 = lookupProtector.Protect(newKeyId, input); Assert.NotEqual(result1, result2); }
public void EncryptThenDecryptProducesPlainText() { const string input = "*****@*****.**"; var keyRing = new KeyRing(); var keyId = keyRing.CurrentKeyId; var lookupProtector = new AspNetCoreIdentityEncryption.LookupProtector(keyRing); var cipherText = lookupProtector.Protect(keyId, input); var plainText = lookupProtector.Unprotect(keyId, cipherText); Assert.Equal(input, plainText); }
public void RoatingTheKeyRingDoesNotBreakDecryption() { const string input = "*****@*****.**"; var keyRing = new KeyRing(); var keyId = keyRing.CurrentKeyId; var lookupProtector = new AspNetCoreIdentityEncryption.LookupProtector(keyRing); var cipherText = lookupProtector.Protect(keyId, input); keyRing.CreateAndActivateNewKey(); var plainText = lookupProtector.Unprotect(keyId, cipherText); Assert.Equal(input, plainText); }