We consider the problem of computing the root-mean-square (RMS) gain of switched linear systems. We develop a new approach which is based on an attempt to characterize the "worst-case" switching law (WCSL), that is, the switching law that yields the maximal possible gain. Our main result provides a sufficient condition guaranteeing that the WCSL can be characterized explicitly using the differential Riccati equations (DREs) corresponding to the linear subsystems. This condition automatically holds for first-order SISO systems, so we obtain a complete solution to the RMS gain problem in this case. Key words: Switched and hybrid systems, bilinear control systems, optimal control, maximum principle, algebraic Riccati equation, differential Riccati equation, Hamilton-Jacobi-Bellman equation.