importSec1DerOrThrow
importSec1DerOrThrow
Import an EC private key from DER-encoded SEC 1 ECPrivateKey.
SEC 1 is the legacy EC-only format. Internally converts to PKCS#8 for import. When the ECPrivateKey carries the optional RFC 5915 parameters [0] field (OpenSSL always writes it), its named-curve OID must match algorithm.curve; when the field is absent, the caller-supplied curve is trusted.
When algorithm is omitted, the curve is inferred from the embedded parameters [0] field; a key without a supported named curve then fails.
ts
function importSec1DerOrThrow(
der: Uint8Array,
algorithm?: ImportEcKeyInput,
): Promise<CryptoKey>Parameters
der:Uint8Arrayalgorithm?:ImportEcKeyInput
Throws
Error— If DER is not an ECPrivateKey, its embedded curve doesn't matchalgorithm, or no curve is available (neither embedded nor supplied)
See also
exportSec1Derfor the inverse operationimportSec1Pemfor PEM input