One Logo Pool Ball
CryptoKit · IOS API REFERENCE

SharedSecret

struct · iOS 13.0+ · SDK 27.1

struct SharedSecret

A key agreement result from which you can derive a symmetric cryptographic key. Generate a shared secret by calling your private key’s `sharedSecretFromKeyAgreement(publicKeyShare:)` method with the public key from another party. The other party computes the same secret by passing your public key to the the equivalent method on their own private key. 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``.

Members (2)

get · iOS 13.0+

description

TypeScript
get description(): string
Swift declaration
var description: String { get }

A textual representation of this instance. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(describing:)` initializer. This initializer works with any type, and uses the custom `description` property for types that conform to `CustomStringConvertible`: struct Point: CustomStringConvertible { let x: Int, y: Int var description: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(describing: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `description` property.

method · iOS 13.0+

withUnsafeBytes

TypeScript
withUnsafeBytes(body: ((arg0: ArrayBuffer) => unknown)): unknown
Swift declaration
func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R

Calls the given closure with the contents of underlying storage. - note: Calling `withUnsafeBytes` multiple times does not guarantee that the same buffer pointer will be passed in every time. - warning: The buffer argument to the body should not be stored or used outside of the lifetime of the call to the closure. Clients should prefer the `withBytes` function to this one, because `withBytes` uses the non-escapable type `RawSpan` to ensure that the buffer argument is not stored outside of the closure.

Skipped declarations

2 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

SharedSecret.x963DerivedSymmetricKey(using:sharedInfo:outputByteCount:)

Passing a Swift type itself is not supported.

SharedSecret.hkdfDerivedSymmetricKey(using:salt:sharedInfo:outputByteCount:)

Passing a Swift type itself is not supported.

All CryptoKit types →