]>
git.saurik.com Git - apple/xnu.git/blob - bsd/sys/cprotect.h
2 * Copyright (c) 2009 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _SYS_CPROTECT_H_
30 #define _SYS_CPROTECT_H_
38 #include <sys/cdefs.h>
39 #include <sys/kernel_types.h>
41 #define PROTECTION_CLASS_A 1
42 #define PROTECTION_CLASS_B 2
43 #define PROTECTION_CLASS_C 3
44 #define PROTECTION_CLASS_D 4
45 #define PROTECTION_CLASS_E 5
47 #define KEYSIZE 8 /* 8x4 = 32, 32x8 = 256 */
48 #define INTEGRITYSIZE 2 /* 2x4 = 8, 8x8 = 64 */
50 #define LOCKED_STATE 0
51 #define UNLOCKED_STATE 1
53 #define LOCKED_KEYCHAIN 0
54 #define UNLOCKED_KEYCHAIN 1
56 #define CONTENT_PROTECTION_XATTR_NAME "com.apple.system.cprotect"
58 #define kEMBCKeyHandleSpecial ~1
60 /* SLIST_HEAD(cp_list, cp_entry) cp_head = LIST_HEAD_INITIALIZER(cp_head); */
61 /* struct cp_list *cprotect_list_headp; /\* List head *\/ */
63 typedef struct cprotect
*cprotect_t
;
64 typedef struct cp_wrap_func
*cp_wrap_func_t
;
65 typedef struct cp_global_state
*cp_global_state_t
;
66 typedef struct cp_xattr
*cp_xattr_t
;
69 typedef int wrapper_t(uint32_t properties
, void *key_bytes
, size_t key_length
, void **wrapped_data
, uint32_t *wrapped_length
);
70 typedef int unwrapper_t(uint32_t properties
, void *wrapped_data
, size_t wrapped_data_length
, void **key_bytes
, uint32_t *key_length
);
73 uint32_t cache_key
[KEYSIZE
];
74 uint32_t special_data
;
76 uint8_t cache_key_flushed
;
77 uint8_t lock_state
; /* lock_state: 0 means unlocked. 1 means locked */
81 SLIST_ENTRY(cp_entry
) cp_list
;
82 struct cprotect
*protected_entry
;
87 unwrapper_t
*unwrapper
;
90 struct cp_global_state
{
92 uint8_t wrap_functions_set
;
96 uint32_t persistent_class
;
97 uint8_t persistent_key
[32];
98 uint8_t persistent_integrity
[8];
99 uint8_t xattr_version
;
102 int cp_create_init(vnode_t
, vfs_context_t
);
103 int cp_key_store_action(int);
104 int cp_register_wraps(cp_wrap_func_t
);
105 struct cprotect
*cp_vnode_entry_alloc(void);
106 void cp_vnode_entry_init(vnode_t
);
107 int cp_vnode_entry_init_needed(vnode_t
);
108 struct cp_xattr
* cp_vn_getxattr(vnode_t
, vfs_context_t
);
109 int cp_vn_setxattr(vnode_t
, uint32_t, vfs_context_t
);
111 #endif /* KERNEL_PRIVATE */
117 #endif /* !_SYS_CPROTECT_H_ */