]>
Commit | Line | Data |
---|---|---|
427c49bc A |
1 | // |
2 | // SOSInternal.h | |
3 | // sec | |
4 | // | |
5 | // Created by Mitch Adler on 7/18/12. | |
6 | // | |
7 | // | |
8 | ||
9 | #ifndef _SOSINTERNAL_H_ | |
10 | #define _SOSINTERNAL_H_ | |
11 | ||
12 | #include <CoreFoundation/CoreFoundation.h> | |
13 | ||
14 | #include <Security/SecKey.h> | |
15 | ||
16 | #include <SecureObjectSync/SOSCloudCircle.h> | |
17 | ||
18 | #include <utilities/SecCFWrappers.h> | |
19 | ||
20 | __BEGIN_DECLS | |
21 | ||
22 | enum { | |
23 | // Public errors are first (See SOSCloudCircle) | |
24 | ||
25 | kSOSErrorFirstPrivateError = 1024, | |
26 | ||
27 | kSOSErrorAllocationFailure = 1024, | |
28 | kSOSErrorEncodeFailure = 1025, | |
29 | kSOSErrorNameMismatch = 1026, | |
30 | kSOSErrorSendFailure = 1027, | |
31 | kSOSErrorProcessingFailure = 1028, | |
32 | kSOSErrorDecodeFailure = 1029, | |
33 | ||
34 | kSOSErrorAlreadyPeer = 1030, | |
35 | kSOSErrorNotApplicant = 1031, | |
36 | kSOSErrorPeerNotFound = 1032, | |
37 | ||
38 | kSOSErrorNoKey = 1033, | |
39 | kSOSErrorBadKey = 1034, | |
40 | kSOSErrorBadFormat = 1035, | |
41 | kSOSErrorNoCircleName = 1036, | |
42 | kSOSErrorNoCircle = 1037, | |
43 | kSOSErrorBadSignature = 1038, | |
44 | kSOSErrorReplay = 1039, | |
45 | ||
46 | kSOSErrorUnexpectedType = 1040, | |
47 | ||
48 | kSOSErrorUnsupported = 1041 | |
49 | }; | |
50 | ||
51 | bool SOSCreateError(CFIndex errorCode, CFStringRef descriptionString, CFErrorRef previousError, CFErrorRef *newError); | |
52 | ||
53 | bool SOSCreateErrorWithFormat(CFIndex errorCode, CFErrorRef previousError, CFErrorRef *newError, | |
54 | CFDictionaryRef formatOptions, CFStringRef formatString, ...) | |
55 | CF_FORMAT_FUNCTION(5,6); | |
56 | ||
57 | bool SOSCreateErrorWithFormatAndArguments(CFIndex errorCode, CFErrorRef previousError, CFErrorRef *newError, | |
58 | CFDictionaryRef formatOptions, CFStringRef formatString, va_list args) | |
59 | CF_FORMAT_FUNCTION(5,0); | |
60 | ||
61 | ||
62 | static inline bool isSOSErrorCoded(CFErrorRef error, CFIndex sosErrorCode) { | |
63 | return CFErrorGetCode(error) == sosErrorCode && CFEqualSafe(CFErrorGetDomain(error), kSOSErrorDomain); | |
64 | } | |
65 | ||
66 | ||
67 | // | |
68 | // Utility Functions | |
69 | // | |
70 | OSStatus GenerateECPair(int keySize, SecKeyRef* public, SecKeyRef *full); | |
71 | OSStatus GeneratePermanentECPair(int keySize, SecKeyRef* public, SecKeyRef *full); | |
72 | ||
73 | CFStringRef SOSChangesCopyDescription(CFDictionaryRef changes, bool is_sender); | |
74 | ||
75 | CFStringRef SOSCopyIDOfKey(SecKeyRef key, CFErrorRef *error); | |
76 | ||
77 | // | |
78 | // Der encoding accumulation | |
79 | // | |
80 | static inline bool accumulate_size(size_t *accumulator, size_t size) { | |
81 | *accumulator += size; | |
82 | return size != 0; | |
83 | } | |
84 | ||
85 | __END_DECLS | |
86 | ||
87 | #endif |