• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 and
5  * only version 2 as published by the Free Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  */
12 
13 #ifndef MSM_PFT_H_
14 #define MSM_PFT_H_
15 
16 #include <linux/types.h>
17 
18 /**
19  *  enum pft_command_opcode - PFT driver command ID
20  *
21  *  @PFT_CMD_OPCODE_SET_STATE -
22  *      command ID to set PFT driver state
23  *  @PFT_CMD_OPCODE_UPDATE_REG_APP_UID -
24  *      command ID to update the list of registered application
25  *      UID
26  *  @PFT_CMD_OPCODE_PERFORM_IN_PLACE_FILE_ENC -
27  *      command ID to perfrom in-place file encryption
28  */
29 enum pft_command_opcode {
30 	PFT_CMD_OPCODE_SET_STATE,
31 	PFT_CMD_OPCODE_UPDATE_REG_APP_UID,
32 	PFT_CMD_OPCODE_PERFORM_IN_PLACE_FILE_ENC,
33 	/* */
34 	PFT_CMD_OPCODE_MAX_COMMAND_INDEX
35 };
36 
37 /**
38  * enum pft_state - PFT driver operational states
39  *
40  * @PFT_STATE_DEACTIVATED - driver is deativated.
41  * @PFT_STATE_DEACTIVATING - driver is in the process of being deativated.
42  * @PFT_STATE_KEY_REMOVED - driver is active but no encryption key is loaded.
43  * @PFT_STATE_REMOVING_KEY - driver is active, but the encryption key is being
44  *      removed.
45  * @PFT_STATE_KEY_LOADED - driver is active, and the encryption key is loaded
46  *      to encryption block, hence registered apps can perform file operations
47  *      on encrypted files.
48  */
49 enum pft_state {
50 	PFT_STATE_DEACTIVATED,
51 	PFT_STATE_DEACTIVATING,
52 	PFT_STATE_KEY_REMOVED,
53 	PFT_STATE_REMOVING_KEY,
54 	PFT_STATE_KEY_LOADED,
55 	/* Internal */
56 	PFT_STATE_MAX_INDEX
57 };
58 
59 /**
60  * enum pft_command_response_code - PFT response on the previous
61  * command
62  *
63  * @PFT_CMD_RESP_SUCCESS - The command was properly processed
64  *      without an error.
65  * @PFT_CMD_RESP_GENERAL_ERROR -
66  *      Indicates an error that cannot be better described by a
67  *      more specific errors below.
68  * @PFT_CMD_RESP_INVALID_COMMAND - Invalid or unsupported
69  *      command id.
70  * @PFT_CMD_RESP_INVALID_CMD_PARAMS - Invalid command
71  *	parameters.
72  * @PFT_CMD_RESP_INVALID_STATE - Invalid state
73  * @PFT_CMD_RESP_ALREADY_IN_STATE - Used to indicates that
74  *      the new state is equal to the existing one.
75  * @PFT_CMD_RESP_INPLACE_FILE_IS_OPEN - Used to indicates
76  *      that the file that should be encrypted is already open
77  *      and can be encrypted.
78  * @PFT_CMD_RESP_ENT_FILES_CLOSING_FAILURE
79  *	Indicates about failure of the PFT to close Enterprise files
80  * @PFT_CMD_RESP_MAX_INDEX
81  */
82 enum pft_command_response_code {
83 	PFT_CMD_RESP_SUCCESS,
84 	PFT_CMD_RESP_GENERAL_ERROR,
85 	PFT_CMD_RESP_INVALID_COMMAND,
86 	PFT_CMD_RESP_INVALID_CMD_PARAMS,
87 	PFT_CMD_RESP_INVALID_STATE,
88 	PFT_CMD_RESP_ALREADY_IN_STATE,
89 	PFT_CMD_RESP_INPLACE_FILE_IS_OPEN,
90 	PFT_CMD_RESP_ENT_FILES_CLOSING_FAILURE,
91 	/* Internal */
92 	PFT_CMD_RESP_MAX_INDEX
93 };
94 
95 /**
96  * struct pft_command_response - response structure
97  *
98  * @command_id - see enum pft_command_response_code
99  * @error_codee - see enum pft_command_response_code
100  */
101 struct pft_command_response {
102 	__u32 command_id;
103 	__u32 error_code;
104 };
105 
106 /**
107  * struct pft_command - pft command
108  *
109  * @opcode - see enum pft_command_opcode.
110  * @set_state.state - see enum pft_state.
111  * @update_app_list.count - number of items in the
112  *      registered applications list.
113  * @update_app_list.table - registered applications array
114  * @preform_in_place_file_enc.file_descriptor - file descriptor
115  *      of the opened file to be in-placed encrypted.
116  */
117 struct pft_command {
118 	__u32 opcode;
119 	union {
120 		struct {
121 			/* @see pft_state */
122 			__u32 state;
123 		} set_state;
124 		struct {
125 			__u32 items_count; /* number of items */
126 			uid_t table[0]; /* array of UIDs */
127 		} update_app_list;
128 		struct {
129 			__u32 file_descriptor;
130 		} preform_in_place_file_enc;
131 	};
132 };
133 
134 #endif /* MSM_PFT_H_ */
135