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?
Shared Secret based on Elliptic curve Diffie–Hellman with CommonCrypto
Asked Answered
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
#import ? My answer's URL links to C/C++ header. C includes headers with #include. –
Narcis
I'm not so modern as you:) I use old C. The test that in particular invokes this function is here –
Narcis
The issue is iOS that can only use public APIs. –
Timtima
The author of question was looking for the methods in CommonCrypto to generate the shared secret based on ECDH. I pointed to the function. The question does not contain any restrictions (App store, language, etc.). Author should decide if his environment allows such method. –
Narcis
The question is tagged "ios", that would be considered a restriction. –
Timtima
Zaph, I have no iOS now to test, author didn't share his results. So if you have no updates I will delete my answer. Please let me know. –
Narcis
I think you should look to
SecKeyCopyKeyExchangeResult
for a modern and secure approach and also Apple reccomendation –
Ginetteginevra Is there an example code of how to use CCECCryptorComputeSharedSecret in swift ? with private and public EC keys ? –
Patrimony
© 2022 - 2024 — McMap. All rights reserved.
#import <CommonCrypto/CommonECCryptor.h>
does not work. Is this in the Security Framework? Is it a public API? – Timtima