summaryrefslogtreecommitdiff
path: root/include/amlogic_keymaster/AmlogicKeymaster.h (plain)
blob: 4aacc38cebdfd2bb25c312271efd483ad0154e09
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#include <amlogic_keymaster/ipc/amlogic_keymaster_ipc.h>
22#if AMLOGIC_MODIFY
23#include <amlogic_keymaster/amlogic_keymaster_messages.h>
24
25extern "C" {
26#include <tee_client_api.h>
27}
28#endif
29namespace keymaster {
30
31class AmlogicKeymaster {
32 public:
33 AmlogicKeymaster();
34 ~AmlogicKeymaster();
35 int Initialize();
36 void GetVersion(const GetVersionRequest& request, GetVersionResponse* response);
37 void SupportedAlgorithms(const SupportedAlgorithmsRequest& request,
38 SupportedAlgorithmsResponse* response);
39 void SupportedBlockModes(const SupportedBlockModesRequest& request,
40 SupportedBlockModesResponse* response);
41 void SupportedPaddingModes(const SupportedPaddingModesRequest& request,
42 SupportedPaddingModesResponse* response);
43 void SupportedDigests(const SupportedDigestsRequest& request,
44 SupportedDigestsResponse* response);
45 void SupportedImportFormats(const SupportedImportFormatsRequest& request,
46 SupportedImportFormatsResponse* response);
47 void SupportedExportFormats(const SupportedExportFormatsRequest& request,
48 SupportedExportFormatsResponse* response);
49 void AddRngEntropy(const AddEntropyRequest& request, AddEntropyResponse* response);
50 void Configure(const ConfigureRequest& request, ConfigureResponse* response);
51 void GenerateKey(const GenerateKeyRequest& request, GenerateKeyResponse* response);
52 void GetKeyCharacteristics(const GetKeyCharacteristicsRequest& request,
53 GetKeyCharacteristicsResponse* response);
54 void ImportKey(const ImportKeyRequest& request, ImportKeyResponse* response);
55 void ImportWrappedKey(const ImportWrappedKeyRequest& request,
56 ImportWrappedKeyResponse* response);
57 void ExportKey(const ExportKeyRequest& request, ExportKeyResponse* response);
58 void AttestKey(const AttestKeyRequest& request, AttestKeyResponse* response);
59 void UpgradeKey(const UpgradeKeyRequest& request, UpgradeKeyResponse* response);
60 void DeleteKey(const DeleteKeyRequest& request, DeleteKeyResponse* response);
61 void DeleteAllKeys(const DeleteAllKeysRequest& request, DeleteAllKeysResponse* response);
62 void BeginOperation(const BeginOperationRequest& request, BeginOperationResponse* response);
63 void UpdateOperation(const UpdateOperationRequest& request, UpdateOperationResponse* response);
64 void FinishOperation(const FinishOperationRequest& request, FinishOperationResponse* response);
65 void AbortOperation(const AbortOperationRequest& request, AbortOperationResponse* response);
66 GetHmacSharingParametersResponse GetHmacSharingParameters();
67 ComputeSharedHmacResponse ComputeSharedHmac(const ComputeSharedHmacRequest& request);
68 VerifyAuthorizationResponse VerifyAuthorization(const VerifyAuthorizationRequest& request);
69#if AMLOGIC_MODIFY
70 /* Move ForwardCommand from static method into class in order to access private members */
71 void ForwardCommand(enum keymaster_command command, const Serializable& req, KeymasterResponse* rsp);
72 private:
73 void SetBootParams(SetBootParamsRequest& request, SetBootParamsResponse* response);
74#if 0
75 bool HexToBytes(uint8_t* bytes, size_t bytes_len, const std::string& hex);
76 bool NibbleValue(const char& c, uint8_t* value);
77 std::string hex2bin(std::string const& s);
78#endif
79 TEEC_Context KM_context;
80 TEEC_Session KM_session;
81#endif
82};
83
84} // namespace keymaster
85
86#endif // TRUSTY_KEYMASTER_H_
87