blob: 47987ceffd8f9a0736eaf6ade3f2d470b045ea26 [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
25#include <android/hardware/identity/1.0/IIdentityCredentialStore.h>
26#include <android/hardware/identity/1.0/types.h>
27
28namespace android {
29namespace security {
30namespace identity {
31
32using ::android::binder::Status;
33using ::android::hardware::identity::V1_0::IWritableIdentityCredential;
34using ::std::string;
35using ::std::vector;
36
37class WritableCredential : public BnWritableCredential {
38 public:
39 WritableCredential(const string& dataPath, const string& credentialName, const string& docType,
40 size_t dataChunkSize, sp<IWritableIdentityCredential> halBinder);
41 ~WritableCredential();
42
43 // IWritableCredential overrides
44 Status getCredentialKeyCertificateChain(const vector<uint8_t>& challenge,
45 vector<uint8_t>* _aidl_return) override;
46
47 Status personalize(const vector<AccessControlProfileParcel>& accessControlProfiles,
48 const vector<EntryNamespaceParcel>& entryNamespaces, int64_t secureUserId,
49 vector<uint8_t>* _aidl_return) override;
50
51 private:
52 string dataPath_;
53 string credentialName_;
54 size_t dataChunkSize_;
55 sp<IWritableIdentityCredential> halBinder_;
56 vector<uint8_t> attestationCertificate_;
57
58 Status ensureAttestationCertificateExists(const vector<uint8_t>& challenge);
59};
60
61} // namespace identity
62} // namespace security
63} // namespace android
64
65#endif // SYSTEM_SECURITY_WRITABLE_CREDENTIAL_H_