Authentication


Authentication ensures that only clients that know the right 'code' can join the network. To start out setup some GWebCaches and configure your client to use them so finding nodes is easier. This especially works well when your network is small and just starting out.

GnucDNA makes authentication easy, it is broken into two parts, challenging the remote connection, and the remote connection challenging you. You supply the DNA with the challenge and response pair and it takes care of the rest.

OnAuthenticate() fires when you have the option to authenticate a connection. At this point you should create a challenge response pair and send it to the DNA with the SendChallenge() method.

OnChallenge() fires when a remote connection whats to challenge you. Send the response with the AnswerChallenge() method. Underneath the DNA is doing two-way authentication so both clients are verified.


Example:

OnAuthenticate(NodeID)
    Challenge = rand(0 - 14)
    Answer = 14 - Challenge
    SendChallenge(NodeID, Challenge, Answer)


OnChallenge(NodeID, Challenge)
    Answer = 14 - Challenge
    AnswerChallenge(NodeID, Answer)