Digital signatures
Digital signatures are the last class of cryptographic operations we learned about as we dedicated the biggest part of Chapter 6, Digital Signatures with Node.js and Trust, to them. Once again, in this section we'll revisit them by showing code samples that work in the browser using the WebCrypto APIs instead. Just as we did in Chapter 6, Digital Signatures with Node.js and Trust, we'll look at examples of calculating and verifying digital signatures using both RSA and ECDSA.
Digital signatures with the WebCrypto APIs
With the WebCrypto APIs, we can calculate a signature with the crypto.subtle.sign(algorithm, key, data)
method. This returns a promise that resolves with an ArrayBuffer
containing our signature's raw bytes, and it requires three parameters:
algorithm
, the first argument, is an object that contains options for the digital signature algorithm to use. We'll see the details of this in the following sections for the RSA...