A generalized two-pass key agreement method, extending the Diffie Hellman algorithm to a completely generalized version is presented using the functional equations approach for function selection. Two functions, which satisfy the given set of conditions, are used to generate a public key, which is a function of private keys from both users without exchanging private keys publicly. Only two passes are required with two computations by each user. It offers a more general purview as compared to the other two pass protocols in use. The work brings forth possibilities for many ad hoc PKC systems wherein one can design a PKC depending on available computational abilities and security requirements.