]> git.saurik.com Git - apple/security.git/blame - sec/SOSCircle/SecureObjectSync/SOSInternal.h
Security-55471.14.18.tar.gz
[apple/security.git] / sec / SOSCircle / SecureObjectSync / SOSInternal.h
CommitLineData
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
22enum {
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
51bool SOSCreateError(CFIndex errorCode, CFStringRef descriptionString, CFErrorRef previousError, CFErrorRef *newError);
52
53bool SOSCreateErrorWithFormat(CFIndex errorCode, CFErrorRef previousError, CFErrorRef *newError,
54 CFDictionaryRef formatOptions, CFStringRef formatString, ...)
55 CF_FORMAT_FUNCTION(5,6);
56
57bool SOSCreateErrorWithFormatAndArguments(CFIndex errorCode, CFErrorRef previousError, CFErrorRef *newError,
58 CFDictionaryRef formatOptions, CFStringRef formatString, va_list args)
59 CF_FORMAT_FUNCTION(5,0);
60
61
62static inline bool isSOSErrorCoded(CFErrorRef error, CFIndex sosErrorCode) {
63 return CFErrorGetCode(error) == sosErrorCode && CFEqualSafe(CFErrorGetDomain(error), kSOSErrorDomain);
64}
65
66
67//
68// Utility Functions
69//
70OSStatus GenerateECPair(int keySize, SecKeyRef* public, SecKeyRef *full);
71OSStatus GeneratePermanentECPair(int keySize, SecKeyRef* public, SecKeyRef *full);
72
73CFStringRef SOSChangesCopyDescription(CFDictionaryRef changes, bool is_sender);
74
75CFStringRef SOSCopyIDOfKey(SecKeyRef key, CFErrorRef *error);
76
77//
78// Der encoding accumulation
79//
80static 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