How to sign/verify using SecKeyRawSign with elliptic curve key

Viewed 2757

I generated an elliptic curve private/public key pair on iOS, and store them to keychain inside secure enclave.

I want to sign/verify a message with those keys.

So, here is my code to sign a message using SecKeyCreateSignature.

var error: Unmanaged<CFError>?
let signature = SecKeyCreateSignature(myPrivateKey,
                                      .ecdsaSignatureMessageX962SHA512,
                                      plainData as CFData,
                                      &error)

It works well, but SecKeyCreateSignature is only available in iOS 10.

I would like to maintain compatibility with iOS 9 at least. So I searched the alternative way to sign a message, and I found SecKeyRawSign that look similar to the function above.

However SecKeyRawSign doesn't look like to support elliptic curve key.

How can I use SecKeyRawSign or alternative ways to sign/verify a message that is equivalent or similar to the code above?

1 Answers
Related