SwiftyRSA
SwiftyRSA copied to clipboard
XCode 9.0 failed to create public key
Public key from data fails, even though data is valid. worked before the update of xcode. Error comes from SecKeyCreateWithData(keyData as CFData, keyDict as CFDictionary, nil)
in addKey
function. Tested independently trying to create key with same CommonCrypto function and the status is OSStatus -50 (wrong secParam). This is after the update, again
@rredpoppy can you provide examples of keys that don't create properly?
@ldiqual device: ipad air system: iOS9.2 use SwiftRSA like this
func encryptWithRSAPublicKey(string: String) -> String? {
do {
let publicKey = try PublicKey(base64Encoded: string)
let clear = try ClearMessage(string: self, using: .utf8)
return try clear.encrypted(with: publicKey, padding: .PKCS1).base64String
} catch {
debugPrint("\(error)")
return nil
}
}
when i use "Of123456' as the encrypt string ,the first time encrypt is ok , then encrypt again. catch error as follow "SwiftyRSAError(message: "Provided key couldn\'t be added to the keychain")"
@CoderSQ sorry about the delay on this. We now expose SwiftyRSAError
as an enum which allows you to know the specific reason for why something went wrong. Would use mind using the latest version (1.3.1) and let me know what's the error? Thanks! https://github.com/TakeScoop/SwiftyRSA/blob/master/SwiftyRSA/SwiftyRSAError.swift#L13-L33
I guess this is actually the same issue that we reported in https://github.com/TakeScoop/SwiftyRSA/issues/107 and we created a fix there also.