SwiftyRSA icon indicating copy to clipboard operation
SwiftyRSA copied to clipboard

XCode 9.0 failed to create public key

Open rredpoppy opened this issue 7 years ago • 4 comments

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 avatar Sep 22 '17 16:09 rredpoppy

@rredpoppy can you provide examples of keys that don't create properly?

ldiqual avatar Sep 27 '17 03:09 ldiqual

@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 avatar Oct 17 '17 03:10 CoderSQ

@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

ldiqual avatar Mar 07 '18 01:03 ldiqual

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.

rgjurgens avatar Mar 20 '18 08:03 rgjurgens