blob: f2aa506fa54bee2267876c47d6384f468723402e [file] [log] [blame]
David Zeuthenab3e5652019-10-28 13:32:48 -04001/*
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 Zeuthena6f9fba2020-02-11 22:08:27 -050023#include <android/hardware/identity/IIdentityCredentialStore.h>
David Zeuthenab3e5652019-10-28 13:32:48 -040024
25#include <android/security/identity/BnCredentialStore.h>
26
27namespace android {
28namespace security {
29namespace identity {
30
31using ::android::sp;
32using ::android::binder::Status;
David Zeuthen045a2c82021-09-11 13:52:17 -040033using ::std::optional;
David Zeuthenab3e5652019-10-28 13:32:48 -040034using ::std::string;
35using ::std::unique_ptr;
36using ::std::vector;
37
David Zeuthena6f9fba2020-02-11 22:08:27 -050038using ::android::hardware::identity::HardwareInformation;
39using ::android::hardware::identity::IIdentityCredentialStore;
David Zeuthen045a2c82021-09-11 13:52:17 -040040using ::android::hardware::identity::IPresentationSession;
David Zeuthenab3e5652019-10-28 13:32:48 -040041
42class CredentialStore : public BnCredentialStore {
43 public:
44 CredentialStore(const string& dataPath, sp<IIdentityCredentialStore> hal);
45 ~CredentialStore();
46
47 bool init();
48
David Zeuthen045a2c82021-09-11 13:52:17 -040049 // Used by both getCredentialByName() and Session::getCredential()
50 //
51 Status getCredentialCommon(const string& credentialName, int32_t cipherSuite,
52 sp<IPresentationSession> halSessionBinder,
53 sp<ICredential>* _aidl_return);
54
David Zeuthenab3e5652019-10-28 13:32:48 -040055 // ICredentialStore overrides
56 Status getSecurityHardwareInfo(SecurityHardwareInfoParcel* _aidl_return) override;
57
58 Status createCredential(const string& credentialName, const string& docType,
59 sp<IWritableCredential>* _aidl_return) override;
60
61 Status getCredentialByName(const string& credentialName, int32_t cipherSuite,
62 sp<ICredential>* _aidl_return) override;
63
David Zeuthen045a2c82021-09-11 13:52:17 -040064 Status createPresentationSession(int32_t cipherSuite, sp<ISession>* _aidl_return) override;
65
David Zeuthenab3e5652019-10-28 13:32:48 -040066 private:
67 string dataPath_;
68
69 sp<IIdentityCredentialStore> hal_;
David Zeuthen472e6c82020-10-16 11:50:13 -040070 int halApiVersion_;
David Zeuthenab3e5652019-10-28 13:32:48 -040071
David Zeuthena6f9fba2020-02-11 22:08:27 -050072 HardwareInformation hwInfo_;
David Zeuthenab3e5652019-10-28 13:32:48 -040073};
74
75} // namespace identity
76} // namespace security
77} // namespace android
78
79#endif // SYSTEM_SECURITY_CREDENTIAL_STORE_H_