AHe said that if he had the key with him, he could give him/her the solution.
BHe said if he could have the key with him,he would give him/her the solution.
CHe told that if he could have the key with him, he would give him/her the solution.
DHe said that If he have had the key with him, he could have given him/her the solution.