Merge #10657: Utils: Improvements to ECDSA key-handling code
Summary:
PR10657 backport https://github.com/bitcoin/bitcoin/pull/10657/files
63179d0 Scope the ECDSA constant sizes to CPubKey / CKey classes (Jack Grigg)
1ce9f0a Ensure that ECDSA constant sizes are correctly-sized (Jack Grigg)
48abe78 Remove redundant = 0 initialisations (Jack Grigg)
17fa391 Specify ECDSA constant sizes as constants (Jack Grigg)
e4a1086 Update Debian copyright list (Jack Grigg)
e181dbe Add comments (Jack Grigg)
a3603ac Fix potential overflows in ECDSA DER parsers (Jack Grigg)
Pull request description:
Mostly trivial, but includes fixes to potential overflows in the ECDSA DER parsers. Cherry-picked from Zcash PR https://github.com/zcash/zcash/pull/2335
Also backported fixup to use ptrdiff_t instead of size_t, so we don't
generate a signed-unsigned-comparison warning:
PR12351 https://github.com/bitcoin/bitcoin/pull/12351/files
Note: the "potential overflows" here isn't anything substantial, rather
just conversion to the good-practice way to compare pointers. The
conversion from lenbyte >= sizeof(size_t) to lenbyte >= 4 does remove
platform-dependent behaviour, but only for signatures that violate
DERSIG and are >16 MiB in size, see discussion on PR.
Test Plan: make check
Reviewers: deadalnix, Fabien, jasonbcox, #bitcoin_abc
Reviewed By: deadalnix, Fabien, #bitcoin_abc
Differential Revision: https://reviews.bitcoinabc.org/D3581