Item Class Keys and Values

Specify the class of a keychain item.

Overview

Keychain items come in a variety of classes according to the kind of data they hold, such as passwords, cryptographic keys, and certificates. The item's class dictates which attributes apply and enables the system to decide whether or not the data should be encrypted on disk. For example, passwords obviously require encryption, but certificates don't because they are not secret.

Use the key and one of the corresponding values listed here to specify the class for a new item you create with a call to the SecItemAdd(_:_:) function by placing the key/value pair in the attributes dictionary.

Later, use this same pair in the query dictionary when searching for an item with one of the SecItemCopyMatching(_:_:), SecItemUpdate(_:_:), or SecItemDelete(_:) functions.

Topics

Item Class Keys

let kSecClass: CFString

A dictionary key whose value is the item's class.

Item Class Values

Values you use with the kSecClass key.

let kSecClassGenericPassword: CFString

The value that indicates a generic password item.

let kSecClassInternetPassword: CFString

The value that indicates an Internet password item.

let kSecClassCertificate: CFString

The value that indicates a certificate item.

let kSecClassKey: CFString

The value that indicates a cryptographic key item.

let kSecClassIdentity: CFString

The value that indicates an identity item.

See Also

Adding Keychain Items

Adding a Password to the Keychain

Add network credentials to the keychain on behalf of the user.

Item Attribute Keys and Values

Specify the attributes of keychain items.