operation_struct.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) 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. #ifndef KEYSTORE_OPERATION_STRUCT_H_
  17. #define KEYSTORE_OPERATION_STRUCT_H_
  18. #include <binder/Binder.h>
  19. #include <binder/IBinder.h>
  20. #include <keymasterV4_0/Keymaster.h>
  21. #include <utils/StrongPointer.h>
  22. #include <keystore/keymaster_types.h>
  23. #include <keystore/keystore_hidl_support.h>
  24. #include <keystore/keystore_return_types.h>
  25. #include <future>
  26. namespace keystore {
  27. using ::android::IBinder;
  28. using ::android::sp;
  29. using keymaster::support::Keymaster;
  30. struct Operation {
  31. Operation() = default;
  32. Operation(uint64_t handle_, uint64_t keyid_, KeyPurpose purpose_, const sp<Keymaster>& device_,
  33. KeyCharacteristics&& characteristics_, sp<IBinder> appToken_,
  34. const hidl_vec<KeyParameter> params_)
  35. : handle(handle_), keyid(keyid_), purpose(purpose_), device(device_),
  36. characteristics(characteristics_), appToken(appToken_), authToken(), verificationToken(),
  37. params(params_) {}
  38. Operation(Operation&&) = default;
  39. Operation(const Operation&) = delete;
  40. bool hasAuthToken() const { return authToken.mac.size() != 0; }
  41. uint64_t handle;
  42. uint64_t keyid;
  43. KeyPurpose purpose;
  44. sp<Keymaster> device;
  45. KeyCharacteristics characteristics;
  46. sp<IBinder> appToken;
  47. std::promise<KeyStoreServiceReturnCode> authTokenPromise;
  48. std::future<KeyStoreServiceReturnCode> authTokenFuture;
  49. HardwareAuthToken authToken;
  50. VerificationToken verificationToken;
  51. const hidl_vec<KeyParameter> params;
  52. };
  53. } // namespace keystore
  54. #endif