Add some const modifiers

This allows these functions to be used with const buffers.
Treat OOM in GCC certificates

This patch treats OOM cases and do a trivial cleanup
Merge pull request #1837 from hardening/const_cert_fix

Const cert fix