diff --git a/enzevalos_iphone/IntroContactTableViewController.swift b/enzevalos_iphone/IntroContactTableViewController.swift index e7a793e1aea96b80c5eb8a2cd927c464d42a5600..7817838132a756f915acf3d976366eb3325c347b 100644 --- a/enzevalos_iphone/IntroContactTableViewController.swift +++ b/enzevalos_iphone/IntroContactTableViewController.swift @@ -9,7 +9,6 @@ import Foundation class IntroContactTableViewController: UITableViewController, IntroInfoButton { - //var contacts: [String: [EnzevalosContact]] = [:] var contacts: [String: [(EnzevalosContact, PersistentKey, [Mail_Address])]] = [:] var selected: Set<IndexPath> = Set<IndexPath>.init() var nextAction: (() -> ())? = nil @@ -71,15 +70,6 @@ class IntroContactTableViewController: UITableViewController, IntroInfoButton { } } -// override func viewWillAppear(_ animated: Bool) { -// super.viewWillAppear(animated) -// for index in selected { -// tableView.selectRow(at: index, animated: false, scrollPosition: .none) -// tableView.delegate?.tableView!(tableView, didSelectRowAt: index) -// } -// //tableView.reloadData() -// } - override func numberOfSections(in tableView: UITableView) -> Int { return 27 } diff --git a/enzevalos_iphone/IntroInputViewController.swift b/enzevalos_iphone/IntroInputViewController.swift index 699acd6c1a7fef04717aa179c06671473592c9fb..3ab9976f3e173388fd5be859e722a076c60659cb 100644 --- a/enzevalos_iphone/IntroInputViewController.swift +++ b/enzevalos_iphone/IntroInputViewController.swift @@ -113,8 +113,7 @@ extension IntroInputViewController: UITextViewDelegate { return false } if !("0123456789-".map { String($0) }.contains(text)) && text != "" { - //TODO: use this again -// return false + return false } return true } diff --git a/enzevalos_iphone/IntroPageViewController.swift b/enzevalos_iphone/IntroPageViewController.swift index 9db373bd4e541100854a5d336303db2ae106f801..f3adf41abf4acc82c2679ccf103eb1887e37e42e 100644 --- a/enzevalos_iphone/IntroPageViewController.swift +++ b/enzevalos_iphone/IntroPageViewController.swift @@ -94,7 +94,6 @@ extension IntroPageViewController: UIPageViewControllerDataSource { return nil } - } extension IntroPageViewController: UIPageViewControllerDelegate { diff --git a/enzevalos_iphone/IntroSecretViewController.swift b/enzevalos_iphone/IntroSecretViewController.swift index 81a1f489279f4789c78f0792cb1752e5bf4fdb32..1151d42d3ee78a9c940df8a0dccbc0ad44005e44 100644 --- a/enzevalos_iphone/IntroSecretViewController.swift +++ b/enzevalos_iphone/IntroSecretViewController.swift @@ -75,7 +75,6 @@ class IntroSecretViewController: UIViewController, IntroInfoButton { secretLabel.text = secretText if let navigationController = navigationController { self.navigationItem.setRightBarButton(UIBarButtonItem(title: doneText, style: .plain, target: self, action: #selector(doneTapped(_:))), animated: true) - //navigationController.navigationItem.setRightBarButton(UIBarButtonItem(barButtonSystemItem: .done, target: self, action: nil), animated: true) } getButton().addTarget(self, action: #selector(titleTapped(sender:)), for: .touchUpInside) } diff --git a/enzevalos_iphone/TravelHandler.swift b/enzevalos_iphone/TravelHandler.swift index 5ebaca65b2b8f111cdfcd38fd5c6ba6775fe1bfb..d4ad387d8bb6630c557d0719010391fe26ebedc6 100644 --- a/enzevalos_iphone/TravelHandler.swift +++ b/enzevalos_iphone/TravelHandler.swift @@ -42,8 +42,8 @@ public class TravelHandler { public static let backupFolder = UserManager.convertToBackendFolderPath(from: "Travel-Backup") public static let backupHeader = "Travel-Backup" public static let keyManagementFolder = UserManager.convertToBackendFolderPath(from: "Travel-Keymanagement") - public static let callForRepealMimeType = MIMETYPE.travelRepeal.rawValue //"application/x-travel.repeal" - public static let callForUseMimeType = MIMETYPE.travelUse.rawValue //"application/x-travel.use" + public static let callForRepealMimeType = MIMETYPE.travelRepeal.rawValue //"application/x.travel.repeal" + public static let callForUseMimeType = MIMETYPE.travelUse.rawValue //"application/x.travel.use" public static let callForUseSecretHeader = "SECRET: " public static let callForUseFingerprintHeader = "FINGERPRINT: " @@ -63,8 +63,6 @@ public class TravelHandler { private static var homeIcon: UIImage { get { -// let tintableImage = #imageLiteral(resourceName: "home2_white").withRenderingMode(.alwaysTemplate) -// return tintableImage.tint(color: .black) return #imageLiteral(resourceName: "home") } } @@ -179,13 +177,6 @@ public class TravelHandler { fileprivate init() { } - //Per contact (with address addr) get key via - // if let adr = DataHandler.handler.findMailAddress(adr: addr), adr.hasKey { - // pgp.exportKey(id: adr.primaryKey, isSecretkey: false, autocrypt: false) - // } - //and compare it in follow-up phase with key found as primary-key field of corresponding address - - /*throw different Errors: * all mails could not be sent * some mails could not be sent @@ -197,9 +188,7 @@ public class TravelHandler { guard mode != .borderCrossing else { throw TravelHandlerError.invalidMode } - //get keys for contacts - // discard contacts, who do not have a key (should be checked in the ui prior calling this function too) - //call Traveler + var contactsWithKey: [String] = [] let pgp = SwiftPGP() var keys: [String: String] = [:] @@ -212,10 +201,11 @@ public class TravelHandler { canSecurelyBackup = true } let backupAddress = self.backupAddress! - //here may lie a attackvector, when traveling over multiple borders. An attacker can exchange the backup key in an early bordercrossing (i.e. the corresponding follow-up fails). we have to handle the manipulated key in following crossings! let backupKey = pgp.exportKey(id: backupKeyID!, isSecretkey: false, autocrypt: false)! + //get keys for contacts for c in contacts { + // discard contacts, who do not have a key (should be checked in the ui prior calling this function too) if let adr = DataHandler.handler.findMailAddress(adr: c), adr.hasKey, let primaryKey = adr.primaryKey { contactsWithKey.append(c) keyIDs[c] = primaryKey.keyID @@ -229,11 +219,9 @@ public class TravelHandler { mailHandler.sendTravelRepeal(to: c, keyID: keyIDs[c]!, sharedSecret: sharedSecrets[c]!, callback: {_ in }) //TODO: use outbox here! } mode = .borderCrossing - //TODO: delete pervious communication if wanted if TravelHandler.deleteCommunication { DataHandler.handler.deleteDecryptedMailCopies() } - //TODO: delete sharedSecrets of others DataHandler.handler.deleteSecretKeys() let data = traveler.getToStore() travelerStored = data @@ -347,7 +335,7 @@ public class TravelHandler { var ids: [String] = [] regular: for mail in regularBackup { if let attachmentSet = mail.attachments, let attachments = Array(attachmentSet) as? [Attachment] { - let backupAttachments = attachments.filter({$0.mimeType ?? "" == MIMETYPE.autocryptSetup.rawValue}) //TODO: currently there are no mails, since they are not handled and Attachments aren't saved + let backupAttachments = attachments.filter({$0.mimeType ?? "" == MIMETYPE.autocryptSetup.rawValue}) for attachment in backupAttachments { if let data = attachment.data, let keyString = String(data: data, encoding: .utf8) { ids = pgp.importKey(passcode, key: keyString) @@ -392,12 +380,12 @@ public class TravelHandler { private func getTravelIntro(current viewController: UIViewController) -> UIViewController { var controllers: [UIViewController] = [] - var description1 = IntroDescriptionViewController.storyboardInstance(description: NSLocalizedString("TravelIntroAtHome", comment: ""), skipButtonAction: {_ in })! //TODO: depend skipButtonAction on entry in userdefaults, if the user was using this feature before + var description1 = IntroDescriptionViewController.storyboardInstance(description: NSLocalizedString("TravelIntroAtHome", comment: ""), skipButtonAction: {_ in })! if mode != .atHome { if canSecurelyBackup { - description1 = IntroDescriptionViewController.storyboardInstance(description: NSLocalizedString("TravelIntroNotAtHome", comment: ""), skipButtonAction: {_ in })! //TODO: depend skipButtonAction on entry in userdefaults, if the user was using this feature before + description1 = IntroDescriptionViewController.storyboardInstance(description: NSLocalizedString("TravelIntroNotAtHome", comment: ""), skipButtonAction: {_ in })! } else { - description1 = IntroDescriptionViewController.storyboardInstance(description: NSLocalizedString("TravelIntroNotAtHomeNoBackup", comment: ""), skipButtonAction: {_ in })! //TODO: depend skipButtonAction on entry in userdefaults, if the user was using this feature before + description1 = IntroDescriptionViewController.storyboardInstance(description: NSLocalizedString("TravelIntroNotAtHomeNoBackup", comment: ""), skipButtonAction: {_ in })! } } controllers.append(description1) @@ -412,7 +400,6 @@ public class TravelHandler { controllers.append(overviewController3) if mode == .atHome { let backupController = IntroButtonViewController.storyboardInstance(description: NSLocalizedString("TravelIntroBackup", comment: ""), buttonAction: {_ in viewController.navigationController?.pushViewController(ExportInfoViewController.storyboardInstance(travelCall: true)!, animated: true)})! - //"Um alle vorangangenen Nachrichten nach deiner Reise wieder lesen zu können, solltest du vor deiner Reise ein Backup erstellen. Wenn du noch keines erstellt hast, solltest du es jetzt tun.\n\nBeachte, dass wir zum Schutz deiner Geheimnisse während der Reise alle Backup-Codes löschen. Du solltest bestehende Codes jetzt notieren und zuhause lassen." backupController.buttonText = NSLocalizedString("CreateBackup", comment: "") controllers.append(backupController) } else if canSecurelyBackup { @@ -427,19 +414,15 @@ public class TravelHandler { controllers.append(describeContactsController) let contacts = getSecureContacts() let contactViewController = IntroContactTableViewController.storyboardInstance(contacts: contacts, titleText: NSLocalizedString("SelectContacts", comment: ""), titleDescription: NSLocalizedString("TravelSelectContacts", comment: ""))! - //controllers.append(contactViewController) let decisionController = IntroYesNoViewController.storyboardInstance(description: NSLocalizedString("TravelCloseLetters", comment: ""), titleText: NSLocalizedString("CloseLetters", comment: ""), titleDescription: NSLocalizedString("CloseLettersDescription", comment: ""))! if !canSecurelyBackup { decisionController.titleImage = TravelHandler.troublePlaneIcon decisionController.titleDescription = NSLocalizedString("CloseLettersDescriptionCannotReopen", comment: "") decisionController.text = NSLocalizedString("TravelCloseLettersDescriptionCannotReopen", comment: "") } - //"Möchtest du alle unverschlüsselten Kopien der bisherigen Nachrichten löschen?\n\n Wenn du das möchtest, bleiben alle Nachrichten erhalten, du kannst sie allerdings so lange nicht lesen, bis du zuhause dein Backup geladen hast." let describeSecretController = IntroButtonViewController.storyboardInstance(description: NSLocalizedString("Travel.Prepare.ShouldShowPassword.Description", comment: ""), buttonText: NSLocalizedString("Continue", comment: ""), titleText: "Passwort merken", titleDescription: NSLocalizedString("Travel.Prepare.ShouldShowPassword.TitleDescription", comment: ""))! - //controllers.append(describeContactsController) let secretController = IntroSecretViewController.storyboardInstance(description: NSLocalizedString("Travel.Prepare.PresentSecret.Description", comment: ""), secret: "s", titleText: "Passwort merken", titleDescription: "Merke dir das Passwort gut, du benötigst es nach deinem Grenzübertritt, um wieder sicher kommunizieren zu können.", alternateText: NSLocalizedString("Travel.Prepare.PresentSecret.wrongSecret.Description", comment: ""))! - // controllers.append(secretController) - let recommendationsController = IntroButtonViewController.storyboardInstance(description: "Wenn du an der Grenze kontrolliert wirst, liegt es in deinem Ermessen, wie stark du mit den Kontrolleuren kooperierst. Kooperierst du nicht, kann es u.a. sein, dass du Strafen zahlen musst. Wenn du Zugang zu Daten von dir lässt, betone vorher ausdrücklich, dass es nicht in deinem Einverständnis passiert. Bleibe dabei jedoch ruhig.\nBehalte deine Geräte die ganze Zeit über im Auge und lüge die Kontrolleure nicht an.\nKurz vor der Kontrolle solltest du deine Geräte ausschalten.", buttonAction: {_ in UIApplication.shared.openURL(URL(string: TravelHandler.website)!)}, titleText: "Während der Kontrolle", titleDescription: "Beachte die dargestellten Hinweise, falls du und deine Geräte kontrolliert werden. Für weitere Hinweise und Informationen besuche unsere Webseite.")! //TODO: add Text here //"Wie mit Grenzbeamten umgehen? und sich generell wie an der Grenze verhalten?\n\nTelefon vorher ausschalten\n\nAuf mögliche Kompromittierung hinweisen\n\nweitere Infos?" + let recommendationsController = IntroButtonViewController.storyboardInstance(description: "Wenn du an der Grenze kontrolliert wirst, liegt es in deinem Ermessen, wie stark du mit den Kontrolleuren kooperierst. Kooperierst du nicht, kann es u.a. sein, dass du Strafen zahlen musst. Wenn du Zugang zu Daten von dir lässt, betone vorher ausdrücklich, dass es nicht in deinem Einverständnis passiert. Bleibe dabei jedoch ruhig.\nBehalte deine Geräte die ganze Zeit über im Auge und lüge die Kontrolleure nicht an.\nKurz vor der Kontrolle solltest du deine Geräte ausschalten.", buttonAction: {_ in UIApplication.shared.openURL(URL(string: TravelHandler.website)!)}, titleText: "Während der Kontrolle", titleDescription: "Beachte die dargestellten Hinweise, falls du und deine Geräte kontrolliert werden. Für weitere Hinweise und Informationen besuche unsere Webseite.")! recommendationsController.buttonText = NSLocalizedString("MoreInformation", comment: "get more info at our website") let pageViewController = IntroPageViewController.storyboardInstance(orderedViewControllers: controllers, titleText: "Vorbereitung", titleDescription: "In diesem Schritt wird dir das Verfahren kurz erläutert. Eine Sicherung wird automatisch erstellt.")