exchangeKeys(publicKey:algorithm:parameters:completion:)
Performs a Diffie-Hellman style key exchange operation.
Declaration
func exchangeKeys(publicKey: Data, algorithm: SecKeyAlgorithm, parameters: [AnyHashable : Any], completion handler: @escaping @Sendable (Data?, (any Error)?) -> Void)func exchangeKeys(publicKey: Data, algorithm: SecKeyAlgorithm, parameters: [AnyHashable : Any]) async throws -> DataParameters
- publicKey:
The remote party’s public key.
- algorithm:
An algorithm suitable for performing this key exchange. For example,
ecdhKeyExchangeCofactorX963SHA256. - parameters:
A dictionary with parameters for this key exchange.
- handler:
A completion handler to call when the key exchange operation completes.
- data
The result of the key exchange operation.
- error
An error object that indicates why the key exchange failed, or
nilif the exchange succeeded.
Discussion
The algorithm you use determines the parameters in the dictionary that are required or optional. For more information, see SecKeyKeyExchangeParameter.