]> git.saurik.com Git - apple/security.git/blob - Security/sec/SOSCircle/SecureObjectSync/SOSPeerInfo.h
Security-57031.10.10.tar.gz
[apple/security.git] / Security / sec / SOSCircle / SecureObjectSync / SOSPeerInfo.h
1 /*
2 * Copyright (c) 2012-2014 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25 #ifndef _SOSPEERINFO_H_
26 #define _SOSPEERINFO_H_
27
28 #include <CoreFoundation/CoreFoundation.h>
29 #include <Security/SecKey.h>
30 #include <CommonCrypto/CommonDigestSPI.h>
31 #include <corecrypto/ccdigest.h>
32
33 __BEGIN_DECLS
34
35 typedef struct __OpaqueSOSPeerInfo *SOSPeerInfoRef;
36
37 enum {
38 kSOSPeerVersion = 2,
39 };
40
41
42 enum {
43 SOSPeerCmpPubKeyHash = 0,
44 SOSPeerCmpName = 1,
45 };
46 typedef uint32_t SOSPeerInfoCmpSelect;
47
48 CFTypeID SOSPeerInfoGetTypeID(void);
49
50 static inline bool isSOSPeerInfo(CFTypeRef obj) {
51 return obj && (CFGetTypeID(obj) == SOSPeerInfoGetTypeID());
52 }
53
54 SOSPeerInfoRef SOSPeerInfoCreate(CFAllocatorRef allocator, CFDictionaryRef gestalt, SecKeyRef signingKey, CFErrorRef* error);
55
56 SOSPeerInfoRef SOSPeerInfoCreateCloudIdentity(CFAllocatorRef allocator, CFDictionaryRef gestalt, SecKeyRef signingKey, CFErrorRef* error);
57
58 SOSPeerInfoRef SOSPeerInfoCreateCopy(CFAllocatorRef allocator, SOSPeerInfoRef toCopy, CFErrorRef* error);
59 SOSPeerInfoRef SOSPeerInfoCopyWithGestaltUpdate(CFAllocatorRef allocator, SOSPeerInfoRef toCopy, CFDictionaryRef gestalt, SecKeyRef signingKey, CFErrorRef* error);
60 SOSPeerInfoRef SOSPeerInfoCopyAsApplication(SOSPeerInfoRef pi, SecKeyRef userkey, SecKeyRef peerkey, CFErrorRef *error);
61
62 bool SOSPeerInfoUpdateDigestWithPublicKeyBytes(SOSPeerInfoRef peer, const struct ccdigest_info *di,
63 ccdigest_ctx_t ctx, CFErrorRef *error);
64 bool SOSPeerInfoUpdateDigestWithDescription(SOSPeerInfoRef peer, const struct ccdigest_info *di,
65 ccdigest_ctx_t ctx, CFErrorRef *error);
66
67
68 bool SOSPeerInfoApplicationVerify(SOSPeerInfoRef pi, SecKeyRef userkey, CFErrorRef *error);
69
70 CF_RETURNS_RETAINED CFDateRef SOSPeerInfoGetApplicationDate(SOSPeerInfoRef pi);
71
72 //
73 // DER Import Export
74 //
75 SOSPeerInfoRef SOSPeerInfoCreateFromDER(CFAllocatorRef allocator, CFErrorRef* error,
76 const uint8_t** der_p, const uint8_t *der_end);
77
78 SOSPeerInfoRef SOSPeerInfoCreateFromData(CFAllocatorRef allocator, CFErrorRef* error,
79 CFDataRef peerinfo_data);
80
81 size_t SOSPeerInfoGetDEREncodedSize(SOSPeerInfoRef peer, CFErrorRef *error);
82 uint8_t* SOSPeerInfoEncodeToDER(SOSPeerInfoRef peer, CFErrorRef* error,
83 const uint8_t* der, uint8_t* der_end);
84
85 CFDataRef SOSPeerInfoCopyEncodedData(SOSPeerInfoRef peer, CFAllocatorRef allocator, CFErrorRef *error);
86
87 //
88 // Gestalt info about the peer. It was fetched by the implementation on the other side.
89 // probably has what you're looking for..
90 //
91 CFTypeRef SOSPeerInfoLookupGestaltValue(SOSPeerInfoRef pi, CFStringRef key);
92 CFDictionaryRef SOSPeerInfoCopyPeerGestalt(SOSPeerInfoRef pi);
93
94 //
95 // Syntactic Sugar for some commone ones, might get deprectated at this level.
96 //
97 CFStringRef SOSPeerInfoGetTransportType(SOSPeerInfoRef peer);
98 CFStringRef SOSPeerInfoGetPeerName(SOSPeerInfoRef peer);
99 CFStringRef SOSPeerInfoGetPeerDeviceType(SOSPeerInfoRef peer);
100 CFIndex SOSPeerInfoGetPeerProtocolVersion(SOSPeerInfoRef peer);
101
102 // IDSs device ID
103 CFStringRef SOSPeerInfoGetDeviceID(SOSPeerInfoRef peer);
104 void SOSPeerInfoSetDeviceID(SOSPeerInfoRef peer, CFStringRef IDS);
105
106 // Stringified ID for this peer, not human readable.
107 CFStringRef SOSPeerInfoGetPeerID(SOSPeerInfoRef peer);
108
109 CFIndex SOSPeerInfoGetVersion(SOSPeerInfoRef peer);
110
111 //
112 // Peer Info Gestalt Helpers
113 //
114 CFStringRef SOSPeerGestaltGetName(CFDictionaryRef gestalt);
115
116 // These are Mobile Gestalt questions. Not all Gestalt questions are carried.
117 CFTypeRef SOSPeerGestaltGetAnswer(CFDictionaryRef gestalt, CFStringRef question);
118
119 SecKeyRef SOSPeerInfoCopyPubKey(SOSPeerInfoRef peer);
120
121 CFComparisonResult SOSPeerInfoCompareByID(const void *val1, const void *val2, void *context);
122
123 SOSPeerInfoRef SOSPeerInfoCreateRetirementTicket(CFAllocatorRef allocator, SecKeyRef privKey, SOSPeerInfoRef peer, CFErrorRef *error);
124
125 CFStringRef SOSPeerInfoInspectRetirementTicket(SOSPeerInfoRef pi, CFErrorRef *error);
126
127 bool SOSPeerInfoRetireRetirementTicket(size_t max_days, SOSPeerInfoRef pi);
128
129 CF_RETURNS_RETAINED CFDateRef SOSPeerInfoGetRetirementDate(SOSPeerInfoRef pi);
130
131 bool SOSPeerInfoIsRetirementTicket(SOSPeerInfoRef pi);
132
133 bool SOSPeerInfoIsCloudIdentity(SOSPeerInfoRef pi);
134
135 SOSPeerInfoRef SOSPeerInfoUpgradeSignatures(CFAllocatorRef allocator, SecKeyRef privKey, SecKeyRef perKey, SOSPeerInfoRef peer, CFErrorRef *error);
136
137 __END_DECLS
138
139 #endif