| David Zeuthen | 045a2c8 | 2021-09-11 13:52:17 -0400 | [diff] [blame] | 1 | /* | 
|  | 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 |  | 
|  | 31 | namespace android { | 
|  | 32 | namespace security { | 
|  | 33 | namespace identity { | 
|  | 34 |  | 
|  | 35 | using ::android::sp; | 
|  | 36 | using ::android::binder::Status; | 
|  | 37 | using ::std::string; | 
|  | 38 | using ::std::vector; | 
|  | 39 |  | 
|  | 40 | using ::android::hardware::identity::CipherSuite; | 
|  | 41 | using ::android::hardware::identity::HardwareInformation; | 
|  | 42 | using ::android::hardware::identity::IIdentityCredential; | 
|  | 43 | using ::android::hardware::identity::IIdentityCredentialStore; | 
|  | 44 | using ::android::hardware::identity::IPresentationSession; | 
|  | 45 | using ::android::hardware::identity::RequestDataItem; | 
|  | 46 | using ::android::hardware::identity::RequestNamespace; | 
|  | 47 |  | 
|  | 48 | class 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_ |