blob: 0c2dac5a768929a8759653944a5a71839aff04b7 [file] [log] [blame]
Kenny Roota91203b2012-02-15 15:00:46 -08001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __KEYSTORE_H__
18#define __KEYSTORE_H__
19
Kenny Root51878182012-03-13 12:53:19 -070020#include <stdint.h>
21
Kenny Roota91203b2012-02-15 15:00:46 -080022// note state values overlap with ResponseCode for the purposes of the state() API
23enum State {
24 STATE_NO_ERROR = 1,
25 STATE_LOCKED = 2,
26 STATE_UNINITIALIZED = 3,
27};
28
29enum ResponseCode {
30 NO_ERROR = STATE_NO_ERROR, // 1
31 LOCKED = STATE_LOCKED, // 2
32 UNINITIALIZED = STATE_UNINITIALIZED, // 3
33 SYSTEM_ERROR = 4,
34 PROTOCOL_ERROR = 5,
35 PERMISSION_DENIED = 6,
36 KEY_NOT_FOUND = 7,
37 VALUE_CORRUPTED = 8,
38 UNDEFINED_ACTION = 9,
39 WRONG_PASSWORD_0 = 10,
40 WRONG_PASSWORD_1 = 11,
41 WRONG_PASSWORD_2 = 12,
42 WRONG_PASSWORD_3 = 13, // MAX_RETRY = 4
Kenny Root70e3a862012-02-15 17:20:23 -080043 SIGNATURE_INVALID = 14,
Kenny Roota91203b2012-02-15 15:00:46 -080044};
45
Kenny Root51878182012-03-13 12:53:19 -070046enum CommandNames {
47 TEST = 0,
48 GET = 1,
49 INSERT = 2,
50 DELETE = 3,
51 EXIST = 4,
52 SAW = 5,
53 RESET = 6,
54 PASSWORD = 7,
55 LOCK = 8,
56 UNLOCK = 9,
57 ZERO = 10,
Kenny Root70e3a862012-02-15 17:20:23 -080058 GENERATE = 11,
59 IMPORT = 12,
60 SIGN = 13,
61 VERIFY = 14,
62 GET_PUBKEY = 15,
63 DEL_KEY = 16,
64 GRANT = 17,
65 UNGRANT = 18,
Kenny Root51878182012-03-13 12:53:19 -070066};
67
68typedef uint8_t command_code_t;
69
Kenny Root70e3a862012-02-15 17:20:23 -080070// Taken: a b c d e f g h i j k l m n o p q r s t u v w x y z
71// * * * * * * * * * * * * * * * * * *
Kenny Root51878182012-03-13 12:53:19 -070072command_code_t CommandCodes[] = {
73 't', // TEST
74 'g', // GET
75 'i', // INSERT
76 'd', // DELETE
77 'e', // EXIST
78 's', // SAW
79 'r', // RESET
80 'p', // PASSWORD
81 'l', // LOCK
82 'u', // UNLOCK
83 'z', // ZERO
Kenny Root70e3a862012-02-15 17:20:23 -080084 'a', // GENERATE
85 'm', // IMPORT
86 'n', // SIGN
87 'v', // VERIFY
88 'b', // GET_PUBKEY
89 'k', // DEL_KEY
90 'x', // GRANT
91 'y', // UNGRANT
Kenny Root51878182012-03-13 12:53:19 -070092};
93
Kenny Roota91203b2012-02-15 15:00:46 -080094#endif