2 * Copyright (c) 2018 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@
24 // DO NOT INCLUDE ME (unless you're SecDbBackupManager.m or a unit test)
25 // These are for internal use and testing only
27 #ifndef SecDbBackupManager_Internal_h
28 #define SecDbBackupManager_Internal_h
30 // Need these things in tests, too
31 #import "SecDbBackupManager.h"
33 #if SECDB_BACKUPS_ENABLED
35 #import "SecDbBackupBag.h"
36 #import "SecDbBackupBagIdentity.h"
37 #import "SecDbBackupKeyClassSigningKey.h"
38 #import "SecDbBackupMetadataClassKey.h"
39 #import "SecDbBackupRecoverySet.h"
41 #include <utilities/SecDb.h>
43 #import <SecurityFoundation/SFEncryptionOperation.h>
44 #import <SecurityFoundation/SFSigningOperation.h>
45 #import <SecurityFoundation/SFKey_Private.h>
46 #import <SecurityFoundation/SFCryptoServicesErrors.h>
48 @interface
SecDbBackupManager (Internal
)
49 @
property (nonatomic
) SecDbBackupBagIdentity
* bagIdentity
;
51 #define BACKUPBAG_PASSPHRASE_LENGTH 32
52 #define UUIDBYTESLENGTH 16
55 - (NSData
*)createBackupBagSecret
:(NSError
**)error
;
56 - (keybag_handle_t
)createBackupBagWithSecret
:(NSData
*)secret error
:(NSError
**)error
;
57 - (BOOL
)saveBackupBag
:(keybag_handle_t
)handle asDefault
:(BOOL
)asDefault error
:(NSError
**)error
;
58 - (keybag_handle_t
)loadBackupBag
:(NSUUID
*)uuid error
:(NSError
**)error
;
59 - (BOOL
)createOrLoadBackupInfrastructure
:(NSError
**)error
;
60 - (SecDbBackupKeyClassSigningKey
*)createKCSKForKeyClass
:(keyclass_t
)keyclass withWrapper
:(SFAESKey
*)wrapper error
:(NSError
**)error
;
61 - (SecDbBackupRecoverySet
*)createRecoverySetWithBagSecret
:(NSData
*)secret forType
:(SecDbBackupRecoveryType
)type error
:(NSError
**)error
;
62 - (SFECKeyPair
*)fetchKCSKForKeyclass
:(keyclass_t
)keyclass error
:(NSError
**)error
;
65 - (NSData
*)getSHA256OfData
:(NSData
*)data
;
66 - (SFECKeyPair
*)getECKeyPairFromDERBytes
:(void*)bytes length
:(size_t)len error
:(NSError
**)error
;
70 #endif // SECDB_BACKUPS_ENABLED
72 #endif /* SecDbBackupManager_Internal_h */