Are you sure you want to limit yourself to Bitcoin only? Depending, you might want to support Dogecoin and other clones as well.
Anyway to solve this problem, the official place to look for this would be Bitcoin Core.
Yes. Core has validateaddress RPC which is basically exactly what I need. However, Core's code is way too refactored. I need one function, self-contained, to do this all. Its only dependency would be SHA-256.