1 // 2 // Copyright (C) 2015 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 ATTESTATION_COMMON_MOCK_CRYPTO_UTILITY_H_ 18 #define ATTESTATION_COMMON_MOCK_CRYPTO_UTILITY_H_ 19 20 #include "attestation/common/crypto_utility.h" 21 22 #include <string> 23 24 #include <gmock/gmock.h> 25 26 namespace attestation { 27 28 class MockCryptoUtility : public CryptoUtility { 29 public: 30 MockCryptoUtility(); 31 ~MockCryptoUtility() override; 32 33 MOCK_CONST_METHOD2(GetRandom, bool(size_t, std::string*)); 34 35 MOCK_METHOD2(CreateSealedKey, bool(std::string* aes_key, 36 std::string* sealed_key)); 37 38 MOCK_METHOD4(EncryptData, bool(const std::string& data, 39 const std::string& aes_key, 40 const std::string& sealed_key, 41 std::string* encrypted_data)); 42 43 MOCK_METHOD3(UnsealKey, bool(const std::string& encrypted_data, 44 std::string* aes_key, 45 std::string* sealed_key)); 46 47 MOCK_METHOD3(DecryptData, bool(const std::string& encrypted_data, 48 const std::string& aes_key, 49 std::string* data)); 50 MOCK_METHOD2(GetRSASubjectPublicKeyInfo, bool(const std::string&, 51 std::string*)); 52 MOCK_METHOD2(GetRSAPublicKey, bool(const std::string&, std::string*)); 53 MOCK_METHOD4(EncryptIdentityCredential, bool(const std::string&, 54 const std::string&, 55 const std::string&, 56 EncryptedIdentityCredential*)); 57 MOCK_METHOD3(EncryptForUnbind, bool(const std::string&, 58 const std::string&, 59 std::string*)); 60 MOCK_METHOD3(VerifySignature, bool(const std::string&, 61 const std::string&, 62 const std::string&)); 63 }; 64 65 } // namespace attestation 66 67 #endif // ATTESTATION_COMMON_MOCK_CRYPTO_UTILITY_H_ 68