Some very interesting information on Castles found here:

http://en.wikipedia.org/wiki/Medieval_fortification

And here:

http://www.bbc.co.uk/dna/h2g2/A2829260

Of particular note is a tidbit of information I often see neglected in Castle/fortress arcitecture. That of Staircase design.

Stairs, when built either spiral or against a wal were always built so that assuming the defender was on the higher ground, the defender had the wall to their left and open space to their right, or in the case of a spiral staircase, the newel (the centre pillar) was to the right. The reason was tactical. With the majority of persons being right handed, this forced the attacker to have limited roo to swing a sword or weapon, while the defender, had open space to their right allowing them uninhibited room to swing a weapon.

This one of the first things I always look for in any maps I see done of fortresses/keeps and is something I always endeavor to ensure I have in my maps.