diff --git a/enzevalos_iphone/SMIME.swift b/enzevalos_iphone/SMIME.swift index 5efd9e2d0a2c8cab4550406c67368014694607e6..6290636e22dd4973b59b953e39268afa6f544b32 100644 --- a/enzevalos_iphone/SMIME.swift +++ b/enzevalos_iphone/SMIME.swift @@ -711,12 +711,13 @@ PkfA6mR7rtcyIbHi34tfkCv/qolV3QivMHov0IJpRyNO let verifyCryptoObj = verify(data: outputData, email: fromAddr, isMailNew: isMailNew) + let signKey = verifyCryptoObj.signKey let sigState = verifyCryptoObj.signatureState let addresses = verifyCryptoObj.signedAdrs let plainText = verifyCryptoObj.plaintext let decryptedData = plainText!.data(using: .utf8)! - return CryptoObject(chiphertext: data, plaintext: plainText, decryptedData: decryptedData, sigState: sigState, encState: encState, signKey: fp, encType: CryptoScheme.SMIME, signedAdrs: sigState == SignatureState.ValidSignature ? addresses : []) + return CryptoObject(chiphertext: data, plaintext: plainText, decryptedData: decryptedData, sigState: sigState, encState: encState, signKey: signKey, encType: CryptoScheme.SMIME, signedAdrs: sigState == SignatureState.ValidSignature ? addresses : []) } func sign(plainData: Data, myEmail: String, detached: Bool = true) throws -> CryptoObject { @@ -811,7 +812,13 @@ PkfA6mR7rtcyIbHi34tfkCv/qolV3QivMHov0IJpRyNO return pem })) - return CryptoObject(chiphertext: data, plaintext: verStr!, decryptedData: nil, sigState: sigState, encState: EncryptionState.NoEncryption, signKey: nil, encType: .SMIME, signedAdrs: signedAddresses) + let signKeyFps = certsFPArr!.map( { (arg) -> String in + let (fp, _) = arg + return fp + }) + + // TODO: set signKey to the entire array after CryptoObject has been modified to use multiple keys + return CryptoObject(chiphertext: data, plaintext: verStr!, decryptedData: nil, sigState: sigState, encState: EncryptionState.NoEncryption, signKey: signKeyFps[0], encType: .SMIME, signedAdrs: signedAddresses) } func encrypt(plainData: Data, ids: [String], ownId: String, encryptForMyId: Bool = true) throws -> CryptoObject {