public void SetLoginInformationURLTest() { // Arrange byte[] derivedKey = new byte[16] { 111, 222, 31, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 104, 15, 16 }; SymmetricKeyAlgorithm ska = SymmetricKeyAlgorithm.GenerateNew(SymmetricEncryptionAlgorithm.AES_CTR); LoginInformationSecret loginInformationSecret = new LoginInformationSecret(loginInformation, "does not matter", ska, derivedKey); string newURL = "https://newandbetter.future"; // Act string loginInformationURL1 = loginInformationSecret.GetURL(derivedKey); bool shouldBeTrue = loginInformationSecret.SetURL(newURL, derivedKey); string loginInformationURL2 = loginInformationSecret.GetURL(derivedKey); bool shouldBeFalse = loginInformationSecret.SetURL(newURL, new byte[] { 1, 2, 3 }); // Assert Assert.IsTrue(shouldBeTrue); Assert.IsFalse(shouldBeFalse); Assert.IsFalse(string.IsNullOrEmpty(loginInformationURL1)); Assert.IsFalse(string.IsNullOrEmpty(loginInformationURL2)); Assert.AreEqual(loginInformation.url, loginInformationURL1); Assert.AreEqual(newURL, loginInformationURL2); }
public static LoginSimplified TurnIntoEditable(LoginInformationSecret loginInformationSecret, byte[] derivedPassword, int zeroBasedIndexNumber) { return(new LoginSimplified() { zeroBasedIndexNumber = zeroBasedIndexNumber, IsSecure = true, Title = loginInformationSecret.GetTitle(derivedPassword), URL = loginInformationSecret.GetURL(derivedPassword), Email = loginInformationSecret.GetEmail(derivedPassword), Username = loginInformationSecret.GetUsername(derivedPassword), Password = loginInformationSecret.GetPassword(derivedPassword), Notes = loginInformationSecret.GetNotes(derivedPassword), Icon = loginInformationSecret.GetIcon(derivedPassword), Category = loginInformationSecret.GetCategory(derivedPassword), Tags = loginInformationSecret.GetTags(derivedPassword), CreationTime = loginInformationSecret.GetCreationTime(derivedPassword).ToString("s", System.Globalization.CultureInfo.InvariantCulture), ModificationTime = loginInformationSecret.GetModificationTime(derivedPassword).ToString("s", System.Globalization.CultureInfo.InvariantCulture), }); }
public void GetLoginInformationUrlTest() { // Arrange byte[] derivedKey = new byte[16] { 111, 222, 31, 4, 5, 6, 7, 88, 9, 107, 11, 12, 13, 104, 15, 16 }; byte[] initialCounter = new byte[] { 0xf0, 0xf1, 0xfb, 0xf3, 0xaa, 0xf5, 0xf6, 0xcc, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }; SettingsAES_CTR settingsAES_CTR = new SettingsAES_CTR(initialCounter); SymmetricKeyAlgorithm skaAES_CTR = new SymmetricKeyAlgorithm(SymmetricEncryptionAlgorithm.AES_CTR, 192, settingsAES_CTR); LoginInformationSecret loginInformationSecret = new LoginInformationSecret(loginInformation, "does not matter", skaAES_CTR, derivedKey); // Act string loginInformationUrl = loginInformationSecret.GetURL(derivedKey); // Assert Assert.IsFalse(string.IsNullOrEmpty(loginInformationUrl)); Assert.AreEqual(loginInformation.url, loginInformationUrl); }