2 * Copyright (c) 2012-2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
25 #ifndef _SOSPEERINFO_H_
26 #define _SOSPEERINFO_H_
28 #include <CoreFoundation/CoreFoundation.h>
29 #include <Security/SecKey.h>
30 #include <CommonCrypto/CommonDigestSPI.h>
31 #include <corecrypto/ccdigest.h>
35 typedef struct __OpaqueSOSPeerInfo
*SOSPeerInfoRef
;
43 SOSPeerCmpPubKeyHash
= 0,
46 typedef uint32_t SOSPeerInfoCmpSelect
;
48 CFTypeID
SOSPeerInfoGetTypeID(void);
50 static inline bool isSOSPeerInfo(CFTypeRef obj
) {
51 return obj
&& (CFGetTypeID(obj
) == SOSPeerInfoGetTypeID());
54 SOSPeerInfoRef
SOSPeerInfoCreate(CFAllocatorRef allocator
, CFDictionaryRef gestalt
, SecKeyRef signingKey
, CFErrorRef
* error
);
56 SOSPeerInfoRef
SOSPeerInfoCreateCloudIdentity(CFAllocatorRef allocator
, CFDictionaryRef gestalt
, SecKeyRef signingKey
, CFErrorRef
* error
);
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
);
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
);
68 bool SOSPeerInfoApplicationVerify(SOSPeerInfoRef pi
, SecKeyRef userkey
, CFErrorRef
*error
);
70 CF_RETURNS_RETAINED CFDateRef
SOSPeerInfoGetApplicationDate(SOSPeerInfoRef pi
);
75 SOSPeerInfoRef
SOSPeerInfoCreateFromDER(CFAllocatorRef allocator
, CFErrorRef
* error
,
76 const uint8_t** der_p
, const uint8_t *der_end
);
78 SOSPeerInfoRef
SOSPeerInfoCreateFromData(CFAllocatorRef allocator
, CFErrorRef
* error
,
79 CFDataRef peerinfo_data
);
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
);
85 CFDataRef
SOSPeerInfoCopyEncodedData(SOSPeerInfoRef peer
, CFAllocatorRef allocator
, CFErrorRef
*error
);
88 // Gestalt info about the peer. It was fetched by the implementation on the other side.
89 // probably has what you're looking for..
91 CFTypeRef
SOSPeerInfoLookupGestaltValue(SOSPeerInfoRef pi
, CFStringRef key
);
92 CFDictionaryRef
SOSPeerInfoCopyPeerGestalt(SOSPeerInfoRef pi
);
95 // Syntactic Sugar for some commone ones, might get deprectated at this level.
97 CFStringRef
SOSPeerInfoGetTransportType(SOSPeerInfoRef peer
);
98 CFStringRef
SOSPeerInfoGetPeerName(SOSPeerInfoRef peer
);
99 CFStringRef
SOSPeerInfoGetPeerDeviceType(SOSPeerInfoRef peer
);
100 CFIndex
SOSPeerInfoGetPeerProtocolVersion(SOSPeerInfoRef peer
);
103 CFStringRef
SOSPeerInfoGetDeviceID(SOSPeerInfoRef peer
);
104 void SOSPeerInfoSetDeviceID(SOSPeerInfoRef peer
, CFStringRef IDS
);
106 // Stringified ID for this peer, not human readable.
107 CFStringRef
SOSPeerInfoGetPeerID(SOSPeerInfoRef peer
);
109 CFIndex
SOSPeerInfoGetVersion(SOSPeerInfoRef peer
);
112 // Peer Info Gestalt Helpers
114 CFStringRef
SOSPeerGestaltGetName(CFDictionaryRef gestalt
);
116 // These are Mobile Gestalt questions. Not all Gestalt questions are carried.
117 CFTypeRef
SOSPeerGestaltGetAnswer(CFDictionaryRef gestalt
, CFStringRef question
);
119 SecKeyRef
SOSPeerInfoCopyPubKey(SOSPeerInfoRef peer
);
121 CFComparisonResult
SOSPeerInfoCompareByID(const void *val1
, const void *val2
, void *context
);
123 SOSPeerInfoRef
SOSPeerInfoCreateRetirementTicket(CFAllocatorRef allocator
, SecKeyRef privKey
, SOSPeerInfoRef peer
, CFErrorRef
*error
);
125 CFStringRef
SOSPeerInfoInspectRetirementTicket(SOSPeerInfoRef pi
, CFErrorRef
*error
);
127 bool SOSPeerInfoRetireRetirementTicket(size_t max_days
, SOSPeerInfoRef pi
);
129 CF_RETURNS_RETAINED CFDateRef
SOSPeerInfoGetRetirementDate(SOSPeerInfoRef pi
);
131 bool SOSPeerInfoIsRetirementTicket(SOSPeerInfoRef pi
);
133 bool SOSPeerInfoIsCloudIdentity(SOSPeerInfoRef pi
);
135 SOSPeerInfoRef
SOSPeerInfoUpgradeSignatures(CFAllocatorRef allocator
, SecKeyRef privKey
, SecKeyRef perKey
, SOSPeerInfoRef peer
, CFErrorRef
*error
);