blob: 356d75f178f089d8be431b5742ec103fe1ef705e [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_H_
18#define SYSTEM_SECURITY_CREDENTIAL_H_
19
20#include <string>
21#include <vector>
22
23#include <android/security/identity/BnCredential.h>
24
25#include <android/hardware/identity/1.0/IIdentityCredentialStore.h>
26#include <android/hardware/identity/1.0/types.h>
27
28#include "CredentialData.h"
29
30namespace android {
31namespace security {
32namespace identity {
33
34using ::android::sp;
35using ::android::binder::Status;
36using ::std::string;
37using ::std::vector;
38
39using ::android::hardware::identity::V1_0::IIdentityCredential;
40using ::android::hardware::identity::V1_0::IIdentityCredentialStore;
41
42class Credential : public BnCredential {
43 public:
44 Credential(const string& dataPath, const string& credentialName);
45 ~Credential();
46
47 Status loadCredential(sp<IIdentityCredentialStore> halStoreBinder);
48
49 // ICredential overrides
50 Status createEphemeralKeyPair(vector<uint8_t>* _aidl_return) override;
51
52 Status setReaderEphemeralPublicKey(const vector<uint8_t>& publicKey) override;
53
54 Status deleteCredential(vector<uint8_t>* _aidl_return) override;
55
56 Status getCredentialKeyCertificateChain(vector<uint8_t>* _aidl_return) override;
57
58 Status selectAuthKey(bool allowUsingExhaustedKeys, int64_t* _aidl_return) override;
59
60 Status getEntries(const vector<uint8_t>& requestMessage,
61 const vector<RequestNamespaceParcel>& requestNamespaces,
62 const vector<uint8_t>& sessionTranscript,
63 const vector<uint8_t>& readerSignature, bool allowUsingExhaustedKeys,
64 GetEntriesResultParcel* _aidl_return) override;
65
66 Status setAvailableAuthenticationKeys(int32_t keyCount, int32_t maxUsesPerKey) override;
67 Status getAuthKeysNeedingCertification(vector<AuthKeyParcel>* _aidl_return) override;
68 Status storeStaticAuthenticationData(const AuthKeyParcel& authenticationKey,
69 const vector<uint8_t>& staticAuthData) override;
70 Status getAuthenticationDataUsageCount(vector<int32_t>* _aidl_return) override;
71
72 private:
73 string dataPath_;
74 string credentialName_;
75
76 const AuthKeyData* selectedAuthKey_ = nullptr;
77 uint64_t selectedChallenge_ = 0;
78
79 sp<CredentialData> data_;
80
81 sp<IIdentityCredential> halBinder_;
82};
83
84} // namespace identity
85} // namespace security
86} // namespace android
87
88#endif // SYSTEM_SECURITY_IDENTITY_CREDENTIAL_H_