Skip to content
Snippets Groups Projects
Commit ad594290 authored by Oliver Wiese's avatar Oliver Wiese
Browse files

keyID of secretkey is not optional

parent 1b3e5bf2
Branches
Tags
No related merge requests found
Showing
with 301 additions and 53 deletions
...@@ -144,7 +144,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -144,7 +144,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}) })
let handler = DataHandler.init() let handler = DataHandler.init()
let keyId = handler.createNewSecretKey(adr: UserManager.loadUserValue(Attribute.userAddr) as! String) let keyId = handler.createNewSecretKey(adr: UserManager.loadUserValue(Attribute.userAddr) as! String)
_ = handler.getContact(name: UserManager.loadUserValue(Attribute.accountname) as! String, address: UserManager.loadUserValue(Attribute.userAddr) as! String, key: keyId.keyID!, prefer_enc: true) _ = handler.getContact(name: UserManager.loadUserValue(Attribute.accountname) as! String, address: UserManager.loadUserValue(Attribute.userAddr) as! String, key: keyId.keyID, prefer_enc: true)
handler.save(during: "setup user") handler.save(during: "setup user")
StudySettings.setupStudyKeys() StudySettings.setupStudyKeys()
Mailbot.firstMail() Mailbot.firstMail()
......
...@@ -114,14 +114,13 @@ class Autocrypt { ...@@ -114,14 +114,13 @@ class Autocrypt {
let encPref = EncState.MUTUAL let encPref = EncState.MUTUAL
let pgp = SwiftPGP() let pgp = SwiftPGP()
if let id = skID { if let key = pgp.exportKey(id: skID, isSecretkey: false, autocrypt: true) {
if let key = pgp.exportKey(id: id, isSecretkey: false, autocrypt: true) {
var string = "\(ADDR)=" + adr var string = "\(ADDR)=" + adr
string = string + "; \(ENCRYPTION)=\(encPref.name)" string = string + "; \(ENCRYPTION)=\(encPref.name)"
string = string + "; \(KEY)=" + key string = string + "; \(KEY)=" + key
builder.header.setExtraHeaderValue(string, forName: AUTOCRYPTHEADER) builder.header.setExtraHeaderValue(string, forName: AUTOCRYPTHEADER)
} }
}
} }
static func recommandateEncryption (receiver: MailAddress) -> (hasAutocrypt: Bool, recommandEnc: Bool){ static func recommandateEncryption (receiver: MailAddress) -> (hasAutocrypt: Bool, recommandEnc: Bool){
......
...@@ -304,7 +304,7 @@ class DataHandler { ...@@ -304,7 +304,7 @@ class DataHandler {
sk = NSEntityDescription.insertNewObject(forEntityName: "SecretKey", into: managedObjectContext) as! SecretKey sk = NSEntityDescription.insertNewObject(forEntityName: "SecretKey", into: managedObjectContext) as! SecretKey
sk.keyID = keyID sk.keyID = keyID
sk.obsolete = false sk.obsolete = false
sk.importedDate = Date() sk.importedDate = Date() as NSDate
UserManager.storeUserValue(keyID as AnyObject, attribute: Attribute.prefSecretKeyID) UserManager.storeUserValue(keyID as AnyObject, attribute: Attribute.prefSecretKeyID)
let adr = UserManager.loadUserValue(Attribute.userAddr) as! String let adr = UserManager.loadUserValue(Attribute.userAddr) as! String
let name = adr // TODO Change here displayname let name = adr // TODO Change here displayname
......
...@@ -54,7 +54,8 @@ class ExportViewController: UITableViewController { ...@@ -54,7 +54,8 @@ class ExportViewController: UITableViewController {
let handler = DataHandler.handler let handler = DataHandler.handler
let sk = handler.prefSecretKey() //handler.findSecretKeys() let sk = handler.prefSecretKey() //handler.findSecretKeys()
let pgp = SwiftPGP() let pgp = SwiftPGP()
if let sk = sk, let keyId = sk.keyID { if let sk = sk {
let keyId = sk.keyID
if alreadySent { if alreadySent {
if let message = pgp.exportKey(id: keyId, isSecretkey: true, autocrypt: true, newPasscode: true) { if let message = pgp.exportKey(id: keyId, isSecretkey: true, autocrypt: true, newPasscode: true) {
passcode = pgp.loadExportPasscode(id: keyId)! passcode = pgp.loadExportPasscode(id: keyId)!
...@@ -148,11 +149,10 @@ class ExportViewController: UITableViewController { ...@@ -148,11 +149,10 @@ class ExportViewController: UITableViewController {
if ids.count > 0 { if ids.count > 0 {
let id = ids[0] let id = ids[0]
let pgp = SwiftPGP() let pgp = SwiftPGP()
if let keyId = id.keyID { let keyId = id.keyID
passcode = pgp.loadExportPasscode(id: keyId) ?? "" passcode = pgp.loadExportPasscode(id: keyId) ?? ""
alreadySent = passcode != "" alreadySent = passcode != ""
} }
}
// Logger.queue.async(flags: .barrier) { // Logger.queue.async(flags: .barrier) {
......
...@@ -112,7 +112,6 @@ class InboxViewController: UITableViewController, InboxCellDelegator { ...@@ -112,7 +112,6 @@ class InboxViewController: UITableViewController, InboxCellDelegator {
} else { } else {
lastUpdateText = NSLocalizedString("NeverUpdated", comment: "Error while loading mailscomment") lastUpdateText = NSLocalizedString("NeverUpdated", comment: "Error while loading mailscomment")
if AppDelegate.getAppDelegate().currentReachabilityStatus != .notReachable && counterRefreshs < 100{ if AppDelegate.getAppDelegate().currentReachabilityStatus != .notReachable && counterRefreshs < 100{
print("REFRESH AGAIN!")
counterRefreshs += 1 counterRefreshs += 1
refresh(nil) refresh(nil)
} }
......
...@@ -86,7 +86,7 @@ class ItunesKeyHandling { ...@@ -86,7 +86,7 @@ class ItunesKeyHandling {
func importPublicKeys() -> [String]{ func importPublicKeys() -> [String]{
var publicKeys = storedKeys.filter{!$0.isSecret} var publicKeys = storedKeys.filter{!$0.isSecret}
publicKeys = publicKeys.filter{DataHandler.handler.findKey(keyID: $0.keyID!) == nil} publicKeys = publicKeys.filter{DataHandler.handler.findKey(keyID: $0.keyID) == nil}
let keyIds = pgp.store(tempKeys: publicKeys) let keyIds = pgp.store(tempKeys: publicKeys)
//TODO: Store in Datahandler -> in tempKey? //TODO: Store in Datahandler -> in tempKey?
return keyIds return keyIds
...@@ -104,9 +104,7 @@ class MinimalImportUI { ...@@ -104,9 +104,7 @@ class MinimalImportUI {
var secretKeyPasswordField: UITextField? = nil var secretKeyPasswordField: UITextField? = nil
func importSecretKeyDialog(first: Bool) { func importSecretKeyDialog(first: Bool) {
guard let keyID = secretKey.keyID else { let keyID = secretKey.keyID
return
}
let format = NSLocalizedString("Read.Import.Secret.Body.Plain", comment: "NewSecretKeyMessage") let format = NSLocalizedString("Read.Import.Secret.Body.Plain", comment: "NewSecretKeyMessage")
var message = String.localizedStringWithFormat(format, keyID) var message = String.localizedStringWithFormat(format, keyID)
if secretKey.hasPassword { if secretKey.hasPassword {
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
......
...@@ -857,9 +857,7 @@ class MailHandler { ...@@ -857,9 +857,7 @@ class MailHandler {
let secretkeys = DataHandler.handler.findSecretKeys() let secretkeys = DataHandler.handler.findSecretKeys()
var decIds = [String]() var decIds = [String]()
for sk in secretkeys { for sk in secretkeys {
if let id = sk.keyID { decIds.append(sk.keyID)
decIds.append(id)
}
} }
return pgp.decrypt(data: data, decKeyIDs: decIds, signatureIDs: keyIds, fromAddr: sender ?? "") return pgp.decrypt(data: data, decKeyIDs: decIds, signatureIDs: keyIds, fromAddr: sender ?? "")
......
...@@ -268,10 +268,13 @@ class OutgoingMail { ...@@ -268,10 +268,13 @@ class OutgoingMail {
var missingOwnPublic = false var missingOwnPublic = false
var pgpKeyIds: [String] = [] var pgpKeyIds: [String] = []
var skKeyID = "" var skKeyID = ""
if let sk = sk, let skID = sk.keyID { if let sk = sk {
let skID = sk.keyID
pgpKeyIds.append(skID) pgpKeyIds.append(skID)
skKeyID = skID skKeyID = skID
} }
if !onlySelfEnc { if !onlySelfEnc {
pgpKeyIds.append(contentsOf: OutgoingMail.addKeys(adrs: pgpAddresses)) pgpKeyIds.append(contentsOf: OutgoingMail.addKeys(adrs: pgpAddresses))
} }
...@@ -285,7 +288,8 @@ class OutgoingMail { ...@@ -285,7 +288,8 @@ class OutgoingMail {
} }
} }
if missingOwnPublic, let sk = sk { if missingOwnPublic, let sk = sk {
if let id = sk.keyID, let myPK = pgp.exportKey(id: id, isSecretkey: false, autocrypt: false), let data = myPK.data(using: .utf8) { let id = sk.keyID
if let myPK = pgp.exportKey(id: id, isSecretkey: false, autocrypt: false), let data = myPK.data(using: .utf8) {
addAttachment(filename: "\(id).asc", mimeType: "application/pgp-keys", charset: nil, data: data) addAttachment(filename: "\(id).asc", mimeType: "application/pgp-keys", charset: nil, data: data)
} }
} }
......
//
// SecretKey+CoreDataClass.swift
// enzevalos_iphone
//
// Created by Oliver Wiese on 02.10.19.
// Copyright © 2019 fu-berlin. All rights reserved.
//
//
import Foundation
import CoreData
@objc(SecretKey)
public class SecretKey: NSManagedObject {
}
//
// SecretKey+CoreDataProperties.swift
// enzevalos_iphone
//
// Created by Oliver Wiese on 02.10.19.
// Copyright © 2019 fu-berlin. All rights reserved.
//
//
import Foundation
import CoreData
extension SecretKey {
@nonobjc public class func fetchRequest() -> NSFetchRequest<SecretKey> {
return NSFetchRequest<SecretKey>(entityName: "SecretKey")
}
@NSManaged public var exported: Bool
@NSManaged public var importedDate: NSDate?
@NSManaged public var keyID: String
@NSManaged public var obsolete: Bool
@NSManaged public var origin: Int16
@NSManaged public var account: Account?
@NSManaged public var decryptedMails: NSSet?
}
// MARK: Generated accessors for decryptedMails
extension SecretKey {
@objc(addDecryptedMailsObject:)
@NSManaged public func addToDecryptedMails(_ value: PersistentMail)
@objc(removeDecryptedMailsObject:)
@NSManaged public func removeFromDecryptedMails(_ value: PersistentMail)
@objc(addDecryptedMails:)
@NSManaged public func addToDecryptedMails(_ values: NSSet)
@objc(removeDecryptedMails:)
@NSManaged public func removeFromDecryptedMails(_ values: NSSet)
}
...@@ -11,7 +11,7 @@ import Foundation ...@@ -11,7 +11,7 @@ import Foundation
class SecretKeyTableViewController: UITableViewController { class SecretKeyTableViewController: UITableViewController {
static let storyboardID = "secretKeyTable" static let storyboardID = "secretKeyTable"
var keys: [DisplaySecretKey] = [] var keys: [DisplayKey] = []
private var prefKeyID: String? { private var prefKeyID: String? {
get { get {
...@@ -76,10 +76,8 @@ class SecretKeyTableViewController: UITableViewController { ...@@ -76,10 +76,8 @@ class SecretKeyTableViewController: UITableViewController {
return return
} }
let newPrefKey = keys[indexPath.row] let newPrefKey = keys[indexPath.row]
guard let id = newPrefKey.keyID else { let id = newPrefKey.keyID
tableView.reloadRows(at: [indexPath], with: .none)
return
}
let pgp = SwiftPGP.init() let pgp = SwiftPGP.init()
if pgp.checkPasswordFor(secretKeyID: id, password: nil, secretkey: newPrefKey.pgpKey) { if pgp.checkPasswordFor(secretKeyID: id, password: nil, secretkey: newPrefKey.pgpKey) {
changePrefKey(tableView: tableView, indexPath: indexPath) changePrefKey(tableView: tableView, indexPath: indexPath)
......
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
import Foundation import Foundation
protocol DisplaySecretKey { protocol DisplayKey {
var importDate: Date { var importDate: Date {
get get
} }
var keyID: String? { var keyID: String {
get get
} }
var pgpKey: Key? { var pgpKey: Key? {
...@@ -22,7 +22,8 @@ protocol DisplaySecretKey { ...@@ -22,7 +22,8 @@ protocol DisplaySecretKey {
func save() -> SecretKey? func save() -> SecretKey?
} }
class TempKey: DisplaySecretKey { class TempKey: DisplayKey {
var pgpkey: Key var pgpkey: Key
let mailAddresses: [String] let mailAddresses: [String]
let importDate: Date let importDate: Date
...@@ -46,7 +47,7 @@ class TempKey: DisplaySecretKey { ...@@ -46,7 +47,7 @@ class TempKey: DisplaySecretKey {
} }
} }
var keyID: String? { var keyID: String {
get { get {
return pgpkey.keyID.longIdentifier return pgpkey.keyID.longIdentifier
} }
...@@ -100,27 +101,45 @@ class TempKey: DisplaySecretKey { ...@@ -100,27 +101,45 @@ class TempKey: DisplaySecretKey {
} }
} }
extension SecretKey: DisplaySecretKey { extension SecretKey: DisplayKey {
var importDate: Date { var importDate: Date {
if let date = self.importedDate { if let date = self.importedDate {
return date return date as Date
} }
let date = Date.init() let date = Date.init()
self.importedDate = date self.importedDate = date as NSDate
return date return date
} }
var pgpKey: Key? { var pgpKey: Key? {
let pgp = SwiftPGP() let pgp = SwiftPGP()
if let id = keyID { let id = keyID
return pgp.loadKey(id: id) return pgp.loadKey(id: id)
} }
return nil
}
func save() -> SecretKey? { func save() -> SecretKey? {
return self return self
} }
}
extension PersistentKey: DisplayKey {
var importDate: Date {
if let date = self.discoveryDate {
return date
}
else {
let date = Date()
self.discoveryDate = date
return date
}
}
var pgpKey: Key? {
let pgp = SwiftPGP()
return pgp.loadKey(id: keyID)
}
func save() -> SecretKey? {
return nil
}
} }
...@@ -296,7 +296,7 @@ public class TravelHandler { ...@@ -296,7 +296,7 @@ public class TravelHandler {
if let fingerprint = DataHandler.handler.getMailAddress(UserManager.loadUserValue(Attribute.userAddr) as! String, temporary: true).primaryKey!.currentlyActiveKey.fingerprint { if let fingerprint = DataHandler.handler.getMailAddress(UserManager.loadUserValue(Attribute.userAddr) as! String, temporary: true).primaryKey!.currentlyActiveKey.fingerprint {
oldFingerprint = fingerprint oldFingerprint = fingerprint
} }
let keyID = DataHandler.handler.createNewSecretKey(adr: UserManager.loadUserValue(Attribute.userAddr) as! String).keyID! let keyID = DataHandler.handler.createNewSecretKey(adr: UserManager.loadUserValue(Attribute.userAddr) as! String).keyID
let pubKey = pgp.exportKey(id: keyID, isSecretkey: false, autocrypt: false)! let pubKey = pgp.exportKey(id: keyID, isSecretkey: false, autocrypt: false)!
let sharedSecrets = try traveler.getToSend() let sharedSecrets = try traveler.getToSend()
for c in traveler.contacts { for c in traveler.contacts {
...@@ -333,7 +333,7 @@ public class TravelHandler { ...@@ -333,7 +333,7 @@ public class TravelHandler {
if let fingerprint = DataHandler.handler.getMailAddress(UserManager.loadUserValue(Attribute.userAddr) as! String, temporary: true).primaryKey!.currentlyActiveKey.fingerprint { if let fingerprint = DataHandler.handler.getMailAddress(UserManager.loadUserValue(Attribute.userAddr) as! String, temporary: true).primaryKey!.currentlyActiveKey.fingerprint {
oldFingerprint = fingerprint oldFingerprint = fingerprint
} }
let keyID = DataHandler.handler.createNewSecretKey(adr: UserManager.loadUserValue(Attribute.userAddr) as! String).keyID! let keyID = DataHandler.handler.createNewSecretKey(adr: UserManager.loadUserValue(Attribute.userAddr) as! String).keyID
let pubKey = pgp.exportKey(id: keyID, isSecretkey: false, autocrypt: false)! let pubKey = pgp.exportKey(id: keyID, isSecretkey: false, autocrypt: false)!
let traveler: Traveler let traveler: Traveler
if let data = travelerStored { if let data = travelerStored {
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>_XCCurrentVersionName</key> <key>_XCCurrentVersionName</key>
<string>enzevalos_iphone 7.xcdatamodel</string> <string>enzevalos_iphone 8.xcdatamodel</string>
</dict> </dict>
</plist> </plist>
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
<entity name="SecretKey" representedClassName="SecretKey" syncable="YES" codeGenerationType="class"> <entity name="SecretKey" representedClassName="SecretKey" syncable="YES" codeGenerationType="class">
<attribute name="exported" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/> <attribute name="exported" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="importedDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/> <attribute name="importedDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="keyID" optional="YES" attributeType="String" syncable="YES"/> <attribute name="keyID" optional="YES" attributeType="String" defaultValueString="nil" syncable="YES"/>
<attribute name="obsolete" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/> <attribute name="obsolete" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="keys" inverseEntity="Account" syncable="YES"/> <relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="keys" inverseEntity="Account" syncable="YES"/>
<relationship name="decryptedMails" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="decryptedKey" inverseEntity="PersistentMail" syncable="YES"/> <relationship name="decryptedMails" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="decryptedKey" inverseEntity="PersistentMail" syncable="YES"/>
...@@ -168,7 +168,7 @@ ...@@ -168,7 +168,7 @@
<element name="Mail_Address" positionX="-297" positionY="-18" width="128" height="210"/> <element name="Mail_Address" positionX="-297" positionY="-18" width="128" height="210"/>
<element name="PersistentKey" positionX="-315" positionY="-36" width="128" height="390"/> <element name="PersistentKey" positionX="-315" positionY="-36" width="128" height="390"/>
<element name="PersistentMail" positionX="-416" positionY="-189" width="128" height="30"/> <element name="PersistentMail" positionX="-416" positionY="-189" width="128" height="30"/>
<element name="SecretKey" positionX="-306" positionY="-27" width="128" height="135"/> <element name="SecretKey" positionX="-306" positionY="-27" width="128" height="133"/>
<element name="Server" positionX="-306" positionY="-27" width="128" height="135"/> <element name="Server" positionX="-306" positionY="-27" width="128" height="135"/>
</elements> </elements>
</model> </model>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14490.99" systemVersion="18G95" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Account" representedClassName="Account" syncable="YES" codeGenerationType="class">
<attribute name="archiveFolderPath" attributeType="String" syncable="YES"/>
<attribute name="displayName" attributeType="String" syncable="YES"/>
<attribute name="draftFolderPath" attributeType="String" syncable="YES"/>
<attribute name="inboxFolderPath" attributeType="String" syncable="YES"/>
<attribute name="loginName" attributeType="String" syncable="YES"/>
<attribute name="prefEnc" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="prefMailAdr" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="prefSecretKeyID" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="sentFolderPath" attributeType="String" syncable="YES"/>
<attribute name="trashFolderPath" attributeType="String" syncable="YES"/>
<relationship name="aliase" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Mail_Address" inverseName="account" inverseEntity="Mail_Address" syncable="YES"/>
<relationship name="imap" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Server" inverseName="imap" inverseEntity="Server" syncable="YES"/>
<relationship name="keys" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="SecretKey" inverseName="account" inverseEntity="SecretKey" syncable="YES"/>
<relationship name="smtp" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Server" inverseName="smtp" inverseEntity="Server" syncable="YES"/>
</entity>
<entity name="Attachment" representedClassName="Attachment" syncable="YES" codeGenerationType="class">
<attribute name="contentID" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="data" attributeType="Binary" syncable="YES"/>
<attribute name="encryptionState" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="isExplicitAttachment" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="mcoPartType" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="mimeType" attributeType="String" syncable="YES"/>
<attribute name="name" attributeType="String" syncable="YES"/>
<attribute name="signatureState" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<relationship name="mail" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="attachments" inverseEntity="PersistentMail" syncable="YES"/>
<relationship name="parentOf" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Attachment" inverseName="partOf" inverseEntity="Attachment" syncable="YES"/>
<relationship name="partOf" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Attachment" inverseName="parentOf" inverseEntity="Attachment" syncable="YES"/>
</entity>
<entity name="EnzevalosContact" representedClassName="EnzevalosContact" syncable="YES">
<attribute name="cnidentifier" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="color" optional="YES" attributeType="Transformable" customClassName="UIColor" syncable="YES"/>
<attribute name="displayname" attributeType="String" syncable="YES"/>
<relationship name="addresses" toMany="YES" deletionRule="Cascade" destinationEntity="Mail_Address" inverseName="contact" inverseEntity="Mail_Address" syncable="YES"/>
<relationship name="keyrecords" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="KeyRecord" inverseName="contact" inverseEntity="KeyRecord" syncable="YES"/>
</entity>
<entity name="Folder" representedClassName="Folder" syncable="YES">
<attribute name="delimiter" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="flags" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="icon" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="lastUpdate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="maxID" optional="YES" attributeType="Decimal" defaultValueString="1" syncable="YES"/>
<attribute name="minUID" optional="YES" attributeType="Decimal" defaultValueString="0.0" syncable="YES"/>
<attribute name="path" attributeType="String" syncable="YES"/>
<attribute name="pseudonym" attributeType="String" syncable="YES"/>
<attribute name="uidvalidity" optional="YES" attributeType="Decimal" defaultValueString="0.0" syncable="YES"/>
<relationship name="keyRecords" optional="YES" toMany="YES" deletionRule="Nullify" ordered="YES" destinationEntity="KeyRecord" inverseName="folder" inverseEntity="KeyRecord" syncable="YES"/>
<relationship name="mails" optional="YES" toMany="YES" deletionRule="Nullify" ordered="YES" destinationEntity="PersistentMail" inverseName="folder" inverseEntity="PersistentMail" syncable="YES"/>
<relationship name="parent" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Folder" inverseName="subfolder" inverseEntity="Folder" syncable="YES"/>
<relationship name="subfolder" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Folder" inverseName="parent" inverseEntity="Folder" syncable="YES"/>
</entity>
<entity name="KeyRecord" representedClassName="KeyRecord" syncable="YES">
<attribute name="newestDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="nick" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="contact" maxCount="1" deletionRule="Nullify" destinationEntity="EnzevalosContact" inverseName="keyrecords" inverseEntity="EnzevalosContact" syncable="YES"/>
<relationship name="folder" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Folder" inverseName="keyRecords" inverseEntity="Folder" syncable="YES"/>
<relationship name="key" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="record" inverseEntity="PersistentKey" syncable="YES"/>
<relationship name="persistentMails" optional="YES" toMany="YES" deletionRule="Nullify" ordered="YES" destinationEntity="PersistentMail" inverseName="record" inverseEntity="PersistentMail" syncable="YES"/>
</entity>
<entity name="Mail_Address" representedClassName="Mail_Address" syncable="YES">
<attribute name="address" attributeType="String" defaultValueString="&quot;&quot;" syncable="YES"/>
<attribute name="invitations" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="primaryKeyID" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="pseudonym" attributeType="String" syncable="YES"/>
<relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="aliase" inverseEntity="Account" syncable="YES"/>
<relationship name="bcc" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="bcc" inverseEntity="PersistentMail" syncable="YES"/>
<relationship name="cc" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="cc" inverseEntity="PersistentMail" syncable="YES"/>
<relationship name="contact" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="EnzevalosContact" inverseName="addresses" inverseEntity="EnzevalosContact" syncable="YES"/>
<relationship name="from" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="from" inverseEntity="PersistentMail" syncable="YES"/>
<relationship name="keys" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="mailaddress" inverseEntity="PersistentKey" syncable="YES"/>
<relationship name="to" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="to" inverseEntity="PersistentMail" syncable="YES"/>
</entity>
<entity name="PersistentKey" representedClassName="PersistentKey" syncable="YES">
<attribute name="autocryptGossip" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="discoveryDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="encryptionType" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="gossip_timestamp" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="gotFailedCallForUse" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="isMisstrusted" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="isRepealed" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="keyID" attributeType="String" syncable="YES"/>
<attribute name="lastSeen" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="lastSeenAutocrypt" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="origin" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="preferEncryption" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="pseudonym" attributeType="String" syncable="YES"/>
<attribute name="sentOwnPublicKey" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="verifiedDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<relationship name="activeKey" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentKey" syncable="YES"/>
<relationship name="activeRepeal" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentMail" syncable="YES"/>
<relationship name="childKeys" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="parentKey" inverseEntity="PersistentKey" syncable="YES"/>
<relationship name="firstMail" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="attachedKeys" inverseEntity="PersistentMail" syncable="YES"/>
<relationship name="mailaddress" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Mail_Address" inverseName="keys" inverseEntity="Mail_Address" syncable="YES"/>
<relationship name="parentKey" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="childKeys" inverseEntity="PersistentKey" syncable="YES"/>
<relationship name="record" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="KeyRecord" inverseName="key" inverseEntity="KeyRecord" syncable="YES"/>
<relationship name="repealedByMails" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="repealsKey" inverseEntity="PersistentMail" syncable="YES"/>
<relationship name="signedMails" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="signedKey" inverseEntity="PersistentMail" syncable="YES"/>
</entity>
<entity name="PersistentMail" representedClassName="PersistentMail" syncable="YES">
<attribute name="body" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="date" attributeType="Date" defaultDateTimeInterval="-31582140" usesScalarValueType="NO" syncable="YES"/>
<attribute name="decryptedBody" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="decrytionCode" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="deleteWhileTravel" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="encryptedBody" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="flag" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="gmailMessageID" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="gmailThreadID" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="isCorrectlySigned" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="isEncrypted" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="isSigned" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="keyID" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="messageID" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="modSeqValue" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="notLoadedMessageIDs" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="received" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<attribute name="secretKey" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="storeEncrypted" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="subject" attributeType="String" syncable="YES"/>
<attribute name="trouble" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="uid" attributeType="Decimal" defaultValueString="0" syncable="YES"/>
<attribute name="uidvalidity" optional="YES" attributeType="Decimal" defaultValueString="0.0" syncable="YES"/>
<attribute name="unableToDecrypt" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="visibleBody" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="xMailer" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="attachedKeys" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="firstMail" inverseEntity="PersistentKey" syncable="YES"/>
<relationship name="attachments" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Attachment" inverseName="mail" inverseEntity="Attachment" syncable="YES"/>
<relationship name="bcc" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Mail_Address" inverseName="bcc" inverseEntity="Mail_Address" syncable="YES"/>
<relationship name="cc" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Mail_Address" inverseName="cc" inverseEntity="Mail_Address" syncable="YES"/>
<relationship name="decryptedKey" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="SecretKey" inverseName="decryptedMails" inverseEntity="SecretKey" syncable="YES"/>
<relationship name="folder" maxCount="1" deletionRule="Nullify" destinationEntity="Folder" inverseName="mails" inverseEntity="Folder" syncable="YES"/>
<relationship name="from" maxCount="1" deletionRule="Nullify" destinationEntity="Mail_Address" inverseName="from" inverseEntity="Mail_Address" syncable="YES"/>
<relationship name="record" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="KeyRecord" inverseName="persistentMails" inverseEntity="KeyRecord" syncable="YES"/>
<relationship name="referenceMails" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="referenceMails" inverseEntity="PersistentMail" syncable="YES"/>
<relationship name="repealsKey" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="repealedByMails" inverseEntity="PersistentKey" syncable="YES"/>
<relationship name="signedKey" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="PersistentKey" inverseName="signedMails" inverseEntity="PersistentKey" syncable="YES"/>
<relationship name="to" toMany="YES" deletionRule="Nullify" destinationEntity="Mail_Address" inverseName="to" inverseEntity="Mail_Address" syncable="YES"/>
<fetchIndex name="byDateIndex">
<fetchIndexElement property="date" type="Binary" order="ascending"/>
</fetchIndex>
</entity>
<entity name="SecretKey" representedClassName="SecretKey" syncable="YES">
<attribute name="exported" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="importedDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="keyID" attributeType="String" defaultValueString="no" syncable="YES"/>
<attribute name="obsolete" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="origin" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="keys" inverseEntity="Account" syncable="YES"/>
<relationship name="decryptedMails" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PersistentMail" inverseName="decryptedKey" inverseEntity="PersistentMail" syncable="YES"/>
</entity>
<entity name="Server" representedClassName="Server" syncable="YES" codeGenerationType="class">
<attribute name="authType" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="connectionType" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="hostname" attributeType="String" syncable="YES"/>
<attribute name="port" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<relationship name="imap" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="imap" inverseEntity="Account" syncable="YES"/>
<relationship name="smtp" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Account" inverseName="smtp" inverseEntity="Account" syncable="YES"/>
</entity>
<fetchRequest name="allKeyRecords" entity="KeyRecord" predicateString="NOT (FALSEPREDICATE)" returnDistinctResults="YES"/>
<fetchRequest name="getFolder" entity="Folder" predicateString="name == &quot;$folder&quot;"/>
<fetchRequest name="getMailAddress" entity="Mail_Address" predicateString="address == &quot;$adr&quot;"/>
<elements>
<element name="Account" positionX="-315" positionY="-36" width="128" height="255"/>
<element name="Attachment" positionX="-315" positionY="-36" width="128" height="210"/>
<element name="EnzevalosContact" positionX="-209" positionY="198" width="128" height="120"/>
<element name="Folder" positionX="-297" positionY="-18" width="128" height="240"/>
<element name="KeyRecord" positionX="-315" positionY="-36" width="128" height="135"/>
<element name="Mail_Address" positionX="-297" positionY="-18" width="128" height="210"/>
<element name="PersistentKey" positionX="-315" positionY="-36" width="128" height="405"/>
<element name="PersistentMail" positionX="-416" positionY="-189" width="128" height="30"/>
<element name="SecretKey" positionX="-306" positionY="-27" width="128" height="150"/>
<element name="Server" positionX="-306" positionY="-27" width="128" height="135"/>
</elements>
</model>
\ No newline at end of file
...@@ -192,9 +192,7 @@ class IncomingMail { ...@@ -192,9 +192,7 @@ class IncomingMail {
let secretkeys = DataHandler.handler.findSecretKeys() let secretkeys = DataHandler.handler.findSecretKeys()
var decIds = [String]() var decIds = [String]()
for sk in secretkeys { for sk in secretkeys {
if let id = sk.keyID { decIds.append(sk.keyID)
decIds.append(id)
}
} }
return decIds return decIds
} }
...@@ -510,9 +508,7 @@ class IncomingMail { ...@@ -510,9 +508,7 @@ class IncomingMail {
let secretkeys = DataHandler.handler.findSecretKeys() let secretkeys = DataHandler.handler.findSecretKeys()
var decIds = [String]() var decIds = [String]()
for sk in secretkeys { for sk in secretkeys {
if let id = sk.keyID { decIds.append(sk.keyID )
decIds.append(id)
}
} }
return pgp.decrypt(data: data, decKeyIDs: decIds, signatureIDs: keyIds, fromAddr: sender ?? "") return pgp.decrypt(data: data, decKeyIDs: decIds, signatureIDs: keyIds, fromAddr: sender ?? "")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment