Kerckhoff-Shannon principle. Unless I can assume that my enemy has
total access to knowledge of my mechanisms, but is in no way
advantaged with respect to my operations, it is not an effective
weapon.
Freedom of information laws frequently have national security interest exceptions. A similar carve out can be made from the requirement of open sourcing public funded software.