1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecunlockstatestatus?language=objc)
pub const kSecUnlockStateStatus: u32 = 1;
/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecreadpermstatus?language=objc)
pub const kSecReadPermStatus: u32 = 2;
/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecwritepermstatus?language=objc)
pub const kSecWritePermStatus: u32 = 4;
/// Contains keychain settings.
/// Field: version An unsigned 32-bit integer representing the keychain version.
/// Field: lockOnSleep A boolean value indicating whether the keychain locks when the system sleeps.
/// Field: useLockInterval A boolean value indicating whether the keychain automatically locks after a certain period of time.
/// Field: lockInterval An unsigned 32-bit integer representing the number of seconds before the keychain locks.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeychainsettings?language=objc)
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct SecKeychainSettings {
pub version: u32,
pub lockOnSleep: Boolean,
pub useLockInterval: Boolean,
pub lockInterval: u32,
}
#[cfg(feature = "objc2")]
unsafe impl Encode for SecKeychainSettings {
const ENCODING: Encoding = Encoding::Struct(
"SecKeychainSettings",
&[
<u32>::ENCODING,
<Boolean>::ENCODING,
<Boolean>::ENCODING,
<u32>::ENCODING,
],
);
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for SecKeychainSettings {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/security/secauthenticationtype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SecAuthenticationType(pub FourCharCode);
impl SecAuthenticationType {
#[doc(alias = "kSecAuthenticationTypeNTLM")]
pub const NTLM: Self = Self(AUTH_TYPE_FIX_!(0x6e746c6d));
#[doc(alias = "kSecAuthenticationTypeMSN")]
pub const MSN: Self = Self(AUTH_TYPE_FIX_!(0x6d736e61));
#[doc(alias = "kSecAuthenticationTypeDPA")]
pub const DPA: Self = Self(AUTH_TYPE_FIX_!(0x64706161));
#[doc(alias = "kSecAuthenticationTypeRPA")]
pub const RPA: Self = Self(AUTH_TYPE_FIX_!(0x72706161));
#[doc(alias = "kSecAuthenticationTypeHTTPBasic")]
pub const HTTPBasic: Self = Self(AUTH_TYPE_FIX_!(0x68747470));
#[doc(alias = "kSecAuthenticationTypeHTTPDigest")]
pub const HTTPDigest: Self = Self(AUTH_TYPE_FIX_!(0x68747464));
#[doc(alias = "kSecAuthenticationTypeHTMLForm")]
pub const HTMLForm: Self = Self(AUTH_TYPE_FIX_!(0x666f726d));
#[doc(alias = "kSecAuthenticationTypeDefault")]
pub const Default: Self = Self(AUTH_TYPE_FIX_!(0x64666c74));
#[doc(alias = "kSecAuthenticationTypeAny")]
pub const Any: Self = Self(AUTH_TYPE_FIX_!(0));
}
#[cfg(feature = "objc2")]
unsafe impl Encode for SecAuthenticationType {
const ENCODING: Encoding = FourCharCode::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for SecAuthenticationType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// Defines the protocol type associated with an AppleShare or Internet password.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secprotocoltype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SecProtocolType(pub FourCharCode);
impl SecProtocolType {
#[doc(alias = "kSecProtocolTypeFTP")]
pub const FTP: Self = Self(0x66747020);
#[doc(alias = "kSecProtocolTypeFTPAccount")]
pub const FTPAccount: Self = Self(0x66747061);
#[doc(alias = "kSecProtocolTypeHTTP")]
pub const HTTP: Self = Self(0x68747470);
#[doc(alias = "kSecProtocolTypeIRC")]
pub const IRC: Self = Self(0x69726320);
#[doc(alias = "kSecProtocolTypeNNTP")]
pub const NNTP: Self = Self(0x6e6e7470);
#[doc(alias = "kSecProtocolTypePOP3")]
pub const POP3: Self = Self(0x706f7033);
#[doc(alias = "kSecProtocolTypeSMTP")]
pub const SMTP: Self = Self(0x736d7470);
#[doc(alias = "kSecProtocolTypeSOCKS")]
pub const SOCKS: Self = Self(0x736f7820);
#[doc(alias = "kSecProtocolTypeIMAP")]
pub const IMAP: Self = Self(0x696d6170);
#[doc(alias = "kSecProtocolTypeLDAP")]
pub const LDAP: Self = Self(0x6c646170);
#[doc(alias = "kSecProtocolTypeAppleTalk")]
pub const AppleTalk: Self = Self(0x61746c6b);
#[doc(alias = "kSecProtocolTypeAFP")]
pub const AFP: Self = Self(0x61667020);
#[doc(alias = "kSecProtocolTypeTelnet")]
pub const Telnet: Self = Self(0x74656c6e);
#[doc(alias = "kSecProtocolTypeSSH")]
pub const SSH: Self = Self(0x73736820);
#[doc(alias = "kSecProtocolTypeFTPS")]
pub const FTPS: Self = Self(0x66747073);
#[doc(alias = "kSecProtocolTypeHTTPS")]
pub const HTTPS: Self = Self(0x68747073);
#[doc(alias = "kSecProtocolTypeHTTPProxy")]
pub const HTTPProxy: Self = Self(0x68747078);
#[doc(alias = "kSecProtocolTypeHTTPSProxy")]
pub const HTTPSProxy: Self = Self(0x68747378);
#[doc(alias = "kSecProtocolTypeFTPProxy")]
pub const FTPProxy: Self = Self(0x66747078);
#[doc(alias = "kSecProtocolTypeCIFS")]
pub const CIFS: Self = Self(0x63696673);
#[doc(alias = "kSecProtocolTypeSMB")]
pub const SMB: Self = Self(0x736d6220);
#[doc(alias = "kSecProtocolTypeRTSP")]
pub const RTSP: Self = Self(0x72747370);
#[doc(alias = "kSecProtocolTypeRTSPProxy")]
pub const RTSPProxy: Self = Self(0x72747378);
#[doc(alias = "kSecProtocolTypeDAAP")]
pub const DAAP: Self = Self(0x64616170);
#[doc(alias = "kSecProtocolTypeEPPC")]
pub const EPPC: Self = Self(0x65707063);
#[doc(alias = "kSecProtocolTypeIPP")]
pub const IPP: Self = Self(0x69707020);
#[doc(alias = "kSecProtocolTypeNNTPS")]
pub const NNTPS: Self = Self(0x6e747073);
#[doc(alias = "kSecProtocolTypeLDAPS")]
pub const LDAPS: Self = Self(0x6c647073);
#[doc(alias = "kSecProtocolTypeTelnetS")]
pub const TelnetS: Self = Self(0x74656c73);
#[doc(alias = "kSecProtocolTypeIMAPS")]
pub const IMAPS: Self = Self(0x696d7073);
#[doc(alias = "kSecProtocolTypeIRCS")]
pub const IRCS: Self = Self(0x69726373);
#[doc(alias = "kSecProtocolTypePOP3S")]
pub const POP3S: Self = Self(0x706f7073);
#[doc(alias = "kSecProtocolTypeCVSpserver")]
pub const CVSpserver: Self = Self(0x63767370);
#[doc(alias = "kSecProtocolTypeSVN")]
pub const SVN: Self = Self(0x73766e20);
#[doc(alias = "kSecProtocolTypeAny")]
pub const Any: Self = Self(0);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for SecProtocolType {
const ENCODING: Encoding = FourCharCode::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for SecProtocolType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// Defines the keychain-related event.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeychainevent?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SecKeychainEvent(pub u32);
impl SecKeychainEvent {
#[doc(alias = "kSecLockEvent")]
pub const LockEvent: Self = Self(1);
#[doc(alias = "kSecUnlockEvent")]
pub const UnlockEvent: Self = Self(2);
#[doc(alias = "kSecAddEvent")]
pub const AddEvent: Self = Self(3);
#[doc(alias = "kSecDeleteEvent")]
pub const DeleteEvent: Self = Self(4);
#[doc(alias = "kSecUpdateEvent")]
pub const UpdateEvent: Self = Self(5);
#[doc(alias = "kSecPasswordChangedEvent")]
pub const PasswordChangedEvent: Self = Self(6);
#[doc(alias = "kSecDefaultChangedEvent")]
pub const DefaultChangedEvent: Self = Self(9);
#[doc(alias = "kSecDataAccessEvent")]
#[deprecated = "Read events are no longer posted"]
pub const DataAccessEvent: Self = Self(10);
#[doc(alias = "kSecKeychainListChangedEvent")]
pub const KeychainListChangedEvent: Self = Self(11);
#[doc(alias = "kSecTrustSettingsChangedEvent")]
pub const TrustSettingsChangedEvent: Self = Self(12);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for SecKeychainEvent {
const ENCODING: Encoding = u32::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for SecKeychainEvent {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// Defines keychain event constants
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeychaineventmask?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SecKeychainEventMask(pub u32);
bitflags::bitflags! {
impl SecKeychainEventMask: u32 {
#[doc(alias = "kSecLockEventMask")]
const LockEventMask = 1<<SecKeychainEvent::LockEvent.0;
#[doc(alias = "kSecUnlockEventMask")]
const UnlockEventMask = 1<<SecKeychainEvent::UnlockEvent.0;
#[doc(alias = "kSecAddEventMask")]
const AddEventMask = 1<<SecKeychainEvent::AddEvent.0;
#[doc(alias = "kSecDeleteEventMask")]
const DeleteEventMask = 1<<SecKeychainEvent::DeleteEvent.0;
#[doc(alias = "kSecUpdateEventMask")]
const UpdateEventMask = 1<<SecKeychainEvent::UpdateEvent.0;
#[doc(alias = "kSecPasswordChangedEventMask")]
const PasswordChangedEventMask = 1<<SecKeychainEvent::PasswordChangedEvent.0;
#[doc(alias = "kSecDefaultChangedEventMask")]
const DefaultChangedEventMask = 1<<SecKeychainEvent::DefaultChangedEvent.0;
#[doc(alias = "kSecDataAccessEventMask")]
#[deprecated = "Read events are no longer posted"]
const DataAccessEventMask = 1<<SecKeychainEvent::DataAccessEvent.0;
#[doc(alias = "kSecKeychainListChangedMask")]
const KeychainListChangedMask = 1<<SecKeychainEvent::KeychainListChangedEvent.0;
#[doc(alias = "kSecTrustSettingsChangedEventMask")]
const TrustSettingsChangedEventMask = 1<<SecKeychainEvent::TrustSettingsChangedEvent.0;
#[doc(alias = "kSecEveryEventMask")]
const EveryEventMask = 0xffffffff;
}
}
#[cfg(feature = "objc2")]
unsafe impl Encode for SecKeychainEventMask {
const ENCODING: Encoding = u32::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for SecKeychainEventMask {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// Contains information about a keychain event.
/// Field: version The version of this structure.
/// Field: item A reference to the keychain item associated with this event, if any. Note that some events do not involve a particular keychain item.
/// Field: keychain A reference to the keychain in which the event occurred.
/// Field: pid The id of the process that generated this event.
///
/// The SecKeychainCallbackInfo type represents a structure that contains information about the keychain event for which your application is being notified. For information on how to write a keychain event callback function, see SecKeychainCallback.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeychaincallbackinfo?language=objc)
#[cfg(all(feature = "SecBase", feature = "libc"))]
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct SecKeychainCallbackInfo {
pub version: u32,
pub item: NonNull<SecKeychainItem>,
pub keychain: NonNull<SecKeychain>,
pub pid: libc::pid_t,
}
#[cfg(all(feature = "SecBase", feature = "libc", feature = "objc2"))]
unsafe impl Encode for SecKeychainCallbackInfo {
const ENCODING: Encoding = Encoding::Struct(
"SecKeychainCallbackInfo",
&[
<u32>::ENCODING,
<NonNull<SecKeychainItem>>::ENCODING,
<NonNull<SecKeychain>>::ENCODING,
<libc::pid_t>::ENCODING,
],
);
}
#[cfg(all(feature = "SecBase", feature = "libc", feature = "objc2"))]
unsafe impl RefEncode for SecKeychainCallbackInfo {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[cfg(feature = "SecBase")]
unsafe impl ConcreteType for SecKeychain {
/// Returns the type identifier of SecKeychain instances.
///
/// Returns: The CFTypeID of SecKeychain instances.
#[doc(alias = "SecKeychainGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn SecKeychainGetTypeID() -> CFTypeID;
}
unsafe { SecKeychainGetTypeID() }
}
}
#[cfg(feature = "SecBase")]
impl SecKeychain {
/// Determines the version of the Keychain Manager installed on the user�s system.
///
/// Parameter `returnVers`: On return, a pointer to the version number of the Keychain Manager installed on the current system.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// `return_vers` must be a valid pointer.
#[doc(alias = "SecKeychainGetVersion")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn version(return_vers: NonNull<u32>) -> OSStatus {
extern "C-unwind" {
fn SecKeychainGetVersion(return_vers: NonNull<u32>) -> OSStatus;
}
unsafe { SecKeychainGetVersion(return_vers) }
}
/// Create a SecKeychainRef for a keychain at pathName. This keychain might
/// not currently exist, use SecKeychainGetStatus if you want to confirm the existence
/// of this keychain.
///
/// Parameter `pathName`: The POSIX path to a keychain.
///
/// Parameter `keychain`: On return, a pointer to the keychain reference. The memory that keychain occupies must be released by calling CFRelease when finished with it.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if the keychain parameter is invalid (NULL).
///
/// # Safety
///
/// - `path_name` must be a valid pointer.
/// - `keychain` must be a valid pointer.
#[doc(alias = "SecKeychainOpen")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn open(
path_name: NonNull<c_char>,
keychain: NonNull<*mut SecKeychain>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainOpen(
path_name: NonNull<c_char>,
keychain: NonNull<*mut SecKeychain>,
) -> OSStatus;
}
unsafe { SecKeychainOpen(path_name, keychain) }
}
/// Creates a new keychain.
///
/// Parameter `pathName`: The POSIX path to a keychain file.
///
/// Parameter `passwordLength`: An unsigned 32-bit integer representing the length of the password buffer.
///
/// Parameter `password`: A pointer to the buffer containing the password. The password must be in canonical UTF8 encoding.
///
/// Parameter `promptUser`: A boolean representing whether to display a password dialog to the user.
///
/// Parameter `initialAccess`: An access reference.
///
/// Parameter `keychain`: On return, a pointer to a keychain reference. The memory that keychain occupies must be released by calling CFRelease when finished with it.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if the keychain parameter is invalid (NULL).
///
/// # Safety
///
/// - `path_name` must be a valid pointer.
/// - `password` must be a valid pointer or null.
/// - `keychain` must be a valid pointer.
#[doc(alias = "SecKeychainCreate")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn create(
path_name: NonNull<c_char>,
password_length: u32,
password: *const c_void,
prompt_user: bool,
initial_access: Option<&SecAccess>,
keychain: NonNull<*mut SecKeychain>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainCreate(
path_name: NonNull<c_char>,
password_length: u32,
password: *const c_void,
prompt_user: Boolean,
initial_access: Option<&SecAccess>,
keychain: NonNull<*mut SecKeychain>,
) -> OSStatus;
}
unsafe {
SecKeychainCreate(
path_name,
password_length,
password,
prompt_user as _,
initial_access,
keychain,
)
}
}
/// Removes one or more keychains from the current keychain searchlist, and deletes the keychain storage (if the keychains are file-based).
///
/// Parameter `keychainOrArray`: A single keychain reference or a reference to an array of keychains to delete. IMPORTANT: SecKeychainDelete does not dispose the memory occupied by keychain references; use the CFRelease function when you are completely finished with a keychain.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h). In addition, errSecInvalidKeychain (-25295) may be returned if the keychain parameter is invalid (NULL).
#[doc(alias = "SecKeychainDelete")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn delete(keychain_or_array: Option<&SecKeychain>) -> OSStatus {
extern "C-unwind" {
fn SecKeychainDelete(keychain_or_array: Option<&SecKeychain>) -> OSStatus;
}
unsafe { SecKeychainDelete(keychain_or_array) }
}
/// Changes the settings of a keychain.
///
/// Parameter `keychain`: A reference to a keychain.
///
/// Parameter `newSettings`: A pointer to the new keychain settings.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// `new_settings` must be a valid pointer.
#[doc(alias = "SecKeychainSetSettings")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn set_settings(
keychain: Option<&SecKeychain>,
new_settings: NonNull<SecKeychainSettings>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainSetSettings(
keychain: Option<&SecKeychain>,
new_settings: NonNull<SecKeychainSettings>,
) -> OSStatus;
}
unsafe { SecKeychainSetSettings(keychain, new_settings) }
}
/// Copy the keychain settings.
///
/// Parameter `keychain`: A reference to the keychain from which to copy its settings.
///
/// Parameter `outSettings`: A pointer to a keychain settings structure. Since this structure is versioned, you must preallocate it and fill in the version of the structure.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// `out_settings` must be a valid pointer.
#[doc(alias = "SecKeychainCopySettings")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn copy_settings(
keychain: Option<&SecKeychain>,
out_settings: NonNull<SecKeychainSettings>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainCopySettings(
keychain: Option<&SecKeychain>,
out_settings: NonNull<SecKeychainSettings>,
) -> OSStatus;
}
unsafe { SecKeychainCopySettings(keychain, out_settings) }
}
/// Unlocks the specified keychain.
///
/// Parameter `keychain`: A reference to the keychain to unlock. Pass NULL to specify the default keychain. If you pass NULL and the default keychain is currently locked, the keychain will appear as the default choice. If you pass a locked keychain, SecKeychainUnlock will use the password provided to unlock it. If the default keychain is currently unlocked, SecKeychainUnlock returns errSecSuccess.
///
/// Parameter `passwordLength`: An unsigned 32-bit integer representing the length of the password buffer.
///
/// Parameter `password`: A buffer containing the password for the keychain. Pass NULL if the user password is unknown. In this case, SecKeychainUnlock displays the Unlock Keychain dialog box, and the authentication user interface associated with the keychain about to be unlocked.
///
/// Parameter `usePassword`: A boolean indicating whether the password parameter is used. You should pass TRUE if it is used or FALSE if it is ignored.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// In most cases, your application does not need to call the SecKeychainUnlock function directly, since most Keychain Manager functions that require an unlocked keychain call SecKeychainUnlock automatically. If your application needs to verify that a keychain is unlocked, call the function SecKeychainGetStatus.
///
/// # Safety
///
/// `password` must be a valid pointer or null.
#[doc(alias = "SecKeychainUnlock")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn unlock(
keychain: Option<&SecKeychain>,
password_length: u32,
password: *const c_void,
use_password: bool,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainUnlock(
keychain: Option<&SecKeychain>,
password_length: u32,
password: *const c_void,
use_password: Boolean,
) -> OSStatus;
}
unsafe { SecKeychainUnlock(keychain, password_length, password, use_password as _) }
}
/// Locks the specified keychain.
///
/// Parameter `keychain`: A reference to the keychain to lock.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
#[doc(alias = "SecKeychainLock")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn lock(keychain: Option<&SecKeychain>) -> OSStatus {
extern "C-unwind" {
fn SecKeychainLock(keychain: Option<&SecKeychain>) -> OSStatus;
}
unsafe { SecKeychainLock(keychain) }
}
/// Locks all keychains belonging to the current user.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
#[doc(alias = "SecKeychainLockAll")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn lock_all() -> OSStatus {
extern "C-unwind" {
fn SecKeychainLockAll() -> OSStatus;
}
unsafe { SecKeychainLockAll() }
}
/// Retrieves a reference to the default keychain.
///
/// Parameter `keychain`: On return, a pointer to the default keychain reference.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// `keychain` must be a valid pointer.
#[doc(alias = "SecKeychainCopyDefault")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn copy_default(keychain: NonNull<*mut SecKeychain>) -> OSStatus {
extern "C-unwind" {
fn SecKeychainCopyDefault(keychain: NonNull<*mut SecKeychain>) -> OSStatus;
}
unsafe { SecKeychainCopyDefault(keychain) }
}
/// Sets the default keychain.
///
/// Parameter `keychain`: A reference to the keychain to set as default.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if the keychain parameter is invalid (NULL).
#[doc(alias = "SecKeychainSetDefault")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn set_default(keychain: Option<&SecKeychain>) -> OSStatus {
extern "C-unwind" {
fn SecKeychainSetDefault(keychain: Option<&SecKeychain>) -> OSStatus;
}
unsafe { SecKeychainSetDefault(keychain) }
}
/// Retrieves a keychain search list.
///
/// Parameter `searchList`: The returned list of keychains to search. When finished with the array, you must call CFRelease() to release the memory.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if the keychain list is not specified (NULL).
///
/// # Safety
///
/// `search_list` must be a valid pointer.
#[doc(alias = "SecKeychainCopySearchList")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn copy_search_list(search_list: NonNull<*const CFArray>) -> OSStatus {
extern "C-unwind" {
fn SecKeychainCopySearchList(search_list: NonNull<*const CFArray>) -> OSStatus;
}
unsafe { SecKeychainCopySearchList(search_list) }
}
/// Specifies the list of keychains to use in a keychain search list.
///
/// Parameter `searchList`: The list of keychains to use in a search list when the SecKeychainCopySearchList function is called. An empty array clears the search list.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if the keychain list is not specified (NULL).
///
/// # Safety
///
/// `search_list` generic must be of the correct type.
#[doc(alias = "SecKeychainSetSearchList")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn set_search_list(search_list: &CFArray) -> OSStatus {
extern "C-unwind" {
fn SecKeychainSetSearchList(search_list: &CFArray) -> OSStatus;
}
unsafe { SecKeychainSetSearchList(search_list) }
}
}
/// [Apple's documentation](https://developer.apple.com/documentation/security/secpreferencesdomain?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SecPreferencesDomain(pub c_int);
impl SecPreferencesDomain {
#[doc(alias = "kSecPreferencesDomainUser")]
pub const User: Self = Self(0);
#[doc(alias = "kSecPreferencesDomainSystem")]
pub const System: Self = Self(1);
#[doc(alias = "kSecPreferencesDomainCommon")]
pub const Common: Self = Self(2);
#[doc(alias = "kSecPreferencesDomainDynamic")]
pub const Dynamic: Self = Self(3);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for SecPreferencesDomain {
const ENCODING: Encoding = c_int::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for SecPreferencesDomain {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[cfg(feature = "SecBase")]
impl SecKeychain {
/// # Safety
///
/// `keychain` must be a valid pointer.
#[doc(alias = "SecKeychainCopyDomainDefault")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn copy_domain_default(
domain: SecPreferencesDomain,
keychain: NonNull<*mut SecKeychain>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainCopyDomainDefault(
domain: SecPreferencesDomain,
keychain: NonNull<*mut SecKeychain>,
) -> OSStatus;
}
unsafe { SecKeychainCopyDomainDefault(domain, keychain) }
}
#[doc(alias = "SecKeychainSetDomainDefault")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn set_domain_default(
domain: SecPreferencesDomain,
keychain: Option<&SecKeychain>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainSetDomainDefault(
domain: SecPreferencesDomain,
keychain: Option<&SecKeychain>,
) -> OSStatus;
}
unsafe { SecKeychainSetDomainDefault(domain, keychain) }
}
/// # Safety
///
/// `search_list` must be a valid pointer.
#[doc(alias = "SecKeychainCopyDomainSearchList")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn copy_domain_search_list(
domain: SecPreferencesDomain,
search_list: NonNull<*const CFArray>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainCopyDomainSearchList(
domain: SecPreferencesDomain,
search_list: NonNull<*const CFArray>,
) -> OSStatus;
}
unsafe { SecKeychainCopyDomainSearchList(domain, search_list) }
}
/// # Safety
///
/// `search_list` generic must be of the correct type.
#[doc(alias = "SecKeychainSetDomainSearchList")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn set_domain_search_list(
domain: SecPreferencesDomain,
search_list: &CFArray,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainSetDomainSearchList(
domain: SecPreferencesDomain,
search_list: &CFArray,
) -> OSStatus;
}
unsafe { SecKeychainSetDomainSearchList(domain, search_list) }
}
#[doc(alias = "SecKeychainSetPreferenceDomain")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn set_preference_domain(domain: SecPreferencesDomain) -> OSStatus {
extern "C-unwind" {
fn SecKeychainSetPreferenceDomain(domain: SecPreferencesDomain) -> OSStatus;
}
unsafe { SecKeychainSetPreferenceDomain(domain) }
}
/// # Safety
///
/// `domain` must be a valid pointer.
#[doc(alias = "SecKeychainGetPreferenceDomain")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn preference_domain(domain: NonNull<SecPreferencesDomain>) -> OSStatus {
extern "C-unwind" {
fn SecKeychainGetPreferenceDomain(domain: NonNull<SecPreferencesDomain>) -> OSStatus;
}
unsafe { SecKeychainGetPreferenceDomain(domain) }
}
/// Retrieves status information for the specified keychain.
///
/// Parameter `keychain`: A keychain reference. Pass NULL to specify the default keychain.
///
/// Parameter `keychainStatus`: On return, a pointer to the status of the specified keychain. See KeychainStatus for valid status constants.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// `keychain_status` must be a valid pointer.
#[doc(alias = "SecKeychainGetStatus")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn status(
keychain: Option<&SecKeychain>,
keychain_status: NonNull<SecKeychainStatus>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainGetStatus(
keychain: Option<&SecKeychain>,
keychain_status: NonNull<SecKeychainStatus>,
) -> OSStatus;
}
unsafe { SecKeychainGetStatus(keychain, keychain_status) }
}
/// Get the path of the specified keychain.
///
/// Parameter `keychain`: A reference to a keychain.
///
/// Parameter `ioPathLength`: On input, a pointer to the size of the buffer pointed to by pathName. On return, the size of the buffer without the zero termination.
///
/// Parameter `pathName`: On return, the POSIX path to the keychain.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// - `io_path_length` must be a valid pointer.
/// - `path_name` must be a valid pointer.
#[doc(alias = "SecKeychainGetPath")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn path(
keychain: Option<&SecKeychain>,
io_path_length: NonNull<u32>,
path_name: NonNull<c_char>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainGetPath(
keychain: Option<&SecKeychain>,
io_path_length: NonNull<u32>,
path_name: NonNull<c_char>,
) -> OSStatus;
}
unsafe { SecKeychainGetPath(keychain, io_path_length, path_name) }
}
/// Obtains tags for all possible attributes for a given item class.
///
/// Parameter `keychain`: A keychain reference.
///
/// Parameter `itemID`: The relation identifier of the item tags (an itemID is a CSSM_DB_RECORDTYPE defined in cssmapple.h).
///
/// Parameter `info`: On return, a pointer to the keychain attribute information. User should call the SecKeychainFreeAttributeInfo function to release the structure when done with it.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if not enough valid parameters were supplied (NULL).
///
/// Warning, this call returns more attributes than are support by the old style Keychain API and passing them into older calls will yield an invalid attribute error. The recommended call to retrieve the attribute values is the SecKeychainItemCopyAttributesAndData function.
///
/// # Safety
///
/// `info` must be a valid pointer.
#[doc(alias = "SecKeychainAttributeInfoForItemID")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn attribute_info_for_item_id(
keychain: Option<&SecKeychain>,
item_id: u32,
info: NonNull<*mut SecKeychainAttributeInfo>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainAttributeInfoForItemID(
keychain: Option<&SecKeychain>,
item_id: u32,
info: NonNull<*mut SecKeychainAttributeInfo>,
) -> OSStatus;
}
unsafe { SecKeychainAttributeInfoForItemID(keychain, item_id, info) }
}
/// Releases the memory acquired by calling the SecKeychainAttributeInfoForItemID function.
///
/// Parameter `info`: A pointer to the keychain attribute information to release.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if not enough valid parameters were supplied (NULL).
///
/// # Safety
///
/// `info` must be a valid pointer.
#[doc(alias = "SecKeychainFreeAttributeInfo")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn free_attribute_info(info: NonNull<SecKeychainAttributeInfo>) -> OSStatus {
extern "C-unwind" {
fn SecKeychainFreeAttributeInfo(info: NonNull<SecKeychainAttributeInfo>) -> OSStatus;
}
unsafe { SecKeychainFreeAttributeInfo(info) }
}
}
/// Defines a pointer to a customized callback function. You supply the customized callback function to do a callback tailored to your application's needs.
///
/// Parameter `keychainEvent`: The keychain event that your application wishes to be notified of. See SecKeychainEvent for a description of possible values. The type of event that can trigger your callback depends on the bit mask you passed in the eventMask parameter of the function SecKeychainAddCallback. For more information, see the discussion.
///
/// Parameter `info`: A pointer to a structure of type SecKeychainCallbackInfo. On return, the structure contains information about the keychain event that occurred. The Keychain Manager passes this information to your callback function via the info parameter.
///
/// Parameter `context`: A pointer to application-defined storage that your application previously passed to the function SecKeychainAddCallback. You can use this value to perform operations like track which instance of a function is operating.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// If you name your function MyKeychainEventCallback, you would declare it like this:
/// OSStatus MyKeychainEventCallback (
/// 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 [Apple's documentation](https://developer.apple.com/documentation/security/seckeychaincallback?language=objc)
#[deprecated = "SecKeychain is deprecated"]
#[cfg(all(feature = "SecBase", feature = "libc"))]
pub type SecKeychainCallback = Option<
unsafe extern "C-unwind" fn(
SecKeychainEvent,
NonNull<SecKeychainCallbackInfo>,
*mut c_void,
) -> OSStatus,
>;
#[cfg(feature = "SecBase")]
impl SecKeychain {
/// Registers your keychain event callback function
///
/// Parameter `callbackFunction`: A pointer to your keychain event callback function, described in SecKeychainCallback. You indicate the type of keychain events you want to receive by passing a bit mask of the desired events in the eventMask parameter.
///
/// Parameter `eventMask`: A bit mask indicating the keychain events that your application wishes to be notified of. See SecKeychainEventMask for a description of this bit mask. The Keychain Manager tests this mask to determine the keychain events that you wish to receive, and passes these events in the keychainEvent parameter of your callback function. See SecKeychainEvent for a description of these events.
///
/// Parameter `userContext`: A pointer to application-defined storage that will be passed to your callback function. Your application can use this to associate any particular call of SecKeychainAddCallback with any particular call of your keychain event callback function.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// - `callback_function` must be implemented correctly.
/// - `user_context` must be a valid pointer or null.
#[doc(alias = "SecKeychainAddCallback")]
#[cfg(all(feature = "SecBase", feature = "libc"))]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn add_callback(
callback_function: SecKeychainCallback,
event_mask: SecKeychainEventMask,
user_context: *mut c_void,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainAddCallback(
callback_function: SecKeychainCallback,
event_mask: SecKeychainEventMask,
user_context: *mut c_void,
) -> OSStatus;
}
unsafe { SecKeychainAddCallback(callback_function, event_mask, user_context) }
}
/// Unregisters your keychain event callback function. Once removed, keychain events won't be sent to the owner of the callback.
///
/// Parameter `callbackFunction`: The callback function pointer to remove
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// `callback_function` must be implemented correctly.
#[doc(alias = "SecKeychainRemoveCallback")]
#[cfg(all(feature = "SecBase", feature = "libc"))]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn remove_callback(callback_function: SecKeychainCallback) -> OSStatus {
extern "C-unwind" {
fn SecKeychainRemoveCallback(callback_function: SecKeychainCallback) -> OSStatus;
}
unsafe { SecKeychainRemoveCallback(callback_function) }
}
/// Adds an Internet password to the specified keychain.
///
/// Parameter `keychain`: A reference to a keychain in which to store an Internet password. Pass NULL to specify the user's default keychain.
///
/// Parameter `serverNameLength`: The length of the buffer pointed to by serverName.
///
/// Parameter `serverName`: A pointer to a string containing the server name associated with this password.
///
/// Parameter `securityDomainLength`: The length of the buffer pointed to by securityDomain.
///
/// Parameter `securityDomain`: A pointer to a string containing the security domain associated with this password, or NULL if there is no relevant security domain.
///
/// Parameter `accountNameLength`: The length of the buffer pointed to by accountName.
///
/// Parameter `accountName`: A pointer to a string containing the account name associated with this password.
///
/// Parameter `pathLength`: The length of the buffer pointed to by path.
///
/// Parameter `path`: A pointer to a string containing the path associated with this password, or NULL if there is no relevant path string.
///
/// Parameter `port`: The TCP/IP port number. If no specific port number is associated with this item, pass 0.
///
/// Parameter `protocol`: The protocol associated with this password. See SecProtocolType for a description of possible values.
///
/// Parameter `authenticationType`: The authentication scheme used. See SecAuthenticationType for a description of possible values. Pass the constant kSecAuthenticationTypeDefault to specify the default authentication scheme.
///
/// Parameter `passwordLength`: The length of the buffer pointed to by passwordData.
///
/// Parameter `passwordData`: A pointer to a buffer containing the password data to be stored in the keychain.
///
/// Parameter `itemRef`: On return, a reference to the new keychain item.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// The SecKeychainAddInternetPassword function adds a new Internet server password to the specified keychain. Required parameters to identify the password are serverName and accountName (you cannot pass NULL for both parameters). In addition, some protocols may require an optional securityDomain when authentication is requested. SecKeychainAddInternetPassword optionally returns a reference to the newly added item.
///
/// # Safety
///
/// - `server_name` must be a valid pointer or null.
/// - `security_domain` must be a valid pointer or null.
/// - `account_name` must be a valid pointer or null.
/// - `path` must be a valid pointer or null.
/// - `password_data` must be a valid pointer.
/// - `item_ref` must be a valid pointer or null.
#[doc(alias = "SecKeychainAddInternetPassword")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn add_internet_password(
keychain: Option<&SecKeychain>,
server_name_length: u32,
server_name: *const c_char,
security_domain_length: u32,
security_domain: *const c_char,
account_name_length: u32,
account_name: *const c_char,
path_length: u32,
path: *const c_char,
port: u16,
protocol: SecProtocolType,
authentication_type: SecAuthenticationType,
password_length: u32,
password_data: NonNull<c_void>,
item_ref: *mut *mut SecKeychainItem,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainAddInternetPassword(
keychain: Option<&SecKeychain>,
server_name_length: u32,
server_name: *const c_char,
security_domain_length: u32,
security_domain: *const c_char,
account_name_length: u32,
account_name: *const c_char,
path_length: u32,
path: *const c_char,
port: u16,
protocol: SecProtocolType,
authentication_type: SecAuthenticationType,
password_length: u32,
password_data: NonNull<c_void>,
item_ref: *mut *mut SecKeychainItem,
) -> OSStatus;
}
unsafe {
SecKeychainAddInternetPassword(
keychain,
server_name_length,
server_name,
security_domain_length,
security_domain,
account_name_length,
account_name,
path_length,
path,
port,
protocol,
authentication_type,
password_length,
password_data,
item_ref,
)
}
}
/// Finds an Internet password based on the attributes passed.
///
/// Parameter `keychainOrArray`: A reference to an array of keychains to search, a single keychain, or NULL to search the user's default keychain search list.
///
/// Parameter `serverNameLength`: The length of the buffer pointed to by serverName.
///
/// Parameter `serverName`: A pointer to a string containing the server name.
///
/// Parameter `securityDomainLength`: The length of the buffer pointed to by securityDomain.
///
/// Parameter `securityDomain`: A pointer to a string containing the security domain. This parameter is optional, as not all protocols will require it.
///
/// Parameter `accountNameLength`: The length of the buffer pointed to by accountName.
///
/// Parameter `accountName`: A pointer to a string containing the account name.
///
/// Parameter `pathLength`: The length of the buffer pointed to by path.
///
/// Parameter `path`: A pointer to a string containing the path.
///
/// Parameter `port`: The TCP/IP port number. Pass 0 to ignore the port number.
///
/// Parameter `protocol`: The protocol associated with this password. See SecProtocolType for a description of possible values.
///
/// Parameter `authenticationType`: The authentication scheme used. See SecAuthenticationType for a description of possible values. Pass the constant kSecAuthenticationTypeDefault to specify the default authentication scheme.
///
/// Parameter `passwordLength`: On return, the length of the buffer pointed to by passwordData.
///
/// Parameter `passwordData`: On return, a pointer to a data buffer containing the password. Your application must call SecKeychainItemFreeContent(NULL, passwordData) to release this data buffer when it is no longer needed. Pass NULL if you are not interested in retrieving the password data at this time, but simply want to find the item reference.
///
/// Parameter `itemRef`: On return, a reference to the keychain item which was found.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// The SecKeychainFindInternetPassword function finds the first Internet password item which matches the attributes you provide. Most attributes are optional; you should pass only as many as you need to narrow the search sufficiently for your application's intended use. SecKeychainFindInternetPassword optionally returns a reference to the found item.
///
/// # Safety
///
/// - `keychain_or_array` should be of the correct type.
/// - `server_name` must be a valid pointer or null.
/// - `security_domain` must be a valid pointer or null.
/// - `account_name` must be a valid pointer or null.
/// - `path` must be a valid pointer or null.
/// - `password_length` must be a valid pointer or null.
/// - `password_data` must be a valid pointer or null.
/// - `item_ref` must be a valid pointer or null.
#[doc(alias = "SecKeychainFindInternetPassword")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn find_internet_password(
keychain_or_array: Option<&CFType>,
server_name_length: u32,
server_name: *const c_char,
security_domain_length: u32,
security_domain: *const c_char,
account_name_length: u32,
account_name: *const c_char,
path_length: u32,
path: *const c_char,
port: u16,
protocol: SecProtocolType,
authentication_type: SecAuthenticationType,
password_length: *mut u32,
password_data: *mut *mut c_void,
item_ref: *mut *mut SecKeychainItem,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainFindInternetPassword(
keychain_or_array: Option<&CFType>,
server_name_length: u32,
server_name: *const c_char,
security_domain_length: u32,
security_domain: *const c_char,
account_name_length: u32,
account_name: *const c_char,
path_length: u32,
path: *const c_char,
port: u16,
protocol: SecProtocolType,
authentication_type: SecAuthenticationType,
password_length: *mut u32,
password_data: *mut *mut c_void,
item_ref: *mut *mut SecKeychainItem,
) -> OSStatus;
}
unsafe {
SecKeychainFindInternetPassword(
keychain_or_array,
server_name_length,
server_name,
security_domain_length,
security_domain,
account_name_length,
account_name,
path_length,
path,
port,
protocol,
authentication_type,
password_length,
password_data,
item_ref,
)
}
}
/// Adds a generic password to the specified keychain.
///
/// Parameter `keychain`: A reference to the keychain in which to store a generic password. Pass NULL to specify the user's default keychain.
///
/// Parameter `serviceNameLength`: The length of the buffer pointed to by serviceName.
///
/// Parameter `serviceName`: A pointer to a string containing the service name associated with this password.
///
/// Parameter `accountNameLength`: The length of the buffer pointed to by accountName.
///
/// Parameter `accountName`: A pointer to a string containing the account name associated with this password.
///
/// Parameter `passwordLength`: The length of the buffer pointed to by passwordData.
///
/// Parameter `passwordData`: A pointer to a buffer containing the password data to be stored in the keychain.
///
/// Parameter `itemRef`: On return, a reference to the new keychain item.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// The SecKeychainAddGenericPassword function adds a new generic password to the default keychain. Required parameters to identify the password are serviceName and accountName, which are application-defined strings. SecKeychainAddGenericPassword optionally returns a reference to the newly added item.
///
/// # Safety
///
/// - `service_name` must be a valid pointer or null.
/// - `account_name` must be a valid pointer or null.
/// - `password_data` must be a valid pointer.
/// - `item_ref` must be a valid pointer or null.
#[doc(alias = "SecKeychainAddGenericPassword")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn add_generic_password(
keychain: Option<&SecKeychain>,
service_name_length: u32,
service_name: *const c_char,
account_name_length: u32,
account_name: *const c_char,
password_length: u32,
password_data: NonNull<c_void>,
item_ref: *mut *mut SecKeychainItem,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainAddGenericPassword(
keychain: Option<&SecKeychain>,
service_name_length: u32,
service_name: *const c_char,
account_name_length: u32,
account_name: *const c_char,
password_length: u32,
password_data: NonNull<c_void>,
item_ref: *mut *mut SecKeychainItem,
) -> OSStatus;
}
unsafe {
SecKeychainAddGenericPassword(
keychain,
service_name_length,
service_name,
account_name_length,
account_name,
password_length,
password_data,
item_ref,
)
}
}
/// Find a generic password based on the attributes passed.
///
/// Parameter `keychainOrArray`: A reference to an array of keychains to search, a single keychain, or NULL to search the user's default keychain search list.
///
/// Parameter `serviceNameLength`: The length of the buffer pointed to by serviceName.
///
/// Parameter `serviceName`: A pointer to a string containing the service name.
///
/// Parameter `accountNameLength`: The length of the buffer pointed to by accountName.
///
/// Parameter `accountName`: A pointer to a string containing the account name.
///
/// Parameter `passwordLength`: On return, the length of the buffer pointed to by passwordData.
///
/// Parameter `passwordData`: On return, a pointer to a data buffer containing the password. Your application must call SecKeychainItemFreeContent(NULL, passwordData) to release this data buffer when it is no longer needed. Pass NULL if you are not interested in retrieving the password data at this time, but simply want to find the item reference.
///
/// Parameter `itemRef`: On return, a reference to the keychain item which was found.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// The SecKeychainFindGenericPassword function finds the first generic password item which matches the attributes you provide. Most attributes are optional; you should pass only as many as you need to narrow the search sufficiently for your application's intended use. SecKeychainFindGenericPassword optionally returns a reference to the found item.
///
/// # Safety
///
/// - `keychain_or_array` should be of the correct type.
/// - `service_name` must be a valid pointer or null.
/// - `account_name` must be a valid pointer or null.
/// - `password_length` must be a valid pointer or null.
/// - `password_data` must be a valid pointer or null.
/// - `item_ref` must be a valid pointer or null.
#[doc(alias = "SecKeychainFindGenericPassword")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn find_generic_password(
keychain_or_array: Option<&CFType>,
service_name_length: u32,
service_name: *const c_char,
account_name_length: u32,
account_name: *const c_char,
password_length: *mut u32,
password_data: *mut *mut c_void,
item_ref: *mut *mut SecKeychainItem,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainFindGenericPassword(
keychain_or_array: Option<&CFType>,
service_name_length: u32,
service_name: *const c_char,
account_name_length: u32,
account_name: *const c_char,
password_length: *mut u32,
password_data: *mut *mut c_void,
item_ref: *mut *mut SecKeychainItem,
) -> OSStatus;
}
unsafe {
SecKeychainFindGenericPassword(
keychain_or_array,
service_name_length,
service_name,
account_name_length,
account_name,
password_length,
password_data,
item_ref,
)
}
}
/// Turns on or off any optional user interaction
///
/// Parameter `state`: A boolean representing the state of user interaction. You should pass TRUE to allow user interaction, and FALSE to disallow user interaction
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
#[doc(alias = "SecKeychainSetUserInteractionAllowed")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn set_user_interaction_allowed(state: bool) -> OSStatus {
extern "C-unwind" {
fn SecKeychainSetUserInteractionAllowed(state: Boolean) -> OSStatus;
}
unsafe { SecKeychainSetUserInteractionAllowed(state as _) }
}
/// Retrieves the current state of user interaction.
///
/// Parameter `state`: On return, a pointer to the current state of user interaction. If this is TRUE then user interaction is allowed, if it is FALSE, then user interaction is not allowed.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// `state` must be a valid pointer.
#[doc(alias = "SecKeychainGetUserInteractionAllowed")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn user_interaction_allowed(state: NonNull<Boolean>) -> OSStatus {
extern "C-unwind" {
fn SecKeychainGetUserInteractionAllowed(state: NonNull<Boolean>) -> OSStatus;
}
unsafe { SecKeychainGetUserInteractionAllowed(state) }
}
/// Returns the CSSM_CSP_HANDLE attachment for the given keychain reference. The handle is valid until the keychain reference is released.
///
/// Parameter `keychain`: A keychain reference.
///
/// Parameter `cspHandle`: On return, a pointer to the CSSM_CSP_HANDLE for the given keychain.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// This API is deprecated for 10.7. It should nho longer be needed.
///
/// # Safety
///
/// `csp_handle` must be a valid pointer.
#[doc(alias = "SecKeychainGetCSPHandle")]
#[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
#[deprecated]
#[inline]
pub unsafe fn csp_handle(
keychain: Option<&SecKeychain>,
csp_handle: NonNull<CSSM_CSP_HANDLE>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainGetCSPHandle(
keychain: Option<&SecKeychain>,
csp_handle: NonNull<CSSM_CSP_HANDLE>,
) -> OSStatus;
}
unsafe { SecKeychainGetCSPHandle(keychain, csp_handle) }
}
/// Returns the CSSM_DL_DB_HANDLE for a given keychain reference. The handle is valid until the keychain reference is released.
///
/// Parameter `keychain`: A keychain reference.
///
/// Parameter `dldbHandle`: On return, a pointer to the CSSM_DL_DB_HANDLE for the given keychain.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// This API is deprecated for 10.7. It should nho longer be needed.
///
/// # Safety
///
/// `dldb_handle` must be a valid pointer.
#[doc(alias = "SecKeychainGetDLDBHandle")]
#[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
#[deprecated]
#[inline]
pub unsafe fn dldb_handle(
keychain: Option<&SecKeychain>,
dldb_handle: NonNull<CSSM_DL_DB_HANDLE>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainGetDLDBHandle(
keychain: Option<&SecKeychain>,
dldb_handle: NonNull<CSSM_DL_DB_HANDLE>,
) -> OSStatus;
}
unsafe { SecKeychainGetDLDBHandle(keychain, dldb_handle) }
}
/// Retrieves the access for a keychain.
///
/// Parameter `keychain`: A reference to the keychain from which to copy the access.
///
/// Parameter `access`: On return, a pointer to the access reference.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// `access` must be a valid pointer.
#[doc(alias = "SecKeychainCopyAccess")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn copy_access(
keychain: Option<&SecKeychain>,
access: NonNull<*mut SecAccess>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainCopyAccess(
keychain: Option<&SecKeychain>,
access: NonNull<*mut SecAccess>,
) -> OSStatus;
}
unsafe { SecKeychainCopyAccess(keychain, access) }
}
/// Sets the access for a keychain.
///
/// Parameter `keychain`: A reference to the keychain for which to set the access.
///
/// Parameter `access`: An access reference.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
#[doc(alias = "SecKeychainSetAccess")]
#[cfg(feature = "SecBase")]
#[deprecated = "SecKeychain is deprecated"]
#[inline]
pub unsafe fn set_access(keychain: Option<&SecKeychain>, access: &SecAccess) -> OSStatus {
extern "C-unwind" {
fn SecKeychainSetAccess(keychain: Option<&SecKeychain>, access: &SecAccess)
-> OSStatus;
}
unsafe { SecKeychainSetAccess(keychain, access) }
}
}
extern "C-unwind" {
#[deprecated = "renamed to `SecKeychain::version`"]
pub fn SecKeychainGetVersion(return_vers: NonNull<u32>) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::open`"]
pub fn SecKeychainOpen(
path_name: NonNull<c_char>,
keychain: NonNull<*mut SecKeychain>,
) -> OSStatus;
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::create`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeychainCreate(
path_name: NonNull<c_char>,
password_length: u32,
password: *const c_void,
prompt_user: bool,
initial_access: Option<&SecAccess>,
keychain: NonNull<*mut SecKeychain>,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainCreate(
path_name: NonNull<c_char>,
password_length: u32,
password: *const c_void,
prompt_user: Boolean,
initial_access: Option<&SecAccess>,
keychain: NonNull<*mut SecKeychain>,
) -> OSStatus;
}
unsafe {
SecKeychainCreate(
path_name,
password_length,
password,
prompt_user as _,
initial_access,
keychain,
)
}
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::delete`"]
pub fn SecKeychainDelete(keychain_or_array: Option<&SecKeychain>) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::set_settings`"]
pub fn SecKeychainSetSettings(
keychain: Option<&SecKeychain>,
new_settings: NonNull<SecKeychainSettings>,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::copy_settings`"]
pub fn SecKeychainCopySettings(
keychain: Option<&SecKeychain>,
out_settings: NonNull<SecKeychainSettings>,
) -> OSStatus;
}
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::unlock`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeychainUnlock(
keychain: Option<&SecKeychain>,
password_length: u32,
password: *const c_void,
use_password: bool,
) -> OSStatus {
extern "C-unwind" {
fn SecKeychainUnlock(
keychain: Option<&SecKeychain>,
password_length: u32,
password: *const c_void,
use_password: Boolean,
) -> OSStatus;
}
unsafe { SecKeychainUnlock(keychain, password_length, password, use_password as _) }
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::lock`"]
pub fn SecKeychainLock(keychain: Option<&SecKeychain>) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `SecKeychain::lock_all`"]
pub fn SecKeychainLockAll() -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::copy_default`"]
pub fn SecKeychainCopyDefault(keychain: NonNull<*mut SecKeychain>) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::set_default`"]
pub fn SecKeychainSetDefault(keychain: Option<&SecKeychain>) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `SecKeychain::copy_search_list`"]
pub fn SecKeychainCopySearchList(search_list: NonNull<*const CFArray>) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `SecKeychain::set_search_list`"]
pub fn SecKeychainSetSearchList(search_list: &CFArray) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::copy_domain_default`"]
pub fn SecKeychainCopyDomainDefault(
domain: SecPreferencesDomain,
keychain: NonNull<*mut SecKeychain>,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::set_domain_default`"]
pub fn SecKeychainSetDomainDefault(
domain: SecPreferencesDomain,
keychain: Option<&SecKeychain>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `SecKeychain::copy_domain_search_list`"]
pub fn SecKeychainCopyDomainSearchList(
domain: SecPreferencesDomain,
search_list: NonNull<*const CFArray>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `SecKeychain::set_domain_search_list`"]
pub fn SecKeychainSetDomainSearchList(
domain: SecPreferencesDomain,
search_list: &CFArray,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `SecKeychain::set_preference_domain`"]
pub fn SecKeychainSetPreferenceDomain(domain: SecPreferencesDomain) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `SecKeychain::preference_domain`"]
pub fn SecKeychainGetPreferenceDomain(domain: NonNull<SecPreferencesDomain>) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::status`"]
pub fn SecKeychainGetStatus(
keychain: Option<&SecKeychain>,
keychain_status: NonNull<SecKeychainStatus>,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::path`"]
pub fn SecKeychainGetPath(
keychain: Option<&SecKeychain>,
io_path_length: NonNull<u32>,
path_name: NonNull<c_char>,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::attribute_info_for_item_id`"]
pub fn SecKeychainAttributeInfoForItemID(
keychain: Option<&SecKeychain>,
item_id: u32,
info: NonNull<*mut SecKeychainAttributeInfo>,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::free_attribute_info`"]
pub fn SecKeychainFreeAttributeInfo(info: NonNull<SecKeychainAttributeInfo>) -> OSStatus;
}
extern "C-unwind" {
#[cfg(all(feature = "SecBase", feature = "libc"))]
#[deprecated = "renamed to `SecKeychain::add_callback`"]
pub fn SecKeychainAddCallback(
callback_function: SecKeychainCallback,
event_mask: SecKeychainEventMask,
user_context: *mut c_void,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(all(feature = "SecBase", feature = "libc"))]
#[deprecated = "renamed to `SecKeychain::remove_callback`"]
pub fn SecKeychainRemoveCallback(callback_function: SecKeychainCallback) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::add_internet_password`"]
pub fn SecKeychainAddInternetPassword(
keychain: Option<&SecKeychain>,
server_name_length: u32,
server_name: *const c_char,
security_domain_length: u32,
security_domain: *const c_char,
account_name_length: u32,
account_name: *const c_char,
path_length: u32,
path: *const c_char,
port: u16,
protocol: SecProtocolType,
authentication_type: SecAuthenticationType,
password_length: u32,
password_data: NonNull<c_void>,
item_ref: *mut *mut SecKeychainItem,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::find_internet_password`"]
pub fn SecKeychainFindInternetPassword(
keychain_or_array: Option<&CFType>,
server_name_length: u32,
server_name: *const c_char,
security_domain_length: u32,
security_domain: *const c_char,
account_name_length: u32,
account_name: *const c_char,
path_length: u32,
path: *const c_char,
port: u16,
protocol: SecProtocolType,
authentication_type: SecAuthenticationType,
password_length: *mut u32,
password_data: *mut *mut c_void,
item_ref: *mut *mut SecKeychainItem,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::add_generic_password`"]
pub fn SecKeychainAddGenericPassword(
keychain: Option<&SecKeychain>,
service_name_length: u32,
service_name: *const c_char,
account_name_length: u32,
account_name: *const c_char,
password_length: u32,
password_data: NonNull<c_void>,
item_ref: *mut *mut SecKeychainItem,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::find_generic_password`"]
pub fn SecKeychainFindGenericPassword(
keychain_or_array: Option<&CFType>,
service_name_length: u32,
service_name: *const c_char,
account_name_length: u32,
account_name: *const c_char,
password_length: *mut u32,
password_data: *mut *mut c_void,
item_ref: *mut *mut SecKeychainItem,
) -> OSStatus;
}
#[deprecated = "renamed to `SecKeychain::set_user_interaction_allowed`"]
#[inline]
pub unsafe extern "C-unwind" fn SecKeychainSetUserInteractionAllowed(state: bool) -> OSStatus {
extern "C-unwind" {
fn SecKeychainSetUserInteractionAllowed(state: Boolean) -> OSStatus;
}
unsafe { SecKeychainSetUserInteractionAllowed(state as _) }
}
extern "C-unwind" {
#[deprecated = "renamed to `SecKeychain::user_interaction_allowed`"]
pub fn SecKeychainGetUserInteractionAllowed(state: NonNull<Boolean>) -> OSStatus;
}
extern "C-unwind" {
#[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
#[deprecated = "renamed to `SecKeychain::csp_handle`"]
pub fn SecKeychainGetCSPHandle(
keychain: Option<&SecKeychain>,
csp_handle: NonNull<CSSM_CSP_HANDLE>,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
#[deprecated = "renamed to `SecKeychain::dldb_handle`"]
pub fn SecKeychainGetDLDBHandle(
keychain: Option<&SecKeychain>,
dldb_handle: NonNull<CSSM_DL_DB_HANDLE>,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::copy_access`"]
pub fn SecKeychainCopyAccess(
keychain: Option<&SecKeychain>,
access: NonNull<*mut SecAccess>,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `SecKeychain::set_access`"]
pub fn SecKeychainSetAccess(keychain: Option<&SecKeychain>, access: &SecAccess) -> OSStatus;
}