Skip to content

Instantly share code, notes, and snippets.

@jmhertlein
Created April 27, 2013 04:20
Show Gist options
  • Save jmhertlein/5471873 to your computer and use it in GitHub Desktop.
Save jmhertlein/5471873 to your computer and use it in GitHub Desktop.
pseudocode for authenticating a user with rsa keys
Server has client's public key already, in a list of trusted public keys
keys are RSA key pairs
client connects
server sends its pubkey
client now using server's pubkey to encrypt all outgoing communications, incoming are still unencrypted
client sends username it wants to authenticate as
server loads trusted pubkey for username
encrypts n securely-randomly-generated bytes, sends over unencrypted connection to client
client uses private key to decrypt
sends now-unencrypted bytes over an encrypted stream to server
server compares client's response with original byte sequence
if same, user is who he says he is (has private key), authentication successful
else, user is not who he says he is (does not have private key), authentication fails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment