2 * Copyright (c) 2011-2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
29 * Message Protection interfaces
32 #include <CoreFoundation/CFBase.h>
33 #include <CoreFoundation/CFData.h>
34 #include <CoreFoundation/CFError.h>
35 #include <Security/SecKey.h>
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
46 typedef struct _SecOTRFullIdentity
* SecOTRFullIdentityRef
;
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
53 typedef struct _SecOTRPublicIdentity
* SecOTRPublicIdentityRef
;
56 * Full identity functions
58 SecOTRFullIdentityRef
SecOTRFullIdentityCreate(CFAllocatorRef allocator
, CFErrorRef
*error
);
60 // This variant is used by MessageProtection that doesn't use persistent references anymore.
61 SecOTRFullIdentityRef
SecOTRFullIdentityCreateFromSecKeyRef(CFAllocatorRef allocator
, SecKeyRef privateKey
,
64 // This variant is used by SOS, and still relies on privateKey having a persistent reference.
65 SecOTRFullIdentityRef
SecOTRFullIdentityCreateFromSecKeyRefSOS(CFAllocatorRef allocator
, SecKeyRef privateKey
,
67 SecOTRFullIdentityRef
SecOTRFullIdentityCreateFromData(CFAllocatorRef allocator
, CFDataRef serializedData
, CFErrorRef
*error
);
69 SecOTRFullIdentityRef
SecOTRFullIdentityCreateFromBytes(CFAllocatorRef allocator
, const uint8_t**bytes
, size_t *size
, CFErrorRef
*error
);
71 bool SecOTRFIPurgeFromKeychain(SecOTRFullIdentityRef thisID
, CFErrorRef
*error
);
73 bool SecOTRFIAppendSerialization(SecOTRFullIdentityRef fullID
, CFMutableDataRef serializeInto
, CFErrorRef
*error
);
76 bool SecOTRFIPurgeAllFromKeychain(CFErrorRef
*error
);
80 * Public identity functions
82 SecOTRPublicIdentityRef
SecOTRPublicIdentityCopyFromPrivate(CFAllocatorRef allocator
, SecOTRFullIdentityRef fullID
, CFErrorRef
*error
);
84 SecOTRPublicIdentityRef
SecOTRPublicIdentityCreateFromSecKeyRef(CFAllocatorRef allocator
, SecKeyRef publicKey
,
87 SecOTRPublicIdentityRef
SecOTRPublicIdentityCreateFromData(CFAllocatorRef allocator
, CFDataRef serializedData
, CFErrorRef
*error
);
88 SecOTRPublicIdentityRef
SecOTRPublicIdentityCreateFromBytes(CFAllocatorRef allocator
, const uint8_t**bytes
, size_t * size
, CFErrorRef
*error
);
90 bool SecOTRPIAppendSerialization(SecOTRPublicIdentityRef publicID
, CFMutableDataRef serializeInto
, CFErrorRef
*error
);
92 void SecOTRAdvertiseHashes(bool advertise
);