To pile-on ...proper storage ...practically indefinite. The compounds are very stable unless exposed to moisture, excessive O2 and contaminants. I have shot plenty of both commercially loaded and hand loaded ammunition that is almost 80 years old (modern smokeless gunpowder ...not black powder mind you). And like others, I have purchased old loading equipment with the old Herco/Hercules/IMR tin cans intact, and unless they were poorly sealed, have loaded it all.
Modern Gunpowder seems to get a musty scent when it goes south. And black powder inherits an acrid acid-type odor similar to vinegar. It may also have an orange tint to it in my experience.
If in doubt, take a little out and put a match to it and compare the burn to a similar amount of known-good powder. This IS NOT a proof that the powder is OK, just an indication that it's still capable of ignition. Though if that were a question, put it in your "b-o-m-b" box or in your garden ...the plants seem to like it (nitrate).