问题
I am looking for the methods in CommonCrypto to generate the shared secret based on ECDH (Elliptic curve Diffie–Hellman). I can find proprietary implementations like this one https://github.com/surespot/surespot-ios/blob/master/surespot/encryption/EncryptionController.mm but this one is not using CommonCrypto. The method to calculate the shared secret is called sometimes Key Exchange and includes the calculation of the shared secret. Can someone send a link to the right documentation or to an example that uses CommonCrypto for generating the shared secret based on Elliptic curve Diffie–Hellman?
回答1:
Look at CommonCrypto function from CommonECCryptor.h
CCECCryptorComputeSharedSecret( CCECCryptorRef privateKey, CCECCryptorRef publicKey, void *out, size_t *outLen)
It constructs a Diffie-Hellman shared secret with a private and public ECC key. Most information they provide are in the header file's commence lines. Header of CCECCryptorComputeSharedSecret is here
来源:https://stackoverflow.com/questions/26750532/shared-secret-based-on-elliptic-curve-diffie-hellman-with-commoncrypto