Key distribution and user authentication