I am reading this Apple documentation and trying to apply it:
https://developer.apple.com/documentation/cryptokit/sharedsecret
It says:
The shared secret isn’t suitable as a symmetric cryptographic key (SymmetricKey) by itself. However, you use it to generate a key by calling either the hkdfDerivedSymmetricKey(using:salt:sharedInfo:outputByteCount:) or x963DerivedSymmetricKey(using:sharedInfo:outputByteCount:) method of the shared secret. After the other party does the same, then you both share a symmetric key suitable for creating a message authentication code like HMAC, or for opening and closing a sealed box with a cipher like ChaChaPoly or AES.
When I click on the link for x963DerivedSymmetricKey(using:sharedInfo:outputByteCount:):
It says:
sharedInfo: The shared information to use for key derivation.
outputByteCount: The length in bytes of resulting symmetric key.
I am confused about these 2 parameters. What exactly is supposed to be passed for sharedInfo and outputByteCount?
The only example I could find is here:
https://gist.github.com/mehmeteminkartal/e2d1ee56526dc032b7257aef80c40d16
But I think this example might be incorrect as it passes bobPublicKey.rawRepresentation for sharedInfo for both alice_key and bobs_key. Also not sure why it passes 16 for outputByteCount.
Can someone explain these?