]> git.saurik.com Git - apple/security.git/blob - keychain/securityd/SecDbBackupManager_Internal.h
Security-59306.101.1.tar.gz
[apple/security.git] / keychain / securityd / SecDbBackupManager_Internal.h
1 /*
2 * Copyright (c) 2018 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 // DO NOT INCLUDE ME (unless you're SecDbBackupManager.m or a unit test)
25 // These are for internal use and testing only
26
27 #ifndef SecDbBackupManager_Internal_h
28 #define SecDbBackupManager_Internal_h
29
30 // Need these things in tests, too
31 #import "SecDbBackupManager.h"
32
33 #if SECDB_BACKUPS_ENABLED
34
35 #import "SecDbBackupBag.h"
36 #import "SecDbBackupBagIdentity.h"
37 #import "SecDbBackupKeyClassSigningKey.h"
38 #import "SecDbBackupMetadataClassKey.h"
39 #import "SecDbBackupRecoverySet.h"
40
41 #include <utilities/SecDb.h>
42
43 #import <SecurityFoundation/SFEncryptionOperation.h>
44 #import <SecurityFoundation/SFSigningOperation.h>
45 #import <SecurityFoundation/SFKey_Private.h>
46 #import <SecurityFoundation/SFCryptoServicesErrors.h>
47
48 @interface SecDbBackupManager (Internal)
49 @property (nonatomic) SecDbBackupBagIdentity* bagIdentity;
50
51 #define BACKUPBAG_PASSPHRASE_LENGTH 32
52 #define UUIDBYTESLENGTH 16
53
54 + (void)resetManager;
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;
63
64 // Pure utilities
65 - (NSData*)getSHA256OfData:(NSData*)data;
66 - (SFECKeyPair*)ECKeyPairFromDerBytes:(void*)bytes length:(size_t)len error:(NSError**)error;
67
68 @end
69
70 #endif // SECDB_BACKUPS_ENABLED
71
72 #endif /* SecDbBackupManager_Internal_h */