1 {
2      File:       SecurityHI/KeychainHI.h
3 
4      Contains:   Keychain API's with Human Interfaces
5 
6      Version:    SecurityHI-55002~751
7 
8      Copyright:  � 2000-2008 by Apple Inc., all rights reserved
9 
10      Bugs?:      For bug reports, consult the following page on
11                  the World Wide Web:
12 
13                      http://bugs.freepascal.org
14 
15 }
16 {  Pascal Translation Updated:  Jonas Maebe, <jonas@freepascal.org>, October 2009 }
17 {  Pascal Translation Updated:  Jonas Maebe, <jonas@freepascal.org>, October 2012 }
18 {
19     Modified for use with Free Pascal
20     Version 308
21     Please report any bugs to <gpc@microbizz.nl>
22 }
23 
24 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
25 {$mode macpas}
26 {$modeswitch cblocks}
27 {$packenum 1}
28 {$macro on}
29 {$inline on}
30 {$calling mwpascal}
31 
32 unit KeychainHI;
33 interface
34 {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
35 {$setc GAP_INTERFACES_VERSION := $0308}
36 
37 {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
38     {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
39 {$endc}
40 
41 {$ifc defined CPUPOWERPC and defined CPUI386}
42 	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
43 {$endc}
44 {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
45 	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
46 {$endc}
47 
48 {$ifc not defined __ppc__ and defined CPUPOWERPC32}
49 	{$setc __ppc__ := 1}
50 {$elsec}
51 	{$setc __ppc__ := 0}
52 {$endc}
53 {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
54 	{$setc __ppc64__ := 1}
55 {$elsec}
56 	{$setc __ppc64__ := 0}
57 {$endc}
58 {$ifc not defined __i386__ and defined CPUI386}
59 	{$setc __i386__ := 1}
60 {$elsec}
61 	{$setc __i386__ := 0}
62 {$endc}
63 {$ifc not defined __x86_64__ and defined CPUX86_64}
64 	{$setc __x86_64__ := 1}
65 {$elsec}
66 	{$setc __x86_64__ := 0}
67 {$endc}
68 {$ifc not defined __arm__ and defined CPUARM}
69 	{$setc __arm__ := 1}
70 {$elsec}
71 	{$setc __arm__ := 0}
72 {$endc}
73 {$ifc not defined __arm64__ and defined CPUAARCH64}
74   {$setc __arm64__ := 1}
75 {$elsec}
76   {$setc __arm64__ := 0}
77 {$endc}
78 
79 {$ifc defined cpu64}
80   {$setc __LP64__ := 1}
81 {$elsec}
82   {$setc __LP64__ := 0}
83 {$endc}
84 
85 
86 {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
87 	{$error Conflicting definitions for __ppc__ and __i386__}
88 {$endc}
89 
90 {$ifc defined __ppc__ and __ppc__}
91 	{$setc TARGET_CPU_PPC := TRUE}
92 	{$setc TARGET_CPU_PPC64 := FALSE}
93 	{$setc TARGET_CPU_X86 := FALSE}
94 	{$setc TARGET_CPU_X86_64 := FALSE}
95 	{$setc TARGET_CPU_ARM := FALSE}
96 	{$setc TARGET_CPU_ARM64 := FALSE}
97 	{$setc TARGET_OS_MAC := TRUE}
98 	{$setc TARGET_OS_IPHONE := FALSE}
99 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
100 	{$setc TARGET_OS_EMBEDDED := FALSE}
101 {$elifc defined __ppc64__ and __ppc64__}
102 	{$setc TARGET_CPU_PPC := FALSE}
103 	{$setc TARGET_CPU_PPC64 := TRUE}
104 	{$setc TARGET_CPU_X86 := FALSE}
105 	{$setc TARGET_CPU_X86_64 := FALSE}
106 	{$setc TARGET_CPU_ARM := FALSE}
107 	{$setc TARGET_CPU_ARM64 := FALSE}
108 	{$setc TARGET_OS_MAC := TRUE}
109 	{$setc TARGET_OS_IPHONE := FALSE}
110 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
111 	{$setc TARGET_OS_EMBEDDED := FALSE}
112 {$elifc defined __i386__ and __i386__}
113 	{$setc TARGET_CPU_PPC := FALSE}
114 	{$setc TARGET_CPU_PPC64 := FALSE}
115 	{$setc TARGET_CPU_X86 := TRUE}
116 	{$setc TARGET_CPU_X86_64 := FALSE}
117 	{$setc TARGET_CPU_ARM := FALSE}
118 	{$setc TARGET_CPU_ARM64 := FALSE}
119 {$ifc defined iphonesim}
120  	{$setc TARGET_OS_MAC := FALSE}
121 	{$setc TARGET_OS_IPHONE := TRUE}
122 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
123 {$elsec}
124 	{$setc TARGET_OS_MAC := TRUE}
125 	{$setc TARGET_OS_IPHONE := FALSE}
126 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
127 {$endc}
128 	{$setc TARGET_OS_EMBEDDED := FALSE}
129 {$elifc defined __x86_64__ and __x86_64__}
130 	{$setc TARGET_CPU_PPC := FALSE}
131 	{$setc TARGET_CPU_PPC64 := FALSE}
132 	{$setc TARGET_CPU_X86 := FALSE}
133 	{$setc TARGET_CPU_X86_64 := TRUE}
134 	{$setc TARGET_CPU_ARM := FALSE}
135 	{$setc TARGET_CPU_ARM64 := FALSE}
136 {$ifc defined iphonesim}
137  	{$setc TARGET_OS_MAC := FALSE}
138 	{$setc TARGET_OS_IPHONE := TRUE}
139 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
140 {$elsec}
141 	{$setc TARGET_OS_MAC := TRUE}
142 	{$setc TARGET_OS_IPHONE := FALSE}
143 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
144 {$endc}
145 	{$setc TARGET_OS_EMBEDDED := FALSE}
146 {$elifc defined __arm__ and __arm__}
147 	{$setc TARGET_CPU_PPC := FALSE}
148 	{$setc TARGET_CPU_PPC64 := FALSE}
149 	{$setc TARGET_CPU_X86 := FALSE}
150 	{$setc TARGET_CPU_X86_64 := FALSE}
151 	{$setc TARGET_CPU_ARM := TRUE}
152 	{$setc TARGET_CPU_ARM64 := FALSE}
153 	{$setc TARGET_OS_MAC := FALSE}
154 	{$setc TARGET_OS_IPHONE := TRUE}
155 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
156 	{$setc TARGET_OS_EMBEDDED := TRUE}
157 {$elifc defined __arm64__ and __arm64__}
158 	{$setc TARGET_CPU_PPC := FALSE}
159 	{$setc TARGET_CPU_PPC64 := FALSE}
160 	{$setc TARGET_CPU_X86 := FALSE}
161 	{$setc TARGET_CPU_X86_64 := FALSE}
162 	{$setc TARGET_CPU_ARM := FALSE}
163 	{$setc TARGET_CPU_ARM64 := TRUE}
164 {$ifc defined ios}
165 	{$setc TARGET_OS_MAC := FALSE}
166 	{$setc TARGET_OS_IPHONE := TRUE}
167 	{$setc TARGET_OS_EMBEDDED := TRUE}
168 {$elsec}
169 	{$setc TARGET_OS_MAC := TRUE}
170 	{$setc TARGET_OS_IPHONE := FALSE}
171 	{$setc TARGET_OS_EMBEDDED := FALSE}
172 {$endc}
173 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
174 {$elsec}
175 	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
176 {$endc}
177 
178 {$ifc defined __LP64__ and __LP64__ }
179   {$setc TARGET_CPU_64 := TRUE}
180 {$elsec}
181   {$setc TARGET_CPU_64 := FALSE}
182 {$endc}
183 
184 {$ifc defined FPC_BIG_ENDIAN}
185 	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
186 	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
187 {$elifc defined FPC_LITTLE_ENDIAN}
188 	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
189 	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
190 {$elsec}
191 	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
192 {$endc}
193 {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
194 {$setc CALL_NOT_IN_CARBON := FALSE}
195 {$setc OLDROUTINENAMES := FALSE}
196 {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
197 {$setc OPAQUE_UPP_TYPES := TRUE}
198 {$setc OTCARBONAPPLICATION := TRUE}
199 {$setc OTKERNEL := FALSE}
200 {$setc PM_USE_SESSION_APIS := TRUE}
201 {$setc TARGET_API_MAC_CARBON := TRUE}
202 {$setc TARGET_API_MAC_OS8 := FALSE}
203 {$setc TARGET_API_MAC_OSX := TRUE}
204 {$setc TARGET_CARBON := TRUE}
205 {$setc TARGET_CPU_68K := FALSE}
206 {$setc TARGET_CPU_MIPS := FALSE}
207 {$setc TARGET_CPU_SPARC := FALSE}
208 {$setc TARGET_OS_UNIX := FALSE}
209 {$setc TARGET_OS_WIN32 := FALSE}
210 {$setc TARGET_RT_MAC_68881 := FALSE}
211 {$setc TARGET_RT_MAC_CFM := FALSE}
212 {$setc TARGET_RT_MAC_MACHO := TRUE}
213 {$setc TYPED_FUNCTION_POINTERS := TRUE}
214 {$setc TYPE_BOOL := FALSE}
215 {$setc TYPE_EXTENDED := FALSE}
216 {$setc TYPE_LONGLONG := TRUE}
217 uses MacTypes,CFBase,KeychainCore,CFString,CFArray,CFDate;
218 {$endc} {not MACOSALLINCLUDE}
219 
220 
221 {$ifc TARGET_OS_MAC}
222 
223 { High-level interface for storing passwords }
224 {
225  *  KCAddAppleSharePassword()   *** DEPRECATED ***
226  *
227  *  Deprecated:
228  *    Use SecKeychainAddInternetPassword
229  *
230  *  Availability:
231  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
232  *    CarbonLib:        in CarbonLib 1.1 and later
233  *    Non-Carbon CFM:   in KeychainLib 1.0 and later
234  }
235 // overloading not available
KCAddAppleSharePasswordnull236 // function KCAddAppleSharePassword( var serverSignature: AFPServerSignature; serverAddress: StringPtr; serverName: StringPtr; volumeName: StringPtr; accountName: StringPtr; passwordLength: UInt32; passwordData: {const} UnivPtr; item: KCItemRefPtr { can be NULL } ): OSStatus;
237 // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
238 
239 
240 {
241  *  KCAddInternetPassword()   *** DEPRECATED ***
242  *
243  *  Deprecated:
244  *    Use SecKeychainAddInternetPassword
245  *
246  *  Availability:
247  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
248  *    CarbonLib:        in CarbonLib 1.1 and later
249  *    Non-Carbon CFM:   in KeychainLib 1.0 and later
250  }
251 // overloading not available
252 // function KCAddInternetPassword( serverName: StringPtr; securityDomain: StringPtr; accountName: StringPtr; port: UInt16; protocol: OSType; authType: OSType; passwordLength: UInt32; passwordData: {const} UnivPtr; item: KCItemRefPtr { can be NULL } ): OSStatus;
253 // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
254 
255 
256 {
257  *  KCAddInternetPasswordWithPath()   *** DEPRECATED ***
258  *
259  *  Deprecated:
260  *    Use SecKeychainAddInternetPassword
261  *
262  *  Availability:
263  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
264  *    CarbonLib:        in CarbonLib 1.1 and later
265  *    Non-Carbon CFM:   in KeychainLib 2.0 and later
266  }
267 // overloading not available
268 // function KCAddInternetPasswordWithPath( serverName: StringPtr; securityDomain: StringPtr; accountName: StringPtr; path: StringPtr; port: UInt16; protocol: OSType; authType: OSType; passwordLength: UInt32; passwordData: {const} UnivPtr; item: KCItemRefPtr { can be NULL } ): OSStatus;
269 // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
270 
271 
272 {
273  *  KCAddGenericPassword()   *** DEPRECATED ***
274  *
275  *  Deprecated:
276  *    Use SecKeychainAddGenericPassword
277  *
278  *  Availability:
279  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
280  *    CarbonLib:        in CarbonLib 1.1 and later
281  *    Non-Carbon CFM:   in KeychainLib 1.0 and later
282  }
283 // overloading not available
284 // function KCAddGenericPassword( serviceName: StringPtr; accountName: StringPtr; passwordLength: UInt32; passwordData: {const} UnivPtr; item: KCItemRefPtr { can be NULL } ): OSStatus;
285 // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
286 
287 
288 { Low-level interface for storing keychain items }
289 {
290  *  KCAddItem()   *** DEPRECATED ***
291  *
292  *  Deprecated:
293  *    Use SecKeychainItemCreateFromContent
294  *
295  *  Availability:
296  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
297  *    CarbonLib:        in CarbonLib 1.1 and later
298  *    Non-Carbon CFM:   in KeychainLib 1.0 and later
299  }
300 function KCAddItem( item: KCItemRef ): OSStatus; external name '_KCAddItem';
301 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
302 
303 
304 { Managing keychains }
305 {
306  *  KCUnlock()   *** DEPRECATED ***
307  *
308  *  Deprecated:
309  *    Use SecKeychainUnlock
310  *
311  *  Availability:
312  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
313  *    CarbonLib:        in CarbonLib 1.1 and later
314  *    Non-Carbon CFM:   in KeychainLib 1.0 and later
315  }
316 // overloading not available
KCUnlocknull317 //function KCUnlock( keychain: KCRef { can be NULL }; password: StringPtr { can be NULL } ): OSStatus;
318 //AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
319 
320 
321 {
322  *  KCCreateKeychain()   *** DEPRECATED ***
323  *
324  *  Deprecated:
325  *    Use SecKeychainCreate
326  *
327  *  Availability:
328  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
329  *    CarbonLib:        in CarbonLib 1.1 and later
330  *    Non-Carbon CFM:   in KeychainLib 1.0 and later
331  }
332 // overloading not available
333 // function KCCreateKeychain( password: StringPtr { can be NULL }; keychain: KCRefPtr { can be NULL } ): OSStatus;
334 // AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
335 
336 
337 {
338  *  KCChangeSettings()   *** DEPRECATED ***
339  *
340  *  Deprecated:
341  *    Use SecKeychainSetSettings
342  *
343  *  Availability:
344  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
345  *    CarbonLib:        in CarbonLib 1.1 and later
346  *    Non-Carbon CFM:   in KeychainLib 2.0 and later
347  }
348 function KCChangeSettings( keychain: KCRef ): OSStatus; external name '_KCChangeSettings';
349 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
350 
351 
352 {
353  *  kcunlock()   *** DEPRECATED ***
354  *
355  *  Deprecated:
356  *    Use SecKeychainUnlock
357  *
358  *  Availability:
359  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
360  *    CarbonLib:        in CarbonLib 1.1 and later
361  *    Non-Carbon CFM:   in KeychainLib 1.0 and later
362  }
kcunlocknull363 function kcunlock( keychain: KCRef { can be NULL }; password: ConstCStringPtr { can be NULL } ): OSStatus; external name '_kcunlock';
364 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
365 
366 
367 {
368  *  kccreatekeychain()   *** DEPRECATED ***
369  *
370  *  Deprecated:
371  *    Use SecKeychainCreate
372  *
373  *  Availability:
374  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
375  *    CarbonLib:        in CarbonLib 1.1 and later
376  *    Non-Carbon CFM:   in KeychainLib 1.0 and later
377  }
kccreatekeychainnull378 function kccreatekeychain( password: ConstCStringPtr { can be NULL }; keychain: KCRefPtr { can be NULL } ): OSStatus; external name '_kccreatekeychain';
379 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
380 
381 
382 {
383  *  kcaddapplesharepassword()   *** DEPRECATED ***
384  *
385  *  Deprecated:
386  *    Use SecKeychainAddInternetPassword
387  *
388  *  Availability:
389  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
390  *    CarbonLib:        in CarbonLib 1.1 and later
391  *    Non-Carbon CFM:   in KeychainLib 1.0 and later
392  }
kcaddapplesharepasswordnull393 function kcaddapplesharepassword( var serverSignature: AFPServerSignature; serverAddress: ConstCStringPtr; serverName: ConstCStringPtr; volumeName: ConstCStringPtr; accountName: ConstCStringPtr; passwordLength: UInt32; passwordData: {const} UnivPtr; item: KCItemRefPtr { can be NULL } ): OSStatus; external name '_kcaddapplesharepassword';
394 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
395 
396 
397 {
398  *  kcaddinternetpassword()   *** DEPRECATED ***
399  *
400  *  Deprecated:
401  *    Use SecKeychainAddInternetPassword
402  *
403  *  Availability:
404  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
405  *    CarbonLib:        in CarbonLib 1.1 and later
406  *    Non-Carbon CFM:   in KeychainLib 1.0 and later
407  }
kcaddinternetpasswordnull408 function kcaddinternetpassword( serverName: ConstCStringPtr; securityDomain: ConstCStringPtr; accountName: ConstCStringPtr; port: UInt16; protocol: OSType; authType: OSType; passwordLength: UInt32; passwordData: {const} UnivPtr; item: KCItemRefPtr { can be NULL } ): OSStatus; external name '_kcaddinternetpassword';
409 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
410 
411 
412 {
413  *  kcaddinternetpasswordwithpath()   *** DEPRECATED ***
414  *
415  *  Deprecated:
416  *    Use SecKeychainAddInternetPassword
417  *
418  *  Availability:
419  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
420  *    CarbonLib:        in CarbonLib 1.1 and later
421  *    Non-Carbon CFM:   in KeychainLib 2.0 and later
422  }
kcaddinternetpasswordwithpathnull423 function kcaddinternetpasswordwithpath( serverName: ConstCStringPtr; securityDomain: ConstCStringPtr; accountName: ConstCStringPtr; path: ConstCStringPtr; port: UInt16; protocol: OSType; authType: OSType; passwordLength: UInt32; passwordData: {const} UnivPtr; item: KCItemRefPtr { can be NULL } ): OSStatus; external name '_kcaddinternetpasswordwithpath';
424 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
425 
426 
427 {
428  *  kcaddgenericpassword()   *** DEPRECATED ***
429  *
430  *  Deprecated:
431  *    Use SecKeychainAddGenericPassword
432  *
433  *  Availability:
434  *    Mac OS X:         in version 10.0 and later in Carbon.framework but deprecated in 10.6
435  *    CarbonLib:        in CarbonLib 1.1 and later
436  *    Non-Carbon CFM:   in KeychainLib 1.0 and later
437  }
kcaddgenericpasswordnull438 function kcaddgenericpassword( serviceName: ConstCStringPtr; accountName: ConstCStringPtr; passwordLength: UInt32; passwordData: {const} UnivPtr; item: KCItemRefPtr { can be NULL } ): OSStatus; external name '_kcaddgenericpassword';
439 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 *)
440 
441 
442 { Working with certificates }
443 {
444  *  KCFindX509Certificates()
445  *
446  *  Availability:
447  *    Mac OS X:         not available
448  *    CarbonLib:        not available
449  *    Non-Carbon CFM:   in KeychainLib 2.0 and later
450  }
451 
452 
453 {
454  *  KCChooseCertificate()
455  *
456  *  Availability:
457  *    Mac OS X:         not available
458  *    CarbonLib:        not available
459  *    Non-Carbon CFM:   in KeychainLib 2.0 and later
460  }
461 
462 {$endc} {TARGET_OS_MAC}
463 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
464 
465 end.
466 {$endc} {not MACOSALLINCLUDE}
467