Skip to content
Snippets Groups Projects
Commit e089640f authored by lazarog98's avatar lazarog98
Browse files

#232 add exceptions to sign and finalize decrypt

parent 7a3ced48
No related branches found
No related tags found
2 merge requests!58Onboarding screens swift ui merge dev,!35Resolve "SMIME Support"
......@@ -709,14 +709,14 @@ PkfA6mR7rtcyIbHi34tfkCv/qolV3QivMHov0IJpRyNO
throw SMIMEError(message: "Decryption failed!", errorArray: errArr, type: SMIMEError.ErrorType.decryption)
}
let (sigState, certsWithFps, sigStr) = verify(data: outputData, email: fromAddr, isMailNew: isMailNew)
let verifyCryptoObj = verify(data: outputData, email: fromAddr, isMailNew: isMailNew)
let addresses = getAllEmailsFromPEMs(certs: certsWithFps.map( { (arg) -> String in
let (_, pem) = arg
return pem
}))
let sigState = verifyCryptoObj.signatureState
let addresses = verifyCryptoObj.signedAdrs
let plainText = verifyCryptoObj.plaintext
let decryptedData = plainText!.data(using: .utf8)!
return CryptoObject(chiphertext: data, plaintext: String(data: outputData, encoding: .utf8), decryptedData: outputData, 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: fp, encType: CryptoScheme.SMIME, signedAdrs: sigState == SignatureState.ValidSignature ? addresses : [])
}
func sign(plainData: Data, myEmail: String, detached: Bool = true) throws -> CryptoObject {
......@@ -728,7 +728,9 @@ PkfA6mR7rtcyIbHi34tfkCv/qolV3QivMHov0IJpRyNO
let (sigText, errArr) = signWithPem(message: text!, certAsPem: cert, keyAsPem: key, detached: detached)
// TODO: Exception
if (errArr != nil && errArr!.count > 0) {
throw SMIMEError(message: "Signing failed!", errorArray: errArr, type: SMIMEError.ErrorType.signing)
}
return CryptoObject(chiphertext: sigText!.data(using: .utf8), plaintext: text, decryptedData: plainData, sigState: SignatureState.ValidSignature, encState: EncryptionState.NoEncryption, signKey: fp, encType: CryptoScheme.SMIME, signedAdrs: [myEmail])
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment