David Zeuthen | 8160315 | 2020-02-11 22:04:24 -0500 | [diff] [blame] | 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 | #ifndef ANDROID_HARDWARE_IDENTITY_IDENTITYCREDENTIALSTORE_H |
| 18 | #define ANDROID_HARDWARE_IDENTITY_IDENTITYCREDENTIALSTORE_H |
| 19 | |
| 20 | #include <aidl/android/hardware/identity/BnIdentityCredentialStore.h> |
| 21 | |
David Zeuthen | 630de2a | 2020-05-11 14:04:54 -0400 | [diff] [blame] | 22 | #include "SecureHardwareProxy.h" |
| 23 | |
David Zeuthen | 8160315 | 2020-02-11 22:04:24 -0500 | [diff] [blame] | 24 | namespace aidl::android::hardware::identity { |
| 25 | |
David Zeuthen | 630de2a | 2020-05-11 14:04:54 -0400 | [diff] [blame] | 26 | using ::android::sp; |
| 27 | using ::android::hardware::identity::SecureHardwareProxyFactory; |
David Zeuthen | 8160315 | 2020-02-11 22:04:24 -0500 | [diff] [blame] | 28 | using ::std::shared_ptr; |
| 29 | using ::std::string; |
| 30 | using ::std::vector; |
| 31 | |
| 32 | class IdentityCredentialStore : public BnIdentityCredentialStore { |
| 33 | public: |
David Zeuthen | 630de2a | 2020-05-11 14:04:54 -0400 | [diff] [blame] | 34 | IdentityCredentialStore(sp<SecureHardwareProxyFactory> hwProxyFactory) |
| 35 | : hwProxyFactory_(hwProxyFactory) {} |
David Zeuthen | 8160315 | 2020-02-11 22:04:24 -0500 | [diff] [blame] | 36 | |
| 37 | // The GCM chunk size used by this implementation is 64 KiB. |
| 38 | static constexpr size_t kGcmChunkSize = 64 * 1024; |
| 39 | |
| 40 | // Methods from IIdentityCredentialStore follow. |
| 41 | ndk::ScopedAStatus getHardwareInformation(HardwareInformation* hardwareInformation) override; |
| 42 | |
| 43 | ndk::ScopedAStatus createCredential( |
| 44 | const string& docType, bool testCredential, |
| 45 | shared_ptr<IWritableIdentityCredential>* outWritableCredential) override; |
| 46 | |
Jooyung Han | 17be89b | 2020-02-21 21:17:06 +0900 | [diff] [blame] | 47 | ndk::ScopedAStatus getCredential(CipherSuite cipherSuite, const vector<uint8_t>& credentialData, |
David Zeuthen | 8160315 | 2020-02-11 22:04:24 -0500 | [diff] [blame] | 48 | shared_ptr<IIdentityCredential>* outCredential) override; |
David Zeuthen | 630de2a | 2020-05-11 14:04:54 -0400 | [diff] [blame] | 49 | |
| 50 | private: |
| 51 | sp<SecureHardwareProxyFactory> hwProxyFactory_; |
David Zeuthen | 8160315 | 2020-02-11 22:04:24 -0500 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | } // namespace aidl::android::hardware::identity |
| 55 | |
| 56 | #endif // ANDROID_HARDWARE_IDENTITY_IDENTITYCREDENTIALSTORE_H |