CFStringRef kSOSHsaCrKeyDictionary = CFSTR("HSADictionary");
CFStringRef sRingState = CFSTR("RingState");
CFStringRef sBackupKeyKey = CFSTR("BackupKey");
+CFStringRef sEscrowRecord = CFSTR("EscrowRecord");
#if TARGET_OS_IPHONE
CFReleaseNull(serialNumber);
}
+const CFStringRef SOSSerialUnknown = CFSTR("Unknown");
+
+CFStringRef SOSPeerInfoCopySerialNumber(SOSPeerInfoRef pi) {
+ CFStringRef retval = SOSPeerInfoV2DictionaryCopyString(pi, sSerialNumberKey);
+ return (retval ? retval : CFRetain(SOSSerialUnknown));
+}
+
static bool SOSPeerInfoV2SanityCheck(SOSPeerInfoRef pi) {
if(!pi) {
return false;
static CFDataRef SOSPeerInfoGetV2Data(SOSPeerInfoRef pi) {
if(SOSPeerInfoV2SanityCheck(pi) == false) return NULL;
- return CFDictionaryGetValue(pi->description, sV2DictionaryKey);
+ return asData(CFDictionaryGetValue(pi->description, sV2DictionaryKey), NULL);
}
static CFMutableDictionaryRef SOSCreateDictionaryFromDER(CFDataRef v2Data, CFErrorRef *error) {
if(serialNumber == NULL) {
secnotice("signing", "serialNumber was returned NULL\n");
}
- CFMutableSetRef views = SOSViewsCreateDefault(false, error);
+ CFMutableSetRef views = SOSViewCopyViewSet(kViewSetDefault);
CFMutableSetRef secproperties = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks);
if(serialNumber) CFDictionaryAddValue(v2Dictionary, sSerialNumberKey, serialNumber);
CFDictionaryAddValue(v2Dictionary, sViewsKey, views);
CFDictionaryAddValue(v2Dictionary, sSecurityPropertiesKey, secproperties);
- if(whichTransportType == kSOSTransportPresent){
- CFDictionaryAddValue(v2Dictionary, sDeviceID, CFSTR(""));
- CFDictionaryAddValue(v2Dictionary, sTransportType, SOSTransportMessageTypeKVS);
- CFDictionaryAddValue(v2Dictionary, sPreferIDS, kCFBooleanTrue);
- }
- else if (whichTransportType == kSOSTransportFuture || whichTransportType == kSOSTransportIDS){
- CFDictionaryAddValue(v2Dictionary, sDeviceID, CFSTR(""));
- CFDictionaryAddValue(v2Dictionary, sTransportType, SOSTransportMessageTypeIDS);
- CFDictionaryAddValue(v2Dictionary, sPreferIDS, kCFBooleanTrue);
- }
+
+ CFDictionaryAddValue(v2Dictionary, sDeviceID, CFSTR(""));
+ CFDictionaryAddValue(v2Dictionary, sTransportType, SOSTransportMessageTypeIDSV2);
+ CFDictionaryAddValue(v2Dictionary, sPreferIDS, kCFBooleanFalse);
+ CFDictionaryAddValue(v2Dictionary, sPreferIDSFragmentation, kCFBooleanTrue);
+
require_action_quiet((v2data = SOSCreateDERFromDictionary(v2Dictionary, error)), out, SOSCreateError(kSOSErrorAllocationFailure, CFSTR("No Memory"), NULL, error));
CFDictionaryAddValue(pi->description, sV2DictionaryKey, v2data);
SOSPeerInfoExpandV2Data(pi, error);
return NULL;
}
+const CFMutableDictionaryRef SOSPeerInfoV2DictionaryCopyDictionary(SOSPeerInfoRef pi, const void *key) {
+ require_quiet(SOSPeerInfoExpandV2Data(pi, NULL), errOut);
+ CFDictionaryRef value = asDictionary(CFDictionaryGetValue(pi->v2Dictionary, key), NULL);
+ if(value != NULL)
+ return CFDictionaryCreateMutableCopy(kCFAllocatorDefault, CFDictionaryGetCount(value), value);
+errOut:
+ return NULL;
+}