private void TestSRP(SRPParameters srpParams) { var password = Password.GenerateCredentialsHash(srpParams.Hash, "TEST", "TESTPW"); var server = new SRPServer("TEST", password, srpParams); var client = new SRPClient("TEST", password, srpParams); // Client sends A to the server. server.PublicEphemeralValueA = client.PublicEphemeralValueA; // Server sends s and B to the client. client.Salt = server.Salt; client.PublicEphemeralValueB = server.PublicEphemeralValueB; Assert.IsTrue(client.SessionKey == server.SessionKey); Assert.IsTrue(server.Validator.IsClientProofValid(client.Validator.ClientSessionKeyProof)); Assert.IsTrue(client.Validator.IsServerProofValid(server.Validator.ServerSessionKeyProof)); }
/// <summary> /// Calculates SRP information based on the username of the account used. /// If this account does not exist in the database, return null. /// </summary> /// <param name="username">The account's username.</param> /// <returns>null if no account exists, otherwise an SRPServer instance to be used for this connection.</returns> private static SRPServer GetSRPDataForUserName(string username) { // TODO this needs to be fetched from the database BigInteger credentials = null ?? new BigInteger(0); SRPServer srpData = new SRPServer(username, credentials, new WowAuthParameters()); srpData.Salt = new BigInteger(new FastRandom(), 32 * 8); return srpData; }