blob: eb63aca2631e3bdf2b0102bd7464bd1656ac85c7 [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_WRITABLE_CREDENTIAL_H_
18#define SYSTEM_SECURITY_WRITABLE_CREDENTIAL_H_
19
20#include <string>
21#include <vector>
22
23#include <android/security/identity/BnWritableCredential.h>
24
David Zeuthena6f9fba2020-02-11 22:08:27 -050025#include <android/hardware/identity/IIdentityCredentialStore.h>
David Zeuthenab3e5652019-10-28 13:32:48 -040026
27namespace android {
28namespace security {
29namespace identity {
30
31using ::android::binder::Status;
David Zeuthena6f9fba2020-02-11 22:08:27 -050032using ::android::hardware::identity::IWritableIdentityCredential;
David Zeuthenab3e5652019-10-28 13:32:48 -040033using ::std::string;
34using ::std::vector;
35
36class WritableCredential : public BnWritableCredential {
37 public:
38 WritableCredential(const string& dataPath, const string& credentialName, const string& docType,
39 size_t dataChunkSize, sp<IWritableIdentityCredential> halBinder);
40 ~WritableCredential();
41
42 // IWritableCredential overrides
43 Status getCredentialKeyCertificateChain(const vector<uint8_t>& challenge,
44 vector<uint8_t>* _aidl_return) override;
45
46 Status personalize(const vector<AccessControlProfileParcel>& accessControlProfiles,
47 const vector<EntryNamespaceParcel>& entryNamespaces, int64_t secureUserId,
48 vector<uint8_t>* _aidl_return) override;
49
50 private:
51 string dataPath_;
52 string credentialName_;
David Zeuthene2a78a42020-04-27 13:34:38 -040053 string docType_;
David Zeuthenab3e5652019-10-28 13:32:48 -040054 size_t dataChunkSize_;
55 sp<IWritableIdentityCredential> halBinder_;
56 vector<uint8_t> attestationCertificate_;
57
David Zeuthene2a78a42020-04-27 13:34:38 -040058 ssize_t calcExpectedProofOfProvisioningSize(
59 const vector<AccessControlProfileParcel>& accessControlProfiles,
60 const vector<EntryNamespaceParcel>& entryNamespaces);
61
David Zeuthenab3e5652019-10-28 13:32:48 -040062 Status ensureAttestationCertificateExists(const vector<uint8_t>& challenge);
63};
64
65} // namespace identity
66} // namespace security
67} // namespace android
68
69#endif // SYSTEM_SECURITY_WRITABLE_CREDENTIAL_H_