5 // Created by Mitch Adler on 7/19/12.
9 #ifndef _SOSPEERINFO_H_
10 #define _SOSPEERINFO_H_
12 #include <CoreFoundation/CoreFoundation.h>
13 #include <Security/SecKey.h>
14 #include <CommonCrypto/CommonDigestSPI.h>
15 #include <corecrypto/ccdigest.h>
20 typedef struct __OpaqueSOSPeerInfo
*SOSPeerInfoRef
;
28 SOSPeerCmpPubKeyHash
= 0,
31 typedef uint32_t SOSPeerInfoCmpSelect
;
33 SOSPeerInfoRef
SOSPeerInfoCreate(CFAllocatorRef allocator
, CFDictionaryRef gestalt
, SecKeyRef signingKey
, CFErrorRef
* error
);
35 SOSPeerInfoRef
SOSPeerInfoCreateCloudIdentity(CFAllocatorRef allocator
, CFDictionaryRef gestalt
, SecKeyRef signingKey
, CFErrorRef
* error
);
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
);
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
);
47 bool SOSPeerInfoApplicationVerify(SOSPeerInfoRef pi
, SecKeyRef userkey
, CFErrorRef
*error
);
49 CF_RETURNS_RETAINED CFDateRef
SOSPeerInfoGetApplicationDate(SOSPeerInfoRef pi
);
54 SOSPeerInfoRef
SOSPeerInfoCreateFromDER(CFAllocatorRef allocator
, CFErrorRef
* error
,
55 const uint8_t** der_p
, const uint8_t *der_end
);
57 SOSPeerInfoRef
SOSPeerInfoCreateFromData(CFAllocatorRef allocator
, CFErrorRef
* error
,
58 CFDataRef peerinfo_data
);
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
);
64 CFDataRef
SOSPeerInfoCopyEncodedData(SOSPeerInfoRef peer
, CFAllocatorRef allocator
, CFErrorRef
*error
);
67 // Gestalt info about the peer. It was fetched by the implementation on the other side.
68 // probably has what you're looking for..
70 CFTypeRef
SOSPeerInfoLookupGestaltValue(SOSPeerInfoRef pi
, CFStringRef key
);
71 CFDictionaryRef
SOSPeerInfoCopyPeerGestalt(SOSPeerInfoRef pi
);
74 // Syntactic Sugar for some commone ones, might get deprectated at this level.
76 CFStringRef
SOSPeerInfoGetPeerName(SOSPeerInfoRef peer
);
77 CFStringRef
SOSPeerInfoGetPeerDeviceType(SOSPeerInfoRef peer
);
80 // Stringified ID for this peer, not human readable.
81 CFStringRef
SOSPeerInfoGetPeerID(SOSPeerInfoRef peer
);
83 CFIndex
SOSPeerInfoGetVersion(SOSPeerInfoRef peer
);
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
);
96 CFArrayRef
CreateArrayOfPeerInfoWithXPCObject(xpc_object_t peerArray
, CFErrorRef
* error
);
97 xpc_object_t
CreateXPCObjectWithArrayOfPeerInfo(CFArrayRef array
, CFErrorRef
*error
);
100 // Peer Info Gestalt Helpers
102 CFStringRef
SOSPeerGestaltGetName(CFDictionaryRef gestalt
);
104 // These are Mobile Gestalt questions. Not all Gestalt questions are carried.
105 CFTypeRef
SOSPeerGestaltGetAnswer(CFDictionaryRef gestalt
, CFStringRef question
);
107 SecKeyRef
SOSPeerInfoCopyPubKey(SOSPeerInfoRef peer
);
109 CFComparisonResult
SOSPeerInfoCompareByID(const void *val1
, const void *val2
, void *context
);
111 SOSPeerInfoRef
SOSPeerInfoCreateRetirementTicket(CFAllocatorRef allocator
, SecKeyRef privKey
, SOSPeerInfoRef peer
, CFErrorRef
*error
);
113 CFStringRef
SOSPeerInfoInspectRetirementTicket(SOSPeerInfoRef pi
, CFErrorRef
*error
);
115 bool SOSPeerInfoRetireRetirementTicket(size_t max_days
, SOSPeerInfoRef pi
);
117 CF_RETURNS_RETAINED CFDateRef
SOSPeerInfoGetRetirementDate(SOSPeerInfoRef pi
);
119 bool SOSPeerInfoIsRetirementTicket(SOSPeerInfoRef pi
);
121 bool SOSPeerInfoIsCloudIdentity(SOSPeerInfoRef pi
);
123 SOSPeerInfoRef
SOSPeerInfoUpgradeSignatures(CFAllocatorRef allocator
, SecKeyRef privKey
, SecKeyRef perKey
, SOSPeerInfoRef peer
, CFErrorRef
*error
);