• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 REMOTE_KEYMASTER_H_
18 #define REMOTE_KEYMASTER_H_
19 
20 #include <keymaster/android_keymaster_messages.h>
21 
22 #include "common/libs/security/keymaster_channel_sharedfd.h"
23 
24 namespace keymaster {
25 
26 class RemoteKeymaster {
27   private:
28    cuttlefish::SharedFdKeymasterChannel* channel_;
29 
30    void ForwardCommand(AndroidKeymasterCommand command, const Serializable& req,
31                        KeymasterResponse* rsp);
32 
33   public:
34    RemoteKeymaster(cuttlefish::SharedFdKeymasterChannel*);
35    ~RemoteKeymaster();
36    bool Initialize();
37    void GetVersion(const GetVersionRequest& request,
38                    GetVersionResponse* response);
39    void SupportedAlgorithms(const SupportedAlgorithmsRequest& request,
40                             SupportedAlgorithmsResponse* response);
41    void SupportedBlockModes(const SupportedBlockModesRequest& request,
42                             SupportedBlockModesResponse* response);
43    void SupportedPaddingModes(const SupportedPaddingModesRequest& request,
44                               SupportedPaddingModesResponse* response);
45    void SupportedDigests(const SupportedDigestsRequest& request,
46                          SupportedDigestsResponse* response);
47    void SupportedImportFormats(const SupportedImportFormatsRequest& request,
48                                SupportedImportFormatsResponse* response);
49    void SupportedExportFormats(const SupportedExportFormatsRequest& request,
50                                SupportedExportFormatsResponse* response);
51    void AddRngEntropy(const AddEntropyRequest& request,
52                       AddEntropyResponse* response);
53    void Configure(const ConfigureRequest& request, ConfigureResponse* response);
54    void GenerateKey(const GenerateKeyRequest& request,
55                     GenerateKeyResponse* response);
56    void GetKeyCharacteristics(const GetKeyCharacteristicsRequest& request,
57                               GetKeyCharacteristicsResponse* response);
58    void ImportKey(const ImportKeyRequest& request, ImportKeyResponse* response);
59    void ImportWrappedKey(const ImportWrappedKeyRequest& request,
60                          ImportWrappedKeyResponse* response);
61    void ExportKey(const ExportKeyRequest& request, ExportKeyResponse* response);
62    void AttestKey(const AttestKeyRequest& request, AttestKeyResponse* response);
63    void UpgradeKey(const UpgradeKeyRequest& request,
64                    UpgradeKeyResponse* response);
65    void DeleteKey(const DeleteKeyRequest& request, DeleteKeyResponse* response);
66    void DeleteAllKeys(const DeleteAllKeysRequest& request,
67                       DeleteAllKeysResponse* response);
68    void BeginOperation(const BeginOperationRequest& request,
69                        BeginOperationResponse* response);
70    void UpdateOperation(const UpdateOperationRequest& request,
71                         UpdateOperationResponse* response);
72    void FinishOperation(const FinishOperationRequest& request,
73                         FinishOperationResponse* response);
74    void AbortOperation(const AbortOperationRequest& request,
75                        AbortOperationResponse* response);
76    GetHmacSharingParametersResponse GetHmacSharingParameters();
77    ComputeSharedHmacResponse ComputeSharedHmac(
78        const ComputeSharedHmacRequest& request);
79    VerifyAuthorizationResponse VerifyAuthorization(
80        const VerifyAuthorizationRequest& request);
81    DeviceLockedResponse DeviceLocked(const DeviceLockedRequest& request);
82    EarlyBootEndedResponse EarlyBootEnded();
83 
84    // CF HAL and remote sides are always compiled together, so will never
85    // disagree about message versions.
message_version()86    uint32_t message_version() { return kDefaultMessageVersion; }
87 };
88 
89 }  // namespace keymaster
90 
91 #endif  // REMOTE_KEYMASTER_H_
92