2

I get a SecKey from given certificates. Depending on the certificate, the SecKey can use either RSA or EllipticCurve encryption.

    let certificate = SecCertificateCreateWithData(kCFAllocatorDefault, certificateData) 
    let certArray = [ certificate ]
    let policy = SecPolicyCreateBasicX509()

    var optionalTrust: SecTrust?
    let status = SecTrustCreateWithCertificates(certArray as AnyObject, policy, &optionalTrust)

    if status == errSecSuccess {
        let publicKey = SecTrustCopyPublicKey(optionalTrust!)
        print(publicKey!)
    }

Once I print the publicKey it gives me: SecKeyRef algorithm id: 1, key type: RSAPublicKey, version: 4, block size: 2048 bits, exponent: {hex: 10001, decimal: 65537}, modulus: , addr: 0x7f7fba5arerw34 , where it specifically says its of type RSAPublicKey.

Is there a way to get the type of encryption used?

0 Answers0