IGateKeeperService.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. #ifndef IGATEKEEPER_SERVICE_H_
  17. #define IGATEKEEPER_SERVICE_H_
  18. #include <binder/IInterface.h>
  19. #include <binder/Parcel.h>
  20. namespace android {
  21. /*
  22. * This must be kept manually in sync with frameworks/base's IGateKeeperService.aidl
  23. */
  24. class IGateKeeperService : public IInterface {
  25. public:
  26. enum {
  27. ENROLL = IBinder::FIRST_CALL_TRANSACTION + 0,
  28. VERIFY = IBinder::FIRST_CALL_TRANSACTION + 1,
  29. VERIFY_CHALLENGE = IBinder::FIRST_CALL_TRANSACTION + 2,
  30. GET_SECURE_USER_ID = IBinder::FIRST_CALL_TRANSACTION + 3,
  31. CLEAR_SECURE_USER_ID = IBinder::FIRST_CALL_TRANSACTION + 4,
  32. REPORT_DEVICE_SETUP_COMPLETE = IBinder::FIRST_CALL_TRANSACTION + 5,
  33. };
  34. enum {
  35. GATEKEEPER_RESPONSE_OK = 0,
  36. GATEKEEPER_RESPONSE_RETRY = 1,
  37. GATEKEEPER_RESPONSE_ERROR = -1,
  38. };
  39. // DECLARE_META_INTERFACE - C++ client interface not needed
  40. static const android::String16 descriptor;
  41. virtual const android::String16& getInterfaceDescriptor() const;
  42. IGateKeeperService() {}
  43. virtual ~IGateKeeperService() {}
  44. /**
  45. * Enrolls a password with the GateKeeper. Returns 0 on success, negative on failure.
  46. * Returns:
  47. * - 0 on success
  48. * - A timestamp T > 0 if the call has failed due to throttling and should not
  49. * be reattempted until T milliseconds have elapsed
  50. * - -1 on failure
  51. */
  52. virtual int enroll(uint32_t uid,
  53. const uint8_t *current_password_handle, uint32_t current_password_handle_length,
  54. const uint8_t *current_password, uint32_t current_password_length,
  55. const uint8_t *desired_password, uint32_t desired_password_length,
  56. uint8_t **enrolled_password_handle, uint32_t *enrolled_password_handle_length) = 0;
  57. /**
  58. * Verifies a password previously enrolled with the GateKeeper.
  59. * Returns:
  60. * - 0 on success
  61. * - A timestamp T > 0 if the call has failed due to throttling and should not
  62. * be reattempted until T milliseconds have elapsed
  63. * - -1 on failure
  64. */
  65. virtual int verify(uint32_t uid, const uint8_t *enrolled_password_handle,
  66. uint32_t enrolled_password_handle_length,
  67. const uint8_t *provided_password, uint32_t provided_password_length,
  68. bool *request_reenroll) = 0;
  69. /**
  70. * Verifies a password previously enrolled with the GateKeeper.
  71. * Returns:
  72. * - 0 on success
  73. * - A timestamp T > 0 if the call has failed due to throttling and should not
  74. * be reattempted until T milliseconds have elapsed
  75. * - -1 on failure
  76. */
  77. virtual int verifyChallenge(uint32_t uid, uint64_t challenge,
  78. const uint8_t *enrolled_password_handle, uint32_t enrolled_password_handle_length,
  79. const uint8_t *provided_password, uint32_t provided_password_length,
  80. uint8_t **auth_token, uint32_t *auth_token_length, bool *request_reenroll) = 0;
  81. /**
  82. * Returns the secure user ID for the provided android user
  83. */
  84. virtual uint64_t getSecureUserId(uint32_t uid) = 0;
  85. /**
  86. * Clears the secure user ID associated with the user.
  87. */
  88. virtual void clearSecureUserId(uint32_t uid) = 0;
  89. /**
  90. * Notifies gatekeeper that device setup has been completed and any potentially still existing
  91. * state from before a factory reset can be cleaned up (if it has not been already).
  92. */
  93. virtual void reportDeviceSetupComplete() = 0;
  94. };
  95. // ----------------------------------------------------------------------------
  96. class BnGateKeeperService: public BnInterface<IGateKeeperService> {
  97. public:
  98. virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply,
  99. uint32_t flags = 0);
  100. };
  101. } // namespace android
  102. #endif