Fix possible buffer overrun.

(cherry picked from commit 2db3ea29298bdc347f15fbfab6d5746022f05101)

Conflicts:
	ssl/t1_lib.c
Add support for SHA2 in CAPI ENGINE.

PR#2706 though patch is from PR#3366.
ASN1 sanity check.

Primitive encodings shouldn't use indefinite length constructed
form.

PR#2438 (partial).