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 #include <aidl/android/hardware/security/keymint/IRemotelyProvisionedComponent.h> 22 23 #include "SecureHardwareProxy.h" 24 25 namespace aidl::android::hardware::identity { 26 27 using ::android::sp; 28 using ::android::hardware::identity::SecureHardwareProxyFactory; 29 using ::std::optional; 30 using ::std::shared_ptr; 31 using ::std::string; 32 using ::std::vector; 33 34 class IdentityCredentialStore : public BnIdentityCredentialStore { 35 public: 36 // If remote key provisioning is supported, pass the service name for the correct 37 // IRemotelyProvisionedComponent to the remotelyProvisionedComponent parameter. Else 38 // pass std::nullopt to indicate remote key provisioning is not supported. 39 IdentityCredentialStore(sp<SecureHardwareProxyFactory> hwProxyFactory, 40 optional<string> remotelyProvisionedComponent); 41 42 // The GCM chunk size used by this implementation is 64 KiB. 43 static constexpr size_t kGcmChunkSize = 64 * 1024; 44 45 // Methods from IIdentityCredentialStore follow. 46 ndk::ScopedAStatus getHardwareInformation(HardwareInformation* hardwareInformation) override; 47 48 ndk::ScopedAStatus createCredential( 49 const string& docType, bool testCredential, 50 shared_ptr<IWritableIdentityCredential>* outWritableCredential) override; 51 52 ndk::ScopedAStatus getCredential(CipherSuite cipherSuite, const vector<uint8_t>& credentialData, 53 shared_ptr<IIdentityCredential>* outCredential) override; 54 55 ndk::ScopedAStatus createPresentationSession( 56 CipherSuite cipherSuite, shared_ptr<IPresentationSession>* outSession) override; 57 58 ndk::ScopedAStatus getRemotelyProvisionedComponent( 59 shared_ptr<::aidl::android::hardware::security::keymint::IRemotelyProvisionedComponent>* 60 outRemotelyProvisionedComponent) override; 61 62 private: 63 sp<SecureHardwareProxyFactory> hwProxyFactory_; 64 optional<string> remotelyProvisionedComponentName_; 65 HardwareInformation hardwareInformation_; 66 }; 67 68 } // namespace aidl::android::hardware::identity 69 70 #endif // ANDROID_HARDWARE_IDENTITY_IDENTITYCREDENTIALSTORE_H 71