David Zeuthen | ab3e565 | 2019-10-28 13:32:48 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 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 | #ifndef SYSTEM_SECURITY_CREDENTIAL_STORE_H_ |
| 18 | #define SYSTEM_SECURITY_CREDENTIAL_STORE_H_ |
| 19 | |
| 20 | #include <string> |
| 21 | #include <vector> |
| 22 | |
David Zeuthen | a6f9fba | 2020-02-11 22:08:27 -0500 | [diff] [blame] | 23 | #include <android/hardware/identity/IIdentityCredentialStore.h> |
David Zeuthen | ab3e565 | 2019-10-28 13:32:48 -0400 | [diff] [blame] | 24 | #include <android/security/identity/BnCredentialStore.h> |
Seth Moore | 81db378 | 2022-01-18 15:58:47 -0800 | [diff] [blame] | 25 | #include <android/security/remoteprovisioning/IRemotelyProvisionedKeyPool.h> |
Tri Vo | 3ab6f05 | 2022-11-22 10:26:16 -0800 | [diff] [blame] | 26 | #include <android/security/rkp/IRemoteProvisioning.h> |
| 27 | |
David Zeuthen | ab3e565 | 2019-10-28 13:32:48 -0400 | [diff] [blame] | 28 | namespace android { |
| 29 | namespace security { |
| 30 | namespace identity { |
| 31 | |
| 32 | using ::android::sp; |
| 33 | using ::android::binder::Status; |
David Zeuthen | 045a2c8 | 2021-09-11 13:52:17 -0400 | [diff] [blame] | 34 | using ::std::optional; |
David Zeuthen | ab3e565 | 2019-10-28 13:32:48 -0400 | [diff] [blame] | 35 | using ::std::string; |
| 36 | using ::std::unique_ptr; |
| 37 | using ::std::vector; |
| 38 | |
David Zeuthen | a6f9fba | 2020-02-11 22:08:27 -0500 | [diff] [blame] | 39 | using ::android::hardware::identity::HardwareInformation; |
| 40 | using ::android::hardware::identity::IIdentityCredentialStore; |
David Zeuthen | 045a2c8 | 2021-09-11 13:52:17 -0400 | [diff] [blame] | 41 | using ::android::hardware::identity::IPresentationSession; |
Seth Moore | 81db378 | 2022-01-18 15:58:47 -0800 | [diff] [blame] | 42 | using ::android::hardware::identity::IWritableIdentityCredential; |
Tri Vo | 3ab6f05 | 2022-11-22 10:26:16 -0800 | [diff] [blame] | 43 | using ::android::hardware::security::keymint::IRemotelyProvisionedComponent; |
Seth Moore | 81db378 | 2022-01-18 15:58:47 -0800 | [diff] [blame] | 44 | using ::android::security::remoteprovisioning::IRemotelyProvisionedKeyPool; |
David Zeuthen | ab3e565 | 2019-10-28 13:32:48 -0400 | [diff] [blame] | 45 | |
| 46 | class CredentialStore : public BnCredentialStore { |
| 47 | public: |
| 48 | CredentialStore(const string& dataPath, sp<IIdentityCredentialStore> hal); |
| 49 | ~CredentialStore(); |
| 50 | |
| 51 | bool init(); |
| 52 | |
David Zeuthen | 045a2c8 | 2021-09-11 13:52:17 -0400 | [diff] [blame] | 53 | // Used by both getCredentialByName() and Session::getCredential() |
| 54 | // |
| 55 | Status getCredentialCommon(const string& credentialName, int32_t cipherSuite, |
| 56 | sp<IPresentationSession> halSessionBinder, |
| 57 | sp<ICredential>* _aidl_return); |
| 58 | |
David Zeuthen | ab3e565 | 2019-10-28 13:32:48 -0400 | [diff] [blame] | 59 | // ICredentialStore overrides |
| 60 | Status getSecurityHardwareInfo(SecurityHardwareInfoParcel* _aidl_return) override; |
| 61 | |
| 62 | Status createCredential(const string& credentialName, const string& docType, |
| 63 | sp<IWritableCredential>* _aidl_return) override; |
| 64 | |
| 65 | Status getCredentialByName(const string& credentialName, int32_t cipherSuite, |
| 66 | sp<ICredential>* _aidl_return) override; |
| 67 | |
David Zeuthen | 045a2c8 | 2021-09-11 13:52:17 -0400 | [diff] [blame] | 68 | Status createPresentationSession(int32_t cipherSuite, sp<ISession>* _aidl_return) override; |
| 69 | |
David Zeuthen | ab3e565 | 2019-10-28 13:32:48 -0400 | [diff] [blame] | 70 | private: |
Seth Moore | 81db378 | 2022-01-18 15:58:47 -0800 | [diff] [blame] | 71 | Status setRemotelyProvisionedAttestationKey(IWritableIdentityCredential* halWritableCredential); |
| 72 | |
David Zeuthen | ab3e565 | 2019-10-28 13:32:48 -0400 | [diff] [blame] | 73 | string dataPath_; |
| 74 | |
| 75 | sp<IIdentityCredentialStore> hal_; |
David Zeuthen | 472e6c8 | 2020-10-16 11:50:13 -0400 | [diff] [blame] | 76 | int halApiVersion_; |
David Zeuthen | ab3e565 | 2019-10-28 13:32:48 -0400 | [diff] [blame] | 77 | |
David Zeuthen | a6f9fba | 2020-02-11 22:08:27 -0500 | [diff] [blame] | 78 | HardwareInformation hwInfo_; |
Tri Vo | 3ab6f05 | 2022-11-22 10:26:16 -0800 | [diff] [blame] | 79 | |
Tri Vo | 3ab6f05 | 2022-11-22 10:26:16 -0800 | [diff] [blame] | 80 | sp<IRemotelyProvisionedComponent> rpc_; |
David Zeuthen | ab3e565 | 2019-10-28 13:32:48 -0400 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | } // namespace identity |
| 84 | } // namespace security |
| 85 | } // namespace android |
| 86 | |
| 87 | #endif // SYSTEM_SECURITY_CREDENTIAL_STORE_H_ |