SwCrypt
SwCrypt copied to clipboard
What is the type def of generateKey() in DH class?
Hi,
What is the content of NSData that is returned by generateKey() in DH class? How can I convert it (Public Key) to X509 in order to be used by Java consumer?
Best Regards, P
Would like to see answer for this too.
Hope is not too late to reply, as the documentation says at https://opensource.apple.com/source/CommonCrypto/CommonCrypto-60027/Source/CommonCryptoSPI/CommonDH.h
It returns a byte string
/*!
@function CCDHGenerateKey
@abstract Generate the public key for use in a Diffie-Hellman handshake.
This value is returned as a byte string.
@param ref The Diffie-Hellman context.
@result returns -1 on failure.
*/
It's an Octet String as defined in PKCS#3.
https://github.com/st3fan/osx-10.9/blob/master/CommonCrypto-60049/lib/CommonDH.c#L124 https://github.com/samdmarshall/apple-corecrypto/blob/df1ffe4ae19dcb7c320d336d7f5f28c9af6daa09/ccdh/corecrypto/ccdh.h#L331
Maybe the java's X509EncodedKeySpec can use it.