(Working on macOS and targetting macOS 10.11)
I'm having trouble getting my head around decoding a given 'secret message' using a given Public Key.
The 'secret message' is obtained from a device SDK call.
The public key is given to me by the device manufacturer.
The encyptedAPIToken is also gained from a SDK call to the device.
The idea is to decode the secret using the public key. This yields a value which is then used to decode another secret using SHA-256, the final result is used as a token in HTTP GET and PUT headers to the device.
The instructions from the device manufacturer are as shown in this picture.
Since I can't embed images in this post, incase you can't see that, it says :
1. Get the Public Key from the manufacturer.
2. Decrpyt secret message with public key using RSA algorithm.
3. Decrpyt encryptedAPIToken using SHA-256 algorithm using value gained in step 2.
So that all seems pretty reasonable.
Except I am having real trouble finding a way to decrpyt the secret message with the given public key.
All the Objective-C/Swift examples I can find are for iOS which uses SecKeyRef - which is not availble on macOS.
I found "Quin The Eskimo"'s CryptoCompatibility sample code from a few years back, but when I run it, like this:
./CryptoCompatibility rsa-small-decrypt public.pem sig
Where "public.pem" is my public key, and sig is the secret in a text file, I get this error:
CryptoCompatibility: error: NSOSStatusErrorDomain / -25256
I am struggling to find examples of how to decrpyt a message using an RSA Public key for Objective-C or Swift, on macOS.