-
-
Save cardoso/c9e381b78671263cfc2e65d568f77bdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import CryptoKit | |
func deriveSymmetricKey(privateKey: P256.KeyAgreement.PrivateKey, publicKey: P256.KeyAgreement.PublicKey) throws -> SymmetricKey { | |
let sharedSecret = try privateKey.sharedSecretFromKeyAgreement(with: publicKey) | |
let symmetricKey = sharedSecret.hkdfDerivedSymmetricKey( | |
using: SHA256.self, | |
salt: "My Key Agreement Salt".data(using: .utf8)!, | |
sharedInfo: Data(), | |
outputByteCount: 32 | |
) | |
return symmetricKey | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment