I am working on a password manager application that saves the user's passwords in a remote server. I need to use AES in CTR mode to encrypt the passwords before sending them to the server. The client is supposed to login/identify himself with a master password (which is already set in the server). This is what I've thought of until now:
- Client connects to server.
- Server sends a random value RAND1.
- Client generates a random value RAND2, and calculates hmacKey = SHA1 (master|RAND1|RAND2).
- Client calculates HMAC of RAND2, appends it to RAND2 and sends it to the server.
- The server (who knows the master password) calculates its own hmacKey and verifies the client.
This hmac key would be used during this whole session. Is this secure?