我从给定的证书中获得了一个SecKey。根据证书的不同,SecKey可以使用RSA或EllipticCurve加密。
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!)
}
一旦我打印了publicKey,它就会给我: SecKeyRef算法ID:1,密钥类型:RSAPublicKey,版本:4,块大小:2048位,指数:{hex:10001,十进制:65537},模数:,addr:0x7f7fba5arerw34,其中特别说明了其类型为RSAPublicKey。 / p>
有没有办法获取所使用的加密类型?