]> git.saurik.com Git - apple/security.git/blob - OSX/sec/SOSCircle/SecureObjectSync/SOSTransportKeyParameter.c
Security-57336.1.9.tar.gz
[apple/security.git] / OSX / sec / SOSCircle / SecureObjectSync / SOSTransportKeyParameter.c
1
2 #include <Security/SecureObjectSync/SOSAccount.h>
3 #include <Security/SecureObjectSync/SOSTransport.h>
4 #include <Security/SecureObjectSync/SOSTransportKeyParameter.h>
5 #include <Security/SecureObjectSync/SOSKVSKeys.h>
6
7 #include <utilities/SecCFWrappers.h>
8 #include <Security/SecureObjectSync/SOSAccountPriv.h>
9 #include <SOSCloudKeychainClient.h>
10
11 CFGiblisWithCompareFor(SOSTransportKeyParameter);
12
13 SOSTransportKeyParameterRef SOSTransportKeyParameterCreateForSubclass(size_t size, SOSAccountRef account, CFErrorRef *error)
14 {
15 SOSTransportKeyParameterRef tpt = CFTypeAllocateWithSpace(SOSTransportKeyParameter, size, kCFAllocatorDefault);
16 tpt->account = CFRetainSafe(account);
17 return tpt;
18 }
19
20 bool SOSTransportKeyParameterHandleNewAccount(SOSTransportKeyParameterRef transport, SOSAccountRef account){
21 return transport->setToNewAccount(transport, account);
22 }
23
24 static CFStringRef SOSTransportKeyParameterCopyFormatDescription(CFTypeRef aObj, CFDictionaryRef formatOptions) {
25 SOSTransportKeyParameterRef t = (SOSTransportKeyParameterRef) aObj;
26
27 return CFStringCreateWithFormat(NULL, NULL, CFSTR("<SOSTransportKeyParameter@%p\n>"), t);
28 }
29
30 static void SOSTransportKeyParameterDestroy(CFTypeRef aObj) {
31 SOSTransportKeyParameterRef transport = (SOSTransportKeyParameterRef) aObj;
32
33 if(transport->destroy)
34 transport->destroy(transport);
35
36 CFReleaseNull(transport->account);
37
38 }
39
40 bool SOSTransportKeyParameterHandleKeyParameterChanges(SOSTransportKeyParameterRef transport, CFDataRef data, CFErrorRef error){
41 return transport->handleKeyParameterChanges(transport, data, error);
42 }
43
44
45 static CFHashCode SOSTransportKeyParameterHash(CFTypeRef obj)
46 {
47 return (intptr_t) obj;
48 }
49
50 static Boolean SOSTransportKeyParameterCompare(CFTypeRef lhs, CFTypeRef rhs)
51 {
52 return SOSTransportKeyParameterHash(lhs) == SOSTransportKeyParameterHash(rhs);
53 }
54
55
56 bool SOSTransportKeyParameterPublishCloudParameters(SOSTransportKeyParameterRef transport, CFDataRef data, CFErrorRef* error) {
57 return transport->publishCloudParameters(transport, data, error);
58 }
59
60 SOSAccountRef SOSTransportKeyParameterGetAccount(SOSTransportKeyParameterRef transport){
61 return transport->account;
62 }
63
64
65 CFIndex SOSTransportKeyParameterGetTransportType(SOSTransportKeyParameterRef transport, CFErrorRef *error){
66 return transport->getTransportType ? transport->getTransportType(transport, error) : kUnknown;
67 }