blob: 4b6a8445b2e31900651a0e8b84c565f4dedd50e7 [file] [log] [blame]
Janis Danisevskis652f3812020-08-04 00:01:12 +00001// Copyright 2020, The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#![allow(missing_docs)]
16
17//! This crate holds types that we are depending on and will be generated by the AIDL
18//! compiler.
19
20use std::cmp::PartialEq;
21use std::fmt;
22
23#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
24pub struct Result {
25 pub rc: ResponseCode,
26 pub km_error_code: i32,
27}
28
29impl fmt::Display for Result {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 write!(f, "{:?}", self)
32 }
33}
34
35#[repr(i32)]
36#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
37pub enum ResponseCode {
38 Ok = 0,
39 // 1 Reserved - formerly NO_ERROR
40 Locked = 2,
41 Uninitialized = 3,
42 SystemError = 4,
43 // 5 Reserved - formerly "protocol error" was never used
44 PermissionDenied = 6,
45 KeyNotFound = 7,
46 ValueCorrupted = 8,
47 // 9 Reserved - formerly "undefined action" was never used
48 WrongPassword = 10,
49 // 11 - 13 Reserved - formerly password retry count indicators: obsolete
50 //
51 // 14 Reserved - formerly SIGNATURE_INVALID: Keystore does not perform public key
52 // operations any more.
53
54 // Indicates to the caller that user authorization is required before the operation may
55 // commence.
56 OpAuthNeeded = 15,
57 // 16 Reserved
58 KeyPermanentlyInvalidated = 17,
59 NoSuchSecurityLevel = 18,
60 KeymintErrorCode = 19,
61 BackendBusy = 20,
62}
63
64pub type ErrorCode = i32;
65
66#[repr(i32)]
67#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
68pub enum KeyPermission {
69 None = 0,
70 Delete = 1,
71 GenUniqueId = 2,
72 GetInfo = 4,
73 Grant = 8,
74 List = 0x10,
75 ManageBlob = 0x20,
76 Rebind = 0x40,
77 ReqForcedOp = 0x80,
78 Update = 0x100,
79 Use = 0x200,
80 UseDevId = 0x400,
81}
82
83#[repr(i32)]
84#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
85pub enum Domain {
86 App = 0,
87 Grant = 1,
88 SELinux = 2,
89 Blob = 3,
90 KeyId = 4,
91}
92
93#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
94pub struct KeyDescriptor {
95 pub domain: Domain,
96 pub namespace_: i64,
97 pub alias: Option<String>,
98 pub blob: Option<Vec<u8>>,
99}