This change migrates //components/client_update_protocol from:
* crypto/sha2 to crypto/hash
* crypto/signature_verifier to crypto/sign and crypto/keypair
Specifically:
* Uses of the obsolete SHA-256 APIs are replaced with uses of the new
crypto::hash API, generally resulting in less copying and intermediate
variables
* Use of SignatureVerifier is replaced with a single call to
crypto::sign::Verify
That causes a design change. Previously, the Ecdsa class relied on
SignatureCreator, and creation of SignatureCreator could fail, so
Ecdsa also had to have a constructor that could fail (its ::Create
static method). Since construction of PublicKey *can't* fail unless the
public key is malformed, and we know the public key in advance (it is
hardcoded), Ecdsa no longer needs a fallible ::Create method. It is now
possible to directly construct an Ecdsa instance and hold it inline.
This change bubbles outwards to clients of Ecdsa, which now hold Ecdsa
instances as class members directly rather than as unique_ptrs, and
allows removing a bunch of conditions / failure paths from those client
classes.
Apart from that design change (which accounts for the bulk of the LOC in
this CL), this CL:
* Migrates some raw arrays to std::arrays, fixing unsafe bounds
warnings;
* Promotes some DCHECKs that indicate programmer errors to CHECKs in
line with current guidance;
* Removes some logic that decoded static public keys from hardcoded
base64 strings at runtime in favor of hardcoding the raw key bytes
instead, and removes some failure paths as a result;
* Removes the MISSING_PUBLIC_KEY error code, since this is now
impossible in RequestSender (the public key is hardcoded, and no
longer needs fallible base64 decoding);
* Adds assignment operators to crypto::keypair, which I forgot to do
when originally adding them but which are needed for Ecdsa to allow
replacing its internal keys for testing
Bug: 372283556
Change-Id: I1431aeebd83722eb45bab32330487a88bf73aaac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6427233
Reviewed-by: Carlos IL <carlosil@chromium.org>
Reviewed-by: Joshua Pawlicki <waffles@chromium.org>
Commit-Queue: Elly FJ <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1444203}