1 /* 2 * Copyright 2019, 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 #pragma once 18 19 #include <stdint.h> 20 #include <teeui/generic_operation.h> 21 #include <teeui/utils.h> 22 23 #include <secure_input/secure_input_proto.h> 24 25 #include "secure_input_tracker.h" 26 #include "trusty_confirmation_ui.h" 27 #include "trusty_time_stamper.h" 28 29 class TrustyOperation 30 : public teeui::Operation<TrustyOperation, 31 monotonic_time_stamper::TimeStamp> { 32 public: TrustyOperation()33 TrustyOperation() 34 : Operation<TrustyOperation, monotonic_time_stamper::TimeStamp>() {} 35 36 int handleMsg(void* msg, 37 uint32_t msglen, 38 void* reponse, 39 uint32_t* responselen); 40 41 /* 42 * teeui::Operation expects the following hooks to be implemented. See 43 * teeui/generic_operation.h for more details. 44 */ 45 teeui::ResponseCode initHook(); 46 void abortHook(); 47 void finalizeHook(); 48 teeui::ResponseCode testCommandHook(teeui::TestModeCommands testCmd); 49 teeui::WriteStream extendedProtocolHook(teeui::Protocol proto, 50 teeui::ReadStream in, 51 teeui::WriteStream out); 52 53 /* 54 * teeui::Operation expects hmac256() and now() to be implemented. 55 */ 56 static teeui::optional<teeui::Hmac> hmac256( 57 const teeui::AuthTokenKey& key, 58 std::initializer_list<teeui::ByteBufferProxy> buffers); 59 using TimeStamp = monotonic_time_stamper::TimeStamp; now()60 static TimeStamp now() { return monotonic_time_stamper::now(); } 61 62 private: 63 TrustyConfirmationUI gui_; 64 InputTracker input_tracker_; 65 }; 66