X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/5c19dc3ae3bd8e40a9c028b0deddd50ff337692c..3a7be6fd655a5b07ffb821947ed6ba5fdc4bea8c:/OSX/sec/SOSCircle/SecureObjectSync/SOSPeerInfoV2.c diff --git a/OSX/sec/SOSCircle/SecureObjectSync/SOSPeerInfoV2.c b/OSX/sec/SOSCircle/SecureObjectSync/SOSPeerInfoV2.c index 6cb35253..d48a7b91 100644 --- a/OSX/sec/SOSCircle/SecureObjectSync/SOSPeerInfoV2.c +++ b/OSX/sec/SOSCircle/SecureObjectSync/SOSPeerInfoV2.c @@ -26,6 +26,7 @@ CFStringRef sSecurityPropertiesKey = CFSTR("SecurityProperties"); CFStringRef kSOSHsaCrKeyDictionary = CFSTR("HSADictionary"); CFStringRef sRingState = CFSTR("RingState"); CFStringRef sBackupKeyKey = CFSTR("BackupKey"); +CFStringRef sEscrowRecord = CFSTR("EscrowRecord"); #if TARGET_OS_IPHONE @@ -75,6 +76,13 @@ void SOSPeerInfoSetSerialNumber(SOSPeerInfoRef pi) { 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; @@ -87,7 +95,7 @@ static bool SOSPeerInfoV2SanityCheck(SOSPeerInfoRef pi) { 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) { @@ -152,21 +160,17 @@ bool SOSPeerInfoUpdateToV2(SOSPeerInfoRef pi, 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); @@ -335,3 +339,11 @@ errOut: 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; +}