Function

SecKeychainItemModifyAttributesAndData

Updates an existing keychain item after changing its attributes or data.

Declaration

OSStatus SecKeychainItemModifyAttributesAndData(SecKeychainItemRef itemRef, const SecKeychainAttributeList *attrList, UInt32 length, const void *data);

Parameters

itemRef

A reference to the keychain item to modify.

attrList

A pointer to the list of attributes to modify and their new values. Pass NULL if you have no need to modify attributes.

length

The length of the buffer pointed to by the data parameter. Pass 0 if you pass NULL in the data parameter.

data

A pointer to a buffer containing the data to store. Pass NULL if you do not need to modify the data.

Return Value

Discussion

The keychain item is written to the keychain’s permanent data store. If the keychain item has not previously been added to a keychain, a call to this function does nothing and returns noErr.

Note that when you use this function to modify a keychain item, Keychain Services updates the modification date of the item. Therefore, you cannot use this function to modify the modification date, as the value you specify will be overwritten with the current time. If you want to change the modification date to something other than the current time, use a CSSM function to do so.

You should pair the SecKeychainItemCopyAttributesAndData function with the SecKeychainItemModifyAttributesAndData function, as these functions handle more attributes than are support by the old Keychain Manager and passing them into older calls yields an invalid attribute error. Use the functions SecKeychainItemModifyContent and SecKeychainItemCopyContent when dealing with older Keychain Manager functions.

See Also

Legacy Keychain Item Management

SecKeychainItemCopyAttributesAndData

Retrieves the data and/or attributes stored in the given keychain item.

SecKeychainItemFreeAttributesAndData

Releases the memory used by the keychain attribute list and/or the keychain data retrieved in a call to SecKeychainItemCopyAttributesAndData.

SecKeychainItemCopyContent

Copies the data and attributes stored in the given keychain item.

SecKeychainItemModifyContent

Updates an existing keychain item after changing its attributes and/or data.

SecKeychainItemFreeContent

Releases the memory used by the keychain attribute list and the keychain data retrieved in a call to the SecKeychainItemCopyContent function.

SecKeychainItemCopyKeychain

Returns the keychain object of a given keychain item.

SecKeychainItemDelete

Deletes a keychain item from the default keychain’s permanent data store.

SecKeychainAttrType

The keychain attribute type.

SecKeychainAttribute

A structure that holds a single keychain attribute.

SecKeychainAttributePtr

A pointer to a keychain attribute structure.

SecKeychainAttributeList

A list of keychain attributes.