1// Copyright (c) 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4//
5// The messages in this file comprise the DBus/Proto interface for
6// Cryptohome where there is an AccountIdentifer argument, an
7// AuthorizationRequest (if needed for the call), and the call's
8// parameters as <Call>Request.
9//
10// 'optional' annotations are used heavily in the RPC definition
11// because the RPC endpoints most properly sanity check the contents
12// for application-specific logic, and the more optional-with-default
13// parameters exist, the less data is actually transferred on the wire
14// in "default" situations.
15
16syntax = "proto2";
17
18option optimize_for = LITE_RUNTIME;
19
20package cryptohome;
21
22import "key.proto";
23
24// Error codes do not need to be sequential per-call.
25// Prefixes by Request/Reply type should be used to help
26// callers know if specialized errors apply.
27enum CryptohomeErrorCode {
28  // 0 is the default value of BaseReply::error. It
29  // should never be used.
30  CRYPTOHOME_ERROR_NOT_SET = 0;
31
32  CRYPTOHOME_ERROR_ACCOUNT_NOT_FOUND = 1;
33  CRYPTOHOME_ERROR_AUTHORIZATION_KEY_NOT_FOUND = 2;
34  CRYPTOHOME_ERROR_AUTHORIZATION_KEY_FAILED = 3;
35  CRYPTOHOME_ERROR_NOT_IMPLEMENTED = 4;
36  CRYPTOHOME_ERROR_MOUNT_FATAL = 5;
37  CRYPTOHOME_ERROR_MOUNT_MOUNT_POINT_BUSY = 6;
38  CRYPTOHOME_ERROR_TPM_COMM_ERROR = 7;
39  CRYPTOHOME_ERROR_TPM_DEFEND_LOCK = 8;
40  CRYPTOHOME_ERROR_TPM_NEEDS_REBOOT = 9;
41  CRYPTOHOME_ERROR_AUTHORIZATION_KEY_DENIED = 10;
42  CRYPTOHOME_ERROR_KEY_QUOTA_EXCEEDED = 11;
43  CRYPTOHOME_ERROR_KEY_LABEL_EXISTS = 12;
44  CRYPTOHOME_ERROR_BACKING_STORE_FAILURE = 13;
45  CRYPTOHOME_ERROR_UPDATE_SIGNATURE_INVALID = 14;
46  CRYPTOHOME_ERROR_KEY_NOT_FOUND = 15;
47  CRYPTOHOME_ERROR_LOCKBOX_SIGNATURE_INVALID = 16;
48  CRYPTOHOME_ERROR_LOCKBOX_CANNOT_SIGN = 17;
49  CRYPTOHOME_ERROR_BOOT_ATTRIBUTE_NOT_FOUND = 18;
50  CRYPTOHOME_ERROR_BOOT_ATTRIBUTES_CANNOT_SIGN = 19;
51  CRYPTOHOME_ERROR_TPM_EK_NOT_AVAILABLE = 20;
52  CRYPTOHOME_ERROR_ATTESTATION_NOT_READY = 21;
53  CRYPTOHOME_ERROR_CANNOT_CONNECT_TO_CA = 22;
54  CRYPTOHOME_ERROR_CA_REFUSED_ENROLLMENT = 23;
55  CRYPTOHOME_ERROR_CA_REFUSED_CERTIFICATE = 24;
56  CRYPTOHOME_ERROR_INTERNAL_ATTESTATION_ERROR = 25;
57}
58
59message AccountIdentifier {
60  optional string email = 1;
61}
62
63message AuthorizationRequest {
64  // |key| must supply at least a |key.secret()|.  If no |key.data()| or
65  // |key.data().label()| is supplied, the |key.secret()| will be tested
66  // against all compatible |key.data().type()| keys, where
67  // KEY_TYPE_PASSWORD is the default type.  If
68  // |key.data().label()| is supplied, then the |key.secret()| will only be
69  // tested against the matching VaultKeyset.
70  optional Key key = 1;
71};
72
73// These parameters are for inbound data to Cryptohome RPC
74// interfaces.  When calls are added that return data, a
75// <Call>Response should be defined.
76message MountRequest {
77  // Perform an ephemeral mount only.
78  optional bool require_ephemeral = 1 [default=false];
79  // If defined, the account will be created if it does not exist.
80  // Additionally, a failed AuthorizationRequest will be expected as
81  // there will be no existing keys.
82  optional CreateRequest create = 2;
83}
84
85// A BaseReply type is used for all cryptohomed responses. A shared base class
86// is used because all calls will always reply with no-error or an error value.
87// A centralized definition allows for a reusable reply handler for cases where
88// there is no Request-specific reply data.  Any specialized data will live in
89// an extension as per MountReply below:
90//   if (reply.HasExtension(MountReply::reply)) { ... }
91//
92message BaseReply {
93  // If a call was successful, error will not be defined (clear_error()).
94  // If a call failed, it must set an error code (set_error(CODE)).
95  // In either case, call-specific data may be added as an extension.
96  optional CryptohomeErrorCode error = 1;
97
98  extensions 1000 to max;
99}
100
101// The MountRequest call may return more than just success or failure
102// so it embeds itself in a BaseReply as an extension.
103message MountReply {
104  extend BaseReply {
105    optional MountReply reply = 1000;
106  }
107  // |recreated| is set when the cryptohome had to be wiped
108  // because the key or data was an unrecoverable.  It does not imply
109  // failure to Mount nor is it 'true' when a CreateRequest creates
110  // a cryptohome for the first time.
111  optional bool recreated = 1 [default=false];
112  // Returns the filesystem-sanitized username.
113  optional string sanitized_username = 2;
114};
115
116message CreateRequest {
117  repeated Key keys = 1;
118  // Explicitly use the |key| from the AuthorizationRequest.
119  // Setting this value means that the KeyData is filled as it
120  // would be with a Key above or in an AddKeyRequest.
121  optional bool copy_authorization_key = 2 [default=false];
122  // In the future, this will contain account-wide data like
123  // the deletion priority or the IdP's origin.
124}
125
126message AddKeyRequest {
127  optional Key key = 1;
128  optional bool clobber_if_exists = 2 [default=false];
129}
130
131message UpdateKeyRequest {
132  optional Key changes = 1;
133  optional bytes authorization_signature = 2;
134}
135
136message CheckKeyRequest {
137}
138
139message RemoveKeyRequest {
140  // Only key.data().label() is used at present.
141  optional Key key = 1;
142}
143
144message SignBootLockboxRequest {
145  // The data to be signed.
146  optional bytes data = 1;
147}
148
149message SignBootLockboxReply {
150  extend BaseReply {
151    optional SignBootLockboxReply reply = 1001;
152  }
153  optional bytes signature = 1;
154}
155
156message VerifyBootLockboxRequest {
157  // The signed data to be verified.
158  optional bytes data = 1;
159  // The signature to be verified.
160  optional bytes signature = 2;
161}
162
163message FinalizeBootLockboxRequest {
164}
165
166message GetKeyDataRequest {
167  // |key| must supply at least one attribute and all others will be treated as
168  // wildcards.  Currently only |key.data().label()| may be supplied.  Like
169  // AuthorizationRequest, support can be added for queries by
170  // |key.data().type()| to return all keys of a certain class, testing
171  // |key.secret()|, or |key.data().provider_data()| entries.
172  optional Key key = 1;
173}
174
175message GetKeyDataReply {
176  extend BaseReply {
177    optional GetKeyDataReply reply = 1002;
178  }
179  repeated KeyData key_data = 1;
180}
181
182message GetBootAttributeRequest {
183  optional string name = 1;
184}
185
186message GetBootAttributeReply {
187  extend BaseReply {
188    optional GetBootAttributeReply reply = 1003;
189  }
190  optional bytes value = 1;
191}
192
193message SetBootAttributeRequest {
194  optional string name = 1;
195  optional bytes value = 2;
196}
197
198message FlushAndSignBootAttributesRequest {
199}
200
201message ListKeysRequest {
202  // The default behavior is by label so any extension here should honor that.
203}
204
205message ListKeysReply {
206  extend BaseReply {
207    optional ListKeysReply reply = 1004;
208  }
209  repeated string labels = 1;
210}
211
212message GetLoginStatusRequest {
213}
214
215message GetLoginStatusReply {
216  extend BaseReply {
217    optional GetLoginStatusReply reply = 1005;
218  }
219  optional bool owner_user_exists=1;
220  optional bool boot_lockbox_finalized=2;
221}
222
223message GetTpmStatusRequest {
224}
225
226message GetTpmStatusReply {
227  extend BaseReply {
228    optional GetTpmStatusReply reply = 1006;
229  }
230  // Whether a TPM is enabled on the system.
231  optional bool enabled = 1;
232  // Whether the TPM has been owned.
233  optional bool owned = 2;
234  // Whether the TPM initialization flow has completed. This includes taking
235  // ownership, preparing attestation data, and finalizing lockbox NVRAM.
236  optional bool initialized = 3;
237  // The TPM owner password. This is only available when (owned &&
238  // !initialized) and sometimes not even then.
239  optional string owner_password = 4;
240  // Whether attestation data has been prepared. This includes reading the
241  // endorsement certificate out of NVRAM and generating an identity key. This
242  // does not include any kind of enrollment with a Privacy CA.
243  optional bool attestation_prepared = 7;
244  // Whether the device has enrolled with a Privacy CA. This means the identity
245  // key has been successfully certified.
246  optional bool attestation_enrolled = 8;
247  // The current dictionary attack counter value.
248  optional int32 dictionary_attack_counter = 9;
249  // The current dictionary attack counter threshold.
250  optional int32 dictionary_attack_threshold = 10;
251  // Whether the TPM is in some form of dictionary attack lockout.
252  optional bool dictionary_attack_lockout_in_effect = 11;
253  // The number of seconds remaining in the lockout.
254  optional int32 dictionary_attack_lockout_seconds_remaining = 12;
255  // Whether the install lockbox has been finalized.
256  optional bool install_lockbox_finalized = 13;
257  // Whether the boot lockbox has been finalized.
258  optional bool boot_lockbox_finalized = 14;
259  // Whether the current PCR values show a verified boot.
260  optional bool verified_boot_measured = 15;
261}
262
263message GetEndorsementInfoRequest {
264}
265
266message GetEndorsementInfoReply {
267  extend BaseReply {
268    optional GetEndorsementInfoReply reply = 1007;
269  }
270  // The endorsement public key (PKCS #1 RSAPublicKey).
271  optional bytes ek_public_key = 1;
272  // The endorsement certificate (X.509).
273  optional bytes ek_certificate = 2;
274}
275
276message InitializeCastKeyRequest {
277}
278