]> git.saurik.com Git - apple/security.git/blob - sec/SOSCircle/SecureObjectSync/SOSPeerInfo.h
Security-55471.14.8.tar.gz
[apple/security.git] / sec / SOSCircle / SecureObjectSync / SOSPeerInfo.h
1 //
2 // SOSPeerInfo.h
3 // sec
4 //
5 // Created by Mitch Adler on 7/19/12.
6 //
7 //
8
9 #ifndef _SOSPEERINFO_H_
10 #define _SOSPEERINFO_H_
11
12 #include <CoreFoundation/CoreFoundation.h>
13 #include <Security/SecKey.h>
14 #include <CommonCrypto/CommonDigestSPI.h>
15 #include <corecrypto/ccdigest.h>
16 #include <xpc/xpc.h>
17
18 __BEGIN_DECLS
19
20 typedef struct __OpaqueSOSPeerInfo *SOSPeerInfoRef;
21
22 enum {
23 kSOSPeerVersion = 1,
24 };
25
26
27 enum {
28 SOSPeerCmpPubKeyHash = 0,
29 SOSPeerCmpName = 1,
30 };
31 typedef uint32_t SOSPeerInfoCmpSelect;
32
33 SOSPeerInfoRef SOSPeerInfoCreate(CFAllocatorRef allocator, CFDictionaryRef gestalt, SecKeyRef signingKey, CFErrorRef* error);
34
35 SOSPeerInfoRef SOSPeerInfoCreateCloudIdentity(CFAllocatorRef allocator, CFDictionaryRef gestalt, SecKeyRef signingKey, CFErrorRef* error);
36
37 SOSPeerInfoRef SOSPeerInfoCreateCopy(CFAllocatorRef allocator, SOSPeerInfoRef toCopy, CFErrorRef* error);
38 SOSPeerInfoRef SOSPeerInfoCopyWithGestaltUpdate(CFAllocatorRef allocator, SOSPeerInfoRef toCopy, CFDictionaryRef gestalt, SecKeyRef signingKey, CFErrorRef* error);
39 SOSPeerInfoRef SOSPeerInfoCopyAsApplication(SOSPeerInfoRef pi, SecKeyRef userkey, SecKeyRef peerkey, CFErrorRef *error);
40
41 bool SOSPeerInfoUpdateDigestWithPublicKeyBytes(SOSPeerInfoRef peer, const struct ccdigest_info *di,
42 ccdigest_ctx_t ctx, CFErrorRef *error);
43 bool SOSPeerInfoUpdateDigestWithDescription(SOSPeerInfoRef peer, const struct ccdigest_info *di,
44 ccdigest_ctx_t ctx, CFErrorRef *error);
45
46
47 bool SOSPeerInfoApplicationVerify(SOSPeerInfoRef pi, SecKeyRef userkey, CFErrorRef *error);
48
49 CF_RETURNS_RETAINED CFDateRef SOSPeerInfoGetApplicationDate(SOSPeerInfoRef pi);
50
51 //
52 // DER Import Export
53 //
54 SOSPeerInfoRef SOSPeerInfoCreateFromDER(CFAllocatorRef allocator, CFErrorRef* error,
55 const uint8_t** der_p, const uint8_t *der_end);
56
57 SOSPeerInfoRef SOSPeerInfoCreateFromData(CFAllocatorRef allocator, CFErrorRef* error,
58 CFDataRef peerinfo_data);
59
60 size_t SOSPeerInfoGetDEREncodedSize(SOSPeerInfoRef peer, CFErrorRef *error);
61 uint8_t* SOSPeerInfoEncodeToDER(SOSPeerInfoRef peer, CFErrorRef* error,
62 const uint8_t* der, uint8_t* der_end);
63
64 CFDataRef SOSPeerInfoCopyEncodedData(SOSPeerInfoRef peer, CFAllocatorRef allocator, CFErrorRef *error);
65
66 //
67 // Gestalt info about the peer. It was fetched by the implementation on the other side.
68 // probably has what you're looking for..
69 //
70 CFTypeRef SOSPeerInfoLookupGestaltValue(SOSPeerInfoRef pi, CFStringRef key);
71 CFDictionaryRef SOSPeerInfoCopyPeerGestalt(SOSPeerInfoRef pi);
72
73 //
74 // Syntactic Sugar for some commone ones, might get deprectated at this level.
75 //
76 CFStringRef SOSPeerInfoGetPeerName(SOSPeerInfoRef peer);
77 CFStringRef SOSPeerInfoGetPeerDeviceType(SOSPeerInfoRef peer);
78
79
80 // Stringified ID for this peer, not human readable.
81 CFStringRef SOSPeerInfoGetPeerID(SOSPeerInfoRef peer);
82
83 CFIndex SOSPeerInfoGetVersion(SOSPeerInfoRef peer);
84
85
86
87 //
88 // Peer Info Arrays
89 //
90
91 CFMutableArrayRef SOSPeerInfoArrayCreateFromDER(CFAllocatorRef allocator, CFErrorRef* error,
92 const uint8_t** der_p, const uint8_t *der_end);
93 size_t SOSPeerInfoArrayGetDEREncodedSize(CFArrayRef pia, CFErrorRef *error);
94 uint8_t* SOSPeerInfoArrayEncodeToDER(CFArrayRef pia, CFErrorRef* error, const uint8_t* der, uint8_t* der_end);
95
96 CFArrayRef CreateArrayOfPeerInfoWithXPCObject(xpc_object_t peerArray, CFErrorRef* error);
97 xpc_object_t CreateXPCObjectWithArrayOfPeerInfo(CFArrayRef array, CFErrorRef *error);
98
99 //
100 // Peer Info Gestalt Helpers
101 //
102 CFStringRef SOSPeerGestaltGetName(CFDictionaryRef gestalt);
103
104 // These are Mobile Gestalt questions. Not all Gestalt questions are carried.
105 CFTypeRef SOSPeerGestaltGetAnswer(CFDictionaryRef gestalt, CFStringRef question);
106
107 SecKeyRef SOSPeerInfoCopyPubKey(SOSPeerInfoRef peer);
108
109 CFComparisonResult SOSPeerInfoCompareByID(const void *val1, const void *val2, void *context);
110
111 SOSPeerInfoRef SOSPeerInfoCreateRetirementTicket(CFAllocatorRef allocator, SecKeyRef privKey, SOSPeerInfoRef peer, CFErrorRef *error);
112
113 CFStringRef SOSPeerInfoInspectRetirementTicket(SOSPeerInfoRef pi, CFErrorRef *error);
114
115 bool SOSPeerInfoRetireRetirementTicket(size_t max_days, SOSPeerInfoRef pi);
116
117 CF_RETURNS_RETAINED CFDateRef SOSPeerInfoGetRetirementDate(SOSPeerInfoRef pi);
118
119 bool SOSPeerInfoIsRetirementTicket(SOSPeerInfoRef pi);
120
121 bool SOSPeerInfoIsCloudIdentity(SOSPeerInfoRef pi);
122
123 SOSPeerInfoRef SOSPeerInfoUpgradeSignatures(CFAllocatorRef allocator, SecKeyRef privKey, SecKeyRef perKey, SOSPeerInfoRef peer, CFErrorRef *error);
124
125 __END_DECLS
126
127 #endif