blob: 42920d173de23a62dba86d37d0d910bfcfabdf88 [file] [log] [blame]
Sridhar Parasuramcb8a9482015-07-27 15:34:18 -07001/*
2 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
13 * * Neither the name of The Linux Foundation nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef KM_MAIN_H
31#define KM_MAIN_H
32
33#include <sys/types.h>
34/**
35 * Commands supported
36 */
37#define KEYMASTER_CMD_ID 0x100UL
38#define KEYMASTER_UTILS_CMD_ID 0x200UL
39
40#define UINT32_MAX (0xffffffff)
41
42typedef enum {
43 /*
44 * List the commands supportedin by the hardware.
45 */
46 KEYMASTER_GET_SUPPORTED_ALGORITHMS = (KEYMASTER_CMD_ID + 1UL),
47 KEYMASTER_GET_SUPPORTED_BLOCK_MODES = (KEYMASTER_CMD_ID + 2UL),
48 KEYMASTER_GET_SUPPORTED_PADDING_MODES = (KEYMASTER_CMD_ID + 3UL),
49 KEYMASTER_GET_SUPPORTED_DIGESTS = (KEYMASTER_CMD_ID + 4UL),
50 KEYMASTER_GET_SUPPORTED_IMPORT_FORMATS = (KEYMASTER_CMD_ID + 5UL),
51 KEYMASTER_GET_SUPPORTED_EXPORT_FORMATS = (KEYMASTER_CMD_ID + 6UL),
52 KEYMASTER_ADD_RNG_ENTROPY = (KEYMASTER_CMD_ID + 7UL),
53 KEYMASTER_GENERATE_KEY = (KEYMASTER_CMD_ID + 8UL),
54 KEYMASTER_GET_KEY_CHARACTERISTICS = (KEYMASTER_CMD_ID + 9UL),
55 KEYMASTER_RESCOPE = (KEYMASTER_CMD_ID + 10UL),
56 KEYMASTER_IMPORT_KEY = (KEYMASTER_CMD_ID + 11UL),
57 KEYMASTER_EXPORT_KEY = (KEYMASTER_CMD_ID + 12UL),
58 KEYMASTER_DELETE_KEY = (KEYMASTER_CMD_ID + 13UL),
59 KEYMASTER_DELETE_ALL_KEYS = (KEYMASTER_CMD_ID + 14UL),
60 KEYMASTER_BEGIN = (KEYMASTER_CMD_ID + 15UL),
61 KEYMASTER_GET_OUTPUT_SIZE = (KEYMASTER_CMD_ID + 16UL),
62 KEYMASTER_UPDATE = (KEYMASTER_CMD_ID + 17UL),
63 KEYMASTER_FINISH = (KEYMASTER_CMD_ID + 18UL),
64 KEYMASTER_ABORT = (KEYMASTER_CMD_ID + 19UL),
65
66 KEYMASTER_SET_ROT = (KEYMASTER_UTILS_CMD_ID + 1UL),
67 KEYMASTER_READ_LK_DEVICE_STATE = (KEYMASTER_UTILS_CMD_ID + 2UL),
68 KEYMASTER_WRITE_LK_DEVICE_STATE = (KEYMASTER_UTILS_CMD_ID + 3UL),
69 KEYMASTER_MILESTONE_CALL = (KEYMASTER_UTILS_CMD_ID + 4UL),
70
71 KEYMASTER_LAST_CMD_ENTRY = (int)0xFFFFFFFFULL
72} keymaster_cmd_t;
73
74
75/*
76 * Utils Api struct
77 */
78/**
79 @brief
80 Data structure
81
82 @param[in] cmd_id Requested command
83 @param[in] rot_ofset Offset from the top of the struct.
84 @param[in] rot_size Size of the ROT
85*/
86typedef struct _km_set_rot_req_t {
87 uint32 cmd_id;
88 uint32 rot_ofset;
89 uint32 rot_size;
90}__attribute__ ((packed)) km_set_rot_req_t;
91
92/**
93 @brief
94 Data structure
95
96 @param[out] status Status of the request
97*/
98typedef struct _km_set_rot_rsp_t {
99 int status;
100}__attribute__ ((packed)) km_set_rot_rsp_t;
101
102/**
103 @brief
104 Data structure
105
106 @param[in] cmd_id Requested command
107 @param[in] data information (could be data or a pointer to the memory that holds the data
108 @param[in] len if data is ptr to some buffer, len indicates length of the buffer
109*/
110typedef struct send_cmd{
111 uint32 cmd_id;
112 uint32 data;
113 uint32 len;
114} __attribute__ ((packed)) send_cmd_t;
115
116/*
117typedef struct send_cmd_rsp{
118 uint32 cmd_id;
119 uint32 data;
120 int32 status;
121} __attribute__ ((packed)) send_cmd_rsp_t; */
122
123/**
124 @brief
125 Data structure
126
127 @param[in] cmd_id Requested command
128*/
129typedef struct _km_set_milestone_req_t {
130 uint32 cmd_id;
131}__attribute__ ((packed)) km_set_milestone_req_t;
132
133/**
134 @brief
135 Data structure
136
137 @param[out] status Status of the request
138*/
139typedef struct _km_set_milestone_rsp_t {
140 int status;
141}__attribute__ ((packed)) km_set_milestone_rsp_t;
142
143/*
144 * Structures for delete_all cmd
145 */
146/*
147 @brief
148 Data structure
149
150 @param[in] cmd_id Requested command
151*/
152typedef struct _key_op_delete_all_req_t {
153 uint32 cmd_id;
154}__attribute__ ((packed)) key_op_delete_all_req_t;
155
156/*
157 @brief
158 Data structure
159
160 @param[out] status Status of the request
161*/
162typedef struct _key_op_delete_all_rsp_t {
163 int status;
164}__attribute__ ((packed)) key_op_delete_all_rsp_t;
165
166#endif /* KM_MAIN_H */