Example #1
0
        public static void Test()
        {
            SecureRemotePassword.SRPParameters srpParameters = new SecureRemotePassword.SRPParameters();
            BigInteger bigInteger = HashUtilities.HashToBigInteger(SecureRemotePassword.SRPParameters.Hash,
                                                                   (HashUtilities.HashDataBroker) "USER:PASSWORD");
            SecureRemotePassword secureRemotePassword1 =
                new SecureRemotePassword("USER", bigInteger, true, SecureRemotePassword.SRPParameters.Defaults);
            SecureRemotePassword secureRemotePassword2 = new SecureRemotePassword("USER", bigInteger, false,
                                                                                  SecureRemotePassword.SRPParameters.Defaults);

            Console.WriteLine("Client sending A = {0}",
                              (object)secureRemotePassword2.PublicEphemeralValueA.ToHexString());
            secureRemotePassword1.PublicEphemeralValueA = secureRemotePassword2.PublicEphemeralValueA;
            Console.WriteLine("Server sending salt = {0}", (object)secureRemotePassword1.Salt.ToHexString());
            Console.WriteLine("Server sending B = {0}",
                              (object)secureRemotePassword1.PublicEphemeralValueB.ToHexString());
            secureRemotePassword2.Salt = secureRemotePassword1.Salt;
            secureRemotePassword2.PublicEphemeralValueB = secureRemotePassword1.PublicEphemeralValueB;
            Console.WriteLine("Server's session key = {0}", (object)secureRemotePassword1.SessionKey.ToHexString());
            Console.WriteLine("Client's session key = {0}", (object)secureRemotePassword2.SessionKey.ToHexString());
            Console.WriteLine("\nServer key == client key {0}",
                              (object)(secureRemotePassword1.SessionKey == secureRemotePassword2.SessionKey));
            Console.WriteLine("Client proof valid: {0}",
                              (object)secureRemotePassword1.IsClientProofValid(secureRemotePassword2.ClientSessionKeyProof));
            Console.WriteLine("Server proof valid: {0}",
                              (object)secureRemotePassword2.IsServerProofValid(secureRemotePassword1.ServerSessionKeyProof));
        }
Example #2
0
 public SecureRemotePassword(string username, BigInteger credentials, bool isServer,
                             SecureRemotePassword.SRPParameters parameters)
 {
     if (!parameters.CaseSensitive)
     {
         username = username.ToUpper();
     }
     this.m_srpParams = parameters;
     this.m_isServer  = isServer;
     this.Username    = username;
     this.Credentials = credentials;
 }
Example #3
0
 /// <summary>
 /// Make an SRP for user authentication. You use something like this when your
 /// verifier and salt are stored in a database
 /// </summary>
 /// <param name="username"></param>
 /// <param name="verifier"></param>
 /// <param name="salt"></param>
 /// <param name="parameters"></param>
 public SecureRemotePassword(string username, BigInteger verifier, BigInteger salt,
                             SecureRemotePassword.SRPParameters parameters)
 {
     if (!parameters.CaseSensitive)
     {
         username = username.ToUpper();
     }
     this.m_srpParams = parameters;
     this.m_isServer  = true;
     this.Username    = username;
     this.Verifier    = verifier;
     this.m_salt      = salt;
 }
Example #4
0
 public SecureRemotePassword(bool isServer, SecureRemotePassword.SRPParameters parameters)
 {
     this.m_srpParams = parameters;
     this.m_isServer  = isServer;
 }