Finding scale of rectangle inside larger rotated rectangle

Apologies if I'm poor at describing this problem.

I have a rectangle, A, of known size, that starts aligned to the x/y axes, and can rotate around its centre point.

For any given angle of rotation, I need to determine the maximum dimensions of a second rectangle, B, that:

- is inscribed inside A

- maintains the same proportions as A

- maintains alignment to the x/y axes

http://gbradley.co.uk/stuff/math.jpg

So, here A (the black rectangle) has been rotated through 30 degrees (the red rectangle). How do I determine the maximum size of B (the blue rectangle)?

Many thanks for any help.