2 * Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
21 * Created by john on Wed Jul 09 2003.
22 * Copyright (c) 2003 Apple. All rights reserved.
26 #include "FileVaultSPI.h"
27 #include "SFFileVault.h"
28 #include <Security/SecBridge.h>
29 #include <Security/cfutilities.h>
31 #pragma mark -------------------- SecFileVault implementation --------------------
33 OSStatus
SecFileVaultCreate (CFStringRef password
, bool enableMasterPassword
, CFURLRef dmgout
, CFStringRef volumeName
,
36 // Note that we do not need the master keychain password, since we can encrypt the
37 // image key with the public key.
41 CFURLRef certificate
= NULL
;
42 if (enableMasterPassword
)
43 sffv
.getCertificate(&certificate
);
45 sffv
.create(password
, certificate
, dmgout
, volumeName
, sizeSpec
);
46 if (certificate
) //@@@ leak if error thrown
47 CFRelease(certificate
);
52 OSStatus
SecFileVaultUserMount (CFStringRef password
, CFURLRef dmgin
, CFURLRef mountpoint
, CFStringRef
*devicepath
)
57 sffv
.mount(password
, NULL
, dmgin
, mountpoint
, devicepath
);
62 OSStatus
SecFileVaultMasterMount(CFURLRef dmgin
, CFURLRef mountpoint
, CFStringRef
*devicepath
)
67 sffv
.mastermount(dmgin
,mountpoint
,devicepath
);
72 OSStatus
SecFileVaultUnmount(CFURLRef mountpoint
, CFStringRef devicepath
)
77 sffv
.unmount(mountpoint
,devicepath
);
82 OSStatus
SecFileVaultUserChangePassword(CFStringRef password
, CFStringRef devicepath
)
87 fv
.userChangePassword(password
, devicepath
);
92 OSStatus
SecFileVaultMakeMasterPassword(CFStringRef masterPasswordPassword
)
97 SecKeychainRef keychainRef
;
98 fv
.makeMasterPassword(masterPasswordPassword
,&keychainRef
);
103 Boolean
SecFileVaultMasterPasswordEnabled(SecKeychainRef
*keychainRef
)
108 return fv
.masterPasswordEnabled(keychainRef
);
113 OSStatus
SecFileVaultChangeMasterPasswordPassword(CFStringRef oldPassword
,CFStringRef newPassword
)
118 fv
.changeMasterPasswordPassword(oldPassword
,newPassword
);
123 #pragma mark -------------------- SecFileVault extended implementation --------------------
125 OSStatus
SecFileVaultMount(CFStringRef password
, CFURLRef certificate
, CFURLRef dmgin
, CFURLRef mountpoint
,
126 CFStringRef
*devicepath
)
131 sffv
.mount(password
, certificate
, dmgin
, mountpoint
, devicepath
);
137 OSStatus
SecFileVaultCreateUsingCertificate (CFStringRef password
, CFURLRef certificate
, CFURLRef dmgout
, CFStringRef volumeName
,
138 CFStringRef sizeSpec
)
143 sffv
.create(password
, certificate
, dmgout
, volumeName
, sizeSpec
);