]> git.saurik.com Git - apple/security.git/blob - OSX/sec/Security/SecOTR.h
Security-59754.80.3.tar.gz
[apple/security.git] / OSX / sec / Security / SecOTR.h
1 /*
2 * Copyright (c) 2011-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 #ifndef _SECOTR_H_
26 #define _SECOTR_H_
27
28 /*
29 * Message Protection interfaces
30 */
31
32 #include <CoreFoundation/CFBase.h>
33 #include <CoreFoundation/CFData.h>
34 #include <CoreFoundation/CFError.h>
35 #include <Security/SecKey.h>
36
37 #include <stdint.h>
38
39 __BEGIN_DECLS
40
41 /*!
42 @typedef
43 @abstract Full identity (public and private) for Message Protection
44 @discussion Abstracts what kind of crypto is going on beyond it being public/priate
45 */
46 typedef struct _SecOTRFullIdentity* SecOTRFullIdentityRef;
47
48 /*!
49 @typedef
50 @abstract Public identity for Message Protection message validation and encryption to send
51 @discussion Abstracts what kind of crypto is going on beyond it being public/priate
52 */
53 typedef struct _SecOTRPublicIdentity* SecOTRPublicIdentityRef;
54
55 /*
56 * Full identity functions
57 */
58 SecOTRFullIdentityRef SecOTRFullIdentityCreate(CFAllocatorRef allocator, CFErrorRef *error);
59
60 // This variant is used by MessageProtection that doesn't use persistent references anymore.
61 SecOTRFullIdentityRef SecOTRFullIdentityCreateFromSecKeyRef(CFAllocatorRef allocator, SecKeyRef privateKey,
62 CFErrorRef *error);
63
64 // This variant is used by SOS, and still relies on privateKey having a persistent reference.
65 SecOTRFullIdentityRef SecOTRFullIdentityCreateFromSecKeyRefSOS(CFAllocatorRef allocator, SecKeyRef privateKey,
66 CFErrorRef *error);
67 SecOTRFullIdentityRef SecOTRFullIdentityCreateFromData(CFAllocatorRef allocator, CFDataRef serializedData, CFErrorRef *error);
68
69 SecOTRFullIdentityRef SecOTRFullIdentityCreateFromBytes(CFAllocatorRef allocator, const uint8_t**bytes, size_t *size, CFErrorRef *error);
70
71 bool SecOTRFIPurgeFromKeychain(SecOTRFullIdentityRef thisID, CFErrorRef *error);
72
73 bool SecOTRFIAppendSerialization(SecOTRFullIdentityRef fullID, CFMutableDataRef serializeInto, CFErrorRef *error);
74
75
76 bool SecOTRFIPurgeAllFromKeychain(CFErrorRef *error);
77
78
79 /*
80 * Public identity functions
81 */
82 SecOTRPublicIdentityRef SecOTRPublicIdentityCopyFromPrivate(CFAllocatorRef allocator, SecOTRFullIdentityRef fullID, CFErrorRef *error);
83
84 SecOTRPublicIdentityRef SecOTRPublicIdentityCreateFromSecKeyRef(CFAllocatorRef allocator, SecKeyRef publicKey,
85 CFErrorRef *error);
86
87 SecOTRPublicIdentityRef SecOTRPublicIdentityCreateFromData(CFAllocatorRef allocator, CFDataRef serializedData, CFErrorRef *error);
88 SecOTRPublicIdentityRef SecOTRPublicIdentityCreateFromBytes(CFAllocatorRef allocator, const uint8_t**bytes, size_t * size, CFErrorRef *error);
89
90 bool SecOTRPIAppendSerialization(SecOTRPublicIdentityRef publicID, CFMutableDataRef serializeInto, CFErrorRef *error);
91
92 void SecOTRAdvertiseHashes(bool advertise);
93
94 __END_DECLS
95
96 #endif