1 /* 2 * Copyright 2020, 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 #pragma once 18 19 #include <cstdint> 20 #include <mutex> 21 22 #include <aidl/android/hardware/security/sharedsecret/BnSharedSecret.h> 23 #include <aidl/android/hardware/security/sharedsecret/SharedSecretParameters.h> 24 #include <keymaster/km_openssl/soft_keymaster_enforcement.h> 25 26 namespace aidl::android::hardware::security::sharedsecret { 27 28 class SoftSharedSecret : public BnSharedSecret { 29 public: 30 ::ndk::ScopedAStatus getSharedSecretParameters(SharedSecretParameters* params) override; 31 ::ndk::ScopedAStatus computeSharedSecret(const std::vector<SharedSecretParameters>& params, 32 std::vector<uint8_t>* sharingCheck) override; 33 34 keymaster::KeymasterKeyBlob HmacKey() const; 35 36 private: 37 mutable std::mutex mutex_; 38 std::vector<std::uint8_t> seed_; 39 std::vector<std::uint8_t> nonce_; 40 keymaster::KeymasterKeyBlob hmac_key_; 41 }; 42 43 } // namespace aidl::android::hardware::security::sharedsecret 44