1 /*
2  * Copyright 2018 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 TRUSTY_KEYMASTER_H_
18 #define TRUSTY_KEYMASTER_H_
19 
20 #include <keymaster/android_keymaster_messages.h>
21 
22 namespace keymaster {
23 
24 class TrustyKeymaster {
25   public:
26     TrustyKeymaster();
27     ~TrustyKeymaster();
28     int Initialize(KmVersion version);
29     void GetVersion(const GetVersionRequest& request, GetVersionResponse* response);
30     void SupportedAlgorithms(const SupportedAlgorithmsRequest& request,
31                              SupportedAlgorithmsResponse* response);
32     void SupportedBlockModes(const SupportedBlockModesRequest& request,
33                              SupportedBlockModesResponse* response);
34     void SupportedPaddingModes(const SupportedPaddingModesRequest& request,
35                                SupportedPaddingModesResponse* response);
36     void SupportedDigests(const SupportedDigestsRequest& request,
37                           SupportedDigestsResponse* response);
38     void SupportedImportFormats(const SupportedImportFormatsRequest& request,
39                                 SupportedImportFormatsResponse* response);
40     void SupportedExportFormats(const SupportedExportFormatsRequest& request,
41                                 SupportedExportFormatsResponse* response);
42     void AddRngEntropy(const AddEntropyRequest& request, AddEntropyResponse* response);
43     void Configure(const ConfigureRequest& request, ConfigureResponse* response);
44     void GenerateKey(const GenerateKeyRequest& request, GenerateKeyResponse* response);
45     void GenerateRkpKey(const GenerateRkpKeyRequest& request, GenerateRkpKeyResponse* response);
46     void GenerateCsr(const GenerateCsrRequest& request, GenerateCsrResponse* response);
47     void GetKeyCharacteristics(const GetKeyCharacteristicsRequest& request,
48                                GetKeyCharacteristicsResponse* response);
49     void ImportKey(const ImportKeyRequest& request, ImportKeyResponse* response);
50     void ImportWrappedKey(const ImportWrappedKeyRequest& request,
51                           ImportWrappedKeyResponse* response);
52     void ExportKey(const ExportKeyRequest& request, ExportKeyResponse* response);
53     void AttestKey(const AttestKeyRequest& request, AttestKeyResponse* response);
54     void UpgradeKey(const UpgradeKeyRequest& request, UpgradeKeyResponse* response);
55     void DeleteKey(const DeleteKeyRequest& request, DeleteKeyResponse* response);
56     void DeleteAllKeys(const DeleteAllKeysRequest& request, DeleteAllKeysResponse* response);
57     void BeginOperation(const BeginOperationRequest& request, BeginOperationResponse* response);
58     void UpdateOperation(const UpdateOperationRequest& request, UpdateOperationResponse* response);
59     void FinishOperation(const FinishOperationRequest& request, FinishOperationResponse* response);
60     void AbortOperation(const AbortOperationRequest& request, AbortOperationResponse* response);
61     GetHmacSharingParametersResponse GetHmacSharingParameters();
62     ComputeSharedHmacResponse ComputeSharedHmac(const ComputeSharedHmacRequest& request);
63     VerifyAuthorizationResponse VerifyAuthorization(const VerifyAuthorizationRequest& request);
64     GetVersion2Response GetVersion2(const GetVersion2Request& request);
65     EarlyBootEndedResponse EarlyBootEnded();
66     DeviceLockedResponse DeviceLocked(const DeviceLockedRequest& request);
67     ConfigureVendorPatchlevelResponse ConfigureVendorPatchlevel(
68             const ConfigureVendorPatchlevelRequest& request);
69 
message_version()70     uint32_t message_version() const { return message_version_; }
71 
72   private:
73     uint32_t message_version_;
74 };
75 
76 }  // namespace keymaster
77 
78 #endif  // TRUSTY_KEYMASTER_H_
79