import { PublicKey } from "https://deno.land/x/fido2@3.2.5/lib/keyUtils.js";
Class representing a generic public key, with utility functions to convert between different formats using Webcrypto
Methods
fromCose(cose)
Import public key from COSE data. Throws on any type of failure.
Internally this function converts COSE to a JWK, then calls .fromJwk() to import key to CryptoKey
Returns internal algorithm, which should be of one of the following formats
- RsaHashedImportParams
- EcKeyImportParams
- undefined
getKey()
Returns internal key in CryptoKey format
- Mainly intended for internal use
- Throws if internal CryptoKey does not exist
setAlgorithm(algorithmInput)
Sets internal algorithm identifier in format used by webcrypto, should be one of
- Allows adding missing properties
- Makes sure
alg.hash
is is{ hash: { name: 'foo'} }
format - Syncs back updated algorithm to this._key
toCose()
Exports public key to COSE data
- Only works if original cose data from 'fromCose()' is available
- Throws on any kind of failure
toJwk()
Exports public key to JWK.
- Only works if original jwk from 'fromJwk()' is available
- Throws on any kind of failure
toPem(forcedExport)
Exports public key to PEM.
- Reuses original PEM string if present.
- Possible to force regeneration of PEM string by setting 'forcedExport' parameter to true
- Throws on any kind of failure