Improve robustness of DER recoding code
Improve robustness of DER recoding code

Add some defensive programming on top of #5634.

This copies the respective OpenSSL code in ECDSA_verify in
OpenSSL pre-1.0.1k (e.g. https://github.com/openssl/openssl/blob/OpenSSL_1_0_1j/crypto/ecdsa/ecs_vrf.c#L89)
more closely.

As reported by @sergiodemianlerner.

Github-Pull: #5640
Rebased-From: c6b7b29f232c651f898eeffb93f36c8f537c56d2

Crowndev/crowncoin,Infernoman/crowncoin,Infernoman/crowncoin,domob1812/crowncoin,Crowndev/crowncoin,Crowndev/crowncoin,domob1812/crowncoin,domob1812/crowncoin,Infernoman/crowncoin,Crowndev/crowncoin,Infernoman/crowncoin,domob1812/crowncoin,Infernoman/crowncoin,Infernoman/crowncoin,domob1812/crowncoin,Crowndev/crowncoin,Crowndev/crowncoin,domob1812/crowncoin