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, 36 bool(std::string* aes_key, std::string* sealed_key)); 37 38 MOCK_METHOD4(EncryptData, 39 bool(const std::string& data, 40 const std::string& aes_key, 41 const std::string& sealed_key, 42 std::string* encrypted_data)); 43 44 MOCK_METHOD3(UnsealKey, 45 bool(const std::string& encrypted_data, 46 std::string* aes_key, 47 std::string* sealed_key)); 48 49 MOCK_METHOD3(DecryptData, 50 bool(const std::string& encrypted_data, 51 const std::string& aes_key, 52 std::string* data)); 53 MOCK_METHOD2(GetRSASubjectPublicKeyInfo, 54 bool(const std::string&, std::string*)); 55 MOCK_METHOD2(GetRSAPublicKey, bool(const std::string&, std::string*)); 56 MOCK_METHOD4(EncryptIdentityCredential, 57 bool(const std::string&, 58 const std::string&, 59 const std::string&, 60 EncryptedIdentityCredential*)); 61 MOCK_METHOD3(EncryptForUnbind, 62 bool(const std::string&, const std::string&, std::string*)); 63 MOCK_METHOD3(VerifySignature, 64 bool(const std::string&, 65 const std::string&, 66 const std::string&)); 67 }; 68 69 } // namespace attestation 70 71 #endif // ATTESTATION_COMMON_MOCK_CRYPTO_UTILITY_H_ 72