1/*
2 * Copyright (c) 2013-2014 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25/*!
26 @header SOSManifest.h
27 The functions provided in SOSTransport.h provide an interface to the
28 secure object syncing transport
29 */
30
31#ifndef _SEC_SOSMANIFEST_H_
32#define _SEC_SOSMANIFEST_H_
33
34#include <corecrypto/ccsha1.h>
35#include <CoreFoundation/CFData.h>
36#include <CoreFoundation/CFError.h>
37
38__BEGIN_DECLS
39
40enum {
41    kSOSManifestUnsortedError = 1,
42    kSOSManifestCreateError = 2,
43};
44
45extern CFStringRef kSOSManifestErrorDomain;
46
47/* SOSObject. */
48
49/* Forward declarations of SOS types. */
50typedef struct __OpaqueSOSManifest *SOSManifestRef;
51struct SOSDigestVector;
52
53/* SOSManifest. */
54CFTypeID SOSManifestGetTypeID(void);
55
56SOSManifestRef SOSManifestCreateWithBytes(const uint8_t *bytes, size_t len,
57                                          CFErrorRef *error);
58SOSManifestRef SOSManifestCreateWithDigestVector(struct SOSDigestVector *dv, CFErrorRef *error);
59SOSManifestRef SOSManifestCreateWithData(CFDataRef data, CFErrorRef *error);
60
61size_t SOSManifestGetSize(SOSManifestRef m);
62
63size_t SOSManifestGetCount(SOSManifestRef m);
64
65const uint8_t *SOSManifestGetBytePtr(SOSManifestRef m);
66
67CFDataRef SOSManifestGetData(SOSManifestRef m);
68
69const struct SOSDigestVector *SOSManifestGetDigestVector(SOSManifestRef manifest);
70
71bool SOSManifestDiff(SOSManifestRef a, SOSManifestRef b,
72                     SOSManifestRef *a_minus_b, SOSManifestRef *b_minus_a,
73                     CFErrorRef *error);
74
75SOSManifestRef SOSManifestCreateWithPatch(SOSManifestRef base,
76                                          SOSManifestRef removals,
77                                          SOSManifestRef additions,
78                                          CFErrorRef *error);
79
80// Returns the set of elements in B that are not in A.
81// This is the relative complement of A in B (B\A), sometimes written B − A
82SOSManifestRef SOSManifestCreateComplement(SOSManifestRef A,
83                                           SOSManifestRef B,
84                                           CFErrorRef *error);
85
86SOSManifestRef SOSManifestCreateIntersection(SOSManifestRef m1,
87                                             SOSManifestRef m2,
88                                             CFErrorRef *error);
89
90
91SOSManifestRef SOSManifestCreateUnion(SOSManifestRef m1,
92                                      SOSManifestRef m2,
93                                      CFErrorRef *error);
94
95void SOSManifestForEach(SOSManifestRef m, void(^block)(CFDataRef e, bool *stop));
96
97CFDataRef SOSManifestGetDigest(SOSManifestRef m, CFErrorRef *error);
98
99__END_DECLS
100
101#endif /* !_SEC_SOSMANIFEST_H_ */
102