blob: 116c2fd1aa0314b558db30b074ca177169ac5057 [file] [log] [blame]
David Zeuthen045a2c82021-09-11 13:52:17 -04001/*
2 * Copyright (c) 2021, 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_PRESENTATION_H_
18#define SYSTEM_SECURITY_PRESENTATION_H_
19
20#include <string>
21#include <vector>
22
23#include <android/security/identity/BnSession.h>
24
25#include <android/hardware/identity/IPresentationSession.h>
26
27#include <android/hardware/identity/IIdentityCredentialStore.h>
28
29#include "CredentialStore.h"
30
31namespace android {
32namespace security {
33namespace identity {
34
35using ::android::sp;
36using ::android::binder::Status;
37using ::std::string;
38using ::std::vector;
39
40using ::android::hardware::identity::CipherSuite;
41using ::android::hardware::identity::HardwareInformation;
42using ::android::hardware::identity::IIdentityCredential;
43using ::android::hardware::identity::IIdentityCredentialStore;
44using ::android::hardware::identity::IPresentationSession;
45using ::android::hardware::identity::RequestDataItem;
46using ::android::hardware::identity::RequestNamespace;
47
48class Session : public BnSession {
49 public:
50 Session(int32_t cipherSuite, sp<IPresentationSession> halBinder, sp<CredentialStore> store)
51 : cipherSuite_(cipherSuite), halBinder_(halBinder), store_(store) {}
52
53 bool initialize();
54
55 // ISession overrides
56 Status getEphemeralKeyPair(vector<uint8_t>* _aidl_return) override;
57
58 Status setReaderEphemeralPublicKey(const vector<uint8_t>& publicKey) override;
59
60 Status setSessionTranscript(const vector<uint8_t>& sessionTranscript) override;
61
62 Status getAuthChallenge(int64_t* _aidl_return) override;
63
64 Status getCredentialForPresentation(const string& credentialName,
65 sp<ICredential>* _aidl_return) override;
66
67 private:
68 int32_t cipherSuite_;
69 sp<IPresentationSession> halBinder_;
70 sp<CredentialStore> store_;
71};
72
73} // namespace identity
74} // namespace security
75} // namespace android
76
77#endif // SYSTEM_SECURITY_SESSION_H_