]>
Commit | Line | Data |
---|---|---|
b1ab9ed8 | 1 | /* |
d8f41ccd | 2 | * Copyright (c) 2006,2011,2014 Apple Inc. All Rights Reserved. |
b54c578e | 3 | * |
b1ab9ed8 | 4 | * @APPLE_LICENSE_HEADER_START@ |
b54c578e | 5 | * |
b1ab9ed8 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
b54c578e | 12 | * |
b1ab9ed8 A |
13 | * The Original Code and all software distributed under the License are |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
b54c578e | 20 | * |
b1ab9ed8 A |
21 | * @APPLE_LICENSE_HEADER_END@ |
22 | */ | |
23 | ||
24 | /* | |
25 | * SecKeychainItemExtendedAttributes.h | |
26 | * Created 9/6/06 by dmitch | |
27 | */ | |
b54c578e | 28 | |
b1ab9ed8 A |
29 | #ifndef _SEC_KEYCHAIN_ITEM_EXTENDED_ATTRIBUTES_H_ |
30 | #define _SEC_KEYCHAIN_ITEM_EXTENDED_ATTRIBUTES_H_ | |
31 | ||
32 | #include <Security/SecBase.h> | |
33 | #include <Security/cssmapple.h> | |
34 | #include <CoreFoundation/CFArray.h> | |
35 | #include <CoreFoundation/CFData.h> | |
36 | ||
37 | #if defined(__cplusplus) | |
38 | extern "C" { | |
39 | #endif | |
40 | ||
b54c578e | 41 | /* |
b1ab9ed8 A |
42 | * Extended attributes extend the fixed set of keychain item attribute in a generally |
43 | * extensible way. A given SecKeychainItemRef can have assigned to it any number | |
44 | * of extended attributes, each consisting of an attribute name (as a CFStringRef) | |
b54c578e | 45 | * and an attribute value (as a CFDataRef). |
b1ab9ed8 | 46 | * |
b54c578e A |
47 | * Each extended attribute is a distinct record residing in the same keychain as |
48 | * the item to which it refers. In a given keychain, the set of the following properties | |
b1ab9ed8 A |
49 | * of an extended attribute record must be unique: |
50 | * | |
51 | * -- the type of item to which the extended attribute is bound (kSecPublicKeyItemClass, | |
52 | * kSecPrivateKeyItemClass, etc.) | |
53 | * -- an identifier which uniquely identifies the item to which the extended attribute | |
b54c578e | 54 | * is bound. Currently this is the PrimaryKey blob. |
b1ab9ed8 | 55 | * -- the extended attribute's Attribute Name, specified in this interface as a |
b54c578e | 56 | * CFString. |
b1ab9ed8 | 57 | * |
b54c578e | 58 | * Thus, e.g., a given item can have at most one extended attribute with |
b1ab9ed8 A |
59 | * Attribute Name of CFSTR("SomeAttributeName"). |
60 | */ | |
b54c578e A |
61 | |
62 | /* | |
b1ab9ed8 A |
63 | * SecKeychainItemSetExtendedAttribute() - set an extended attribute by name and value. |
64 | * | |
b54c578e | 65 | * If the extended attribute specified by 'attrName' does not exist, one will be |
b1ab9ed8 A |
66 | * created with the value specified in 'attrValue'. |
67 | * | |
68 | * If the extended attribute specified by 'attrName already exists, its value will be | |
69 | * replaced by the value specified in 'attrValue'. | |
b54c578e A |
70 | * |
71 | * If the incoming 'attrValue' is NULL, the extended attribute specified by 'attrName' | |
72 | * will be deleted if it exists. If the incoming 'attrValue' is NULL and no such | |
73 | * attribute exists, the function will return errSecNoSuchAttr. | |
b1ab9ed8 A |
74 | */ |
75 | OSStatus SecKeychainItemSetExtendedAttribute( | |
76 | SecKeychainItemRef itemRef, | |
b54c578e | 77 | CFStringRef attrName, /* identifies the attribute */ |
79b9da22 | 78 | CFDataRef attrValue) /* value to set; NULL means delete the |
b1ab9ed8 | 79 | * attribute */ |
d64be36e | 80 | API_UNAVAILABLE(ios, watchos, tvos, bridgeos, macCatalyst); |
b54c578e A |
81 | |
82 | /* | |
83 | * SecKeychainItemCopyExtendedAttribute() - Obtain the value of an an extended attribute. | |
84 | * | |
b1ab9ed8 A |
85 | * If the extended attribute specified by 'attrName' exists, its value will be returned |
86 | * via the *attrValue argument. The caller must CFRelease() this returned value. | |
87 | * | |
88 | * If the extended attribute specified by 'attrName' does not exist, the function | |
89 | * will return errSecNoSuchAttr. | |
90 | */ | |
91 | OSStatus SecKeychainItemCopyExtendedAttribute( | |
92 | SecKeychainItemRef itemRef, | |
93 | CFStringRef attrName, | |
d64be36e | 94 | CFDataRef *attrValue) API_UNAVAILABLE(ios, watchos, tvos, bridgeos, macCatalyst); /* RETURNED */ |
b54c578e | 95 | |
b1ab9ed8 | 96 | /* |
b54c578e | 97 | * SecKeychainItemCopyAllExtendedAttributes() - obtain all of an item's extended attributes. |
b1ab9ed8 A |
98 | * |
99 | * This is used to determine all of the extended attributes associated with a given | |
100 | * SecKeychainItemRef. The Atrribute Names of all of the extended attributes are | |
101 | * returned in the *attrNames argument; on successful return this contains a | |
102 | * CFArray whose elements are CFStringRefs, each of which is an Attribute Name. | |
b54c578e | 103 | * The caller must CFRelease() this array. |
b1ab9ed8 | 104 | * |
b54c578e A |
105 | * Optionally, the Attribute Values of all of the extended attributes is returned |
106 | * in the *attrValues argument; on successful return this contains a CFArray whose | |
107 | * elements are CFDataRefs, each of which is an Attribute Value. The positions of | |
108 | * the elements in this array correspond with the elements in *attrNames; i.e., | |
109 | * the n'th element in *attrName is the Attribute Name corresponding to the | |
110 | * Attribute Value found in the n'th element of *attrValues. | |
b1ab9ed8 A |
111 | * |
112 | * Pass in NULL for attrValues if you don't need the Attribute Values. Caller | |
b54c578e | 113 | * must CFRelease the array returned via this argument. |
b1ab9ed8 A |
114 | * |
115 | * If the item has no extended attributes, this function returns errSecNoSuchAttr. | |
116 | */ | |
117 | OSStatus SecKeychainItemCopyAllExtendedAttributes( | |
118 | SecKeychainItemRef itemRef, | |
119 | CFArrayRef *attrNames, /* RETURNED, each element is a CFStringRef */ | |
79b9da22 | 120 | CFArrayRef *attrValues) /* optional, RETURNED, each element is a |
b1ab9ed8 | 121 | * CFDataRef */ |
d64be36e | 122 | API_UNAVAILABLE(ios, watchos, tvos, bridgeos, macCatalyst); |
b1ab9ed8 A |
123 | #if defined(__cplusplus) |
124 | } | |
125 | #endif | |
126 | ||
127 | #endif /* _SEC_KEYCHAIN_ITEM_EXTENDED_ATTRIBUTES_H_ */ | |
128 |