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::shared_ptr;
30 using ::std::string;
31 using ::std::vector;
32 
33 class IdentityCredentialStore : public BnIdentityCredentialStore {
34  public:
IdentityCredentialStore(sp<SecureHardwareProxyFactory> hwProxyFactory)35   IdentityCredentialStore(sp<SecureHardwareProxyFactory> hwProxyFactory)
36       : hwProxyFactory_(hwProxyFactory) {}
37 
38   // The GCM chunk size used by this implementation is 64 KiB.
39   static constexpr size_t kGcmChunkSize = 64 * 1024;
40 
41   // Methods from IIdentityCredentialStore follow.
42   ndk::ScopedAStatus getHardwareInformation(
43       HardwareInformation* hardwareInformation) override;
44 
45   ndk::ScopedAStatus createCredential(
46       const string& docType, bool testCredential,
47       shared_ptr<IWritableIdentityCredential>* outWritableCredential) override;
48 
49   ndk::ScopedAStatus getCredential(
50       CipherSuite cipherSuite, const vector<uint8_t>& credentialData,
51       shared_ptr<IIdentityCredential>* outCredential) override;
52 
53  private:
54   sp<SecureHardwareProxyFactory> hwProxyFactory_;
55 };
56 
57 }  // namespace aidl::android::hardware::identity
58 
59 #endif  // ANDROID_HARDWARE_IDENTITY_IDENTITYCREDENTIALSTORE_H
60