1 /* 2 * Copyright (C) 2015 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 SYSTEM_KEYMASTER_OPERATION_TABLE_H 18 #define SYSTEM_KEYMASTER_OPERATION_TABLE_H 19 20 #include <keymaster/UniquePtr.h> 21 22 #include <hardware/keymaster_defs.h> 23 #include <keymaster/random_source.h> 24 25 namespace keymaster { 26 27 class Operation; 28 using OperationPtr = UniquePtr<Operation>; 29 30 31 class OperationTable { 32 public: OperationTable(size_t table_size)33 explicit OperationTable(size_t table_size) : 34 table_size_(table_size) {} 35 36 keymaster_error_t Add(OperationPtr&& operation); 37 Operation* Find(keymaster_operation_handle_t op_handle); 38 bool Delete(keymaster_operation_handle_t); 39 40 private: 41 UniquePtr<OperationPtr[]> table_; 42 size_t table_size_; 43 }; 44 45 } // namespace keymaster 46 47 #endif // SYSTEM_KEYMASTER_OPERATION_TABLE_H 48