Type Alias


A customized callback function that keychain services call when a keychain event has occurred.




The keychain event that occurred. The type of event that can trigger your callback depends on the bit mask you passed in the eventMask parameter of the function SecKeychainAddCallback(_:_:_:). See SecKeychainEvent for a list of possible values.


A pointer to a structure of type SecKeychainCallbackInfo. This structure provides your callback with information about the keychain event.


A pointer to application-defined storage that your application previously passed to the function SecKeychainAddCallback(_:_:_:). You can use this value to provide information that the callback function needs in order to properly handle the event, such as an object on which the callback function should call a method.

Return Value

A result code. See Codes.


You would declare your keychain callback function like this if you were to name it MyKeychainCallback:

Listing 1

Declaring a keychain callback function

OSStatus MyKeychainCallback (
    SecKeychainEvent keychainEvent,
    SecKeychainCallbackInfo *info,
    void *context

To add your callback function, use the SecKeychainAddCallback(_:_:_:) function. To remove your callback function, use the SecKeychainRemoveCallback(_:) function.

See Also


func SecKeychainRemoveCallback(SecKeychainCallback) -> OSStatus

Unregisters your keychain event callback function.

struct SecKeychainCallbackInfo

Information about a keychain event that keychain services deliver to your app via a callback function.

enum SecKeychainEvent

The list of keychain events that can trigger a callback.

struct SecKeychainEventMask

Bit masks corresponding to the events that can trigger a keychain callback.