Key derivation implementation: client & server