micro509/keys
Generate keys and move them between WebCrypto, PEM, DER, and JWK formats.
Start with generateKeyPair. Load a private key with importPkcs8Pem, or protect an exported key with exportEncryptedPkcs8Pem.
Functions
decryptRsaOaep— Decrypt an RSA-OAEP ciphertext with the matching private key.decryptRsaOaepOrThrow— Decrypt an RSA-OAEP ciphertext with the matching private key.derivePublicKey— Derive the matching public key from an imported (or generated) private key.encryptRsaOaep— Encrypt a small message with an RSA-OAEP public key.encryptRsaOaepOrThrow— Encrypt a small message with an RSA-OAEP public key.exportBinaryBase64— Export a key as raw base64 (no PEM headers).exportEncryptedPkcs1Pem— Export an RSA private key as legacyProc-Type: 4,ENCRYPTEDPEM (PKCS#1).exportEncryptedPkcs8Der— Export a private key as DER-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.exportEncryptedPkcs8Pem— Export a private key as PEM-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.exportEncryptedSec1Pem— Export an EC private key as legacyProc-Type: 4,ENCRYPTEDPEM (SEC 1).exportPkcs1Der— Export an RSA private key as DER-encoded PKCS#1 RSAPrivateKey.exportPkcs1Pem— Export an RSA private key as PEM-encoded PKCS#1 RSAPrivateKey.exportPkcs8Der— Export a private key as DER-encoded PKCS#8 PrivateKeyInfo.exportPkcs8Pem— Export a private key as PEM-encoded PKCS#8 PrivateKeyInfo.exportPrivateJwk— Export a private key as a JSON Web Key.exportPublicJwk— Export a public key as a JSON Web Key.exportSec1Der— Export an EC private key as DER-encoded SEC 1 ECPrivateKey.exportSec1Pem— Export an EC private key as PEM-encoded SEC 1 ECPrivateKey.exportSpkiDer— Export a public key as DER-encoded SubjectPublicKeyInfo.exportSpkiPem— Export a public key as PEM-encoded SubjectPublicKeyInfo.generateKeyPair— Generate an asymmetric key pair for signing and verification, or — withimportEncryptedPkcs1Pem— Import an RSA private key from legacyProc-Type: 4,ENCRYPTEDPEM (PKCS#1).importEncryptedPkcs1PemOrThrow— Import an RSA private key from legacyProc-Type: 4,ENCRYPTEDPEM (PKCS#1).importEncryptedPkcs8Der— Import a private key from DER-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.importEncryptedPkcs8DerOrThrow— Import a private key from DER-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.importEncryptedPkcs8Pem— Import a private key from PEM-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.importEncryptedPkcs8PemOrThrow— Import a private key from PEM-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.importEncryptedSec1Pem— Import an EC private key from legacyProc-Type: 4,ENCRYPTEDPEM (SEC 1).importEncryptedSec1PemOrThrow— Import an EC private key from legacyProc-Type: 4,ENCRYPTEDPEM (SEC 1).importPkcs1Der— Import an RSA private key from DER-encoded PKCS#1 RSAPrivateKey.importPkcs1DerOrThrow— Import an RSA private key from DER-encoded PKCS#1 RSAPrivateKey.importPkcs1Pem— Import an RSA private key from PEM-encoded PKCS#1 RSAPrivateKey.importPkcs1PemOrThrow— Import an RSA private key from PEM-encoded PKCS#1 RSAPrivateKey.importPkcs8Base64— Import a private key from base64-encoded PKCS#8 PrivateKeyInfo (no PEM headers).importPkcs8Base64OrThrow— Import a private key from base64-encoded PKCS#8 PrivateKeyInfo (no PEM headers).importPkcs8Der— Import a private key from DER-encoded PKCS#8 PrivateKeyInfo.importPkcs8DerOrThrow— Import a private key from DER-encoded PKCS#8 PrivateKeyInfo.importPkcs8Pem— Import a private key from PEM-encoded PKCS#8 PrivateKeyInfo.importPkcs8PemOrThrow— Import a private key from PEM-encoded PKCS#8 PrivateKeyInfo.importPrivateJwk— Import a private signing key from a JSON Web Key.importPrivateJwkOrThrow— Import a private signing key from a JSON Web Key.importPublicJwk— Import a public verification key from a JSON Web Key.importPublicJwkOrThrow— Import a public verification key from a JSON Web Key.importSec1Der— Import an EC private key from DER-encoded SEC 1 ECPrivateKey.importSec1DerOrThrow— Import an EC private key from DER-encoded SEC 1 ECPrivateKey.importSec1Pem— Import an EC private key from PEM-encoded SEC 1 ECPrivateKey.importSec1PemOrThrow— Import an EC private key from PEM-encoded SEC 1 ECPrivateKey.importSpkiBase64— Import a public key from base64-encoded SubjectPublicKeyInfo (no PEM headers).importSpkiBase64OrThrow— Import a public key from base64-encoded SubjectPublicKeyInfo (no PEM headers).importSpkiDer— Import a public key from DER-encoded SubjectPublicKeyInfo.importSpkiDerOrThrow— Import a public key from DER-encoded SubjectPublicKeyInfo.importSpkiPem— Import a public key from PEM-encoded SubjectPublicKeyInfo.importSpkiPemOrThrow— Import a public key from PEM-encoded SubjectPublicKeyInfo.inspectEncryptedPkcs8Der— Reads the PBES2 encryption parameters of a DER PKCS#8parsePbes2AlgorithmIdentifier— Decodes a DER-encoded PBES2 AlgorithmIdentifier into structuredPbes2Parameters.
Types
DecryptRsaOaepErrorCode— Machine-readable failure reason fordecryptRsaOaep.DecryptRsaOaepFailure— Structured failure payload fordecryptRsaOaep.DecryptRsaOaepResult— Success-or-failure result returned bydecryptRsaOaep.EcKeyAlgorithmInput— ECDSA variant ofKeyAlgorithmInput.EcNamedCurve— NIST elliptic curve for ECDSA keys.Ed25519KeyAlgorithmInput— Ed25519 variant ofKeyAlgorithmInput.EncryptedPkcs8Options— PBES2 encryption options for the encrypted PKCS#8 export/import functions.EncryptRsaOaepErrorCode— Machine-readable failure reason forencryptRsaOaep.EncryptRsaOaepFailure— Structured failure payload forencryptRsaOaep.EncryptRsaOaepResult— Success-or-failure result returned byencryptRsaOaep.ImportEcKeyInput— ECDSA variant ofPublicKeyImportInput/PrivateKeyImportInput.ImportEd25519KeyInput— Ed25519 variant ofPublicKeyImportInput/PrivateKeyImportInput.ImportEncryptedKeyErrorCode— Machine-readable failure reason for theimportEncrypted*key functions.ImportEncryptedKeyFailure— Structured failure payload for encrypted key import.ImportEncryptedKeyOptions— Options for the encrypted PKCS#8 import functions.ImportEncryptedKeyResult— Success-or-failure result returned by the publicimportEncrypted*key functions.ImportKeyErrorCode— Machine-readable failure reason for theimport*key functions.ImportKeyFailure— Structured failure payload for key import.ImportKeyResult— Success-or-failure result returned by the publicimport*key functions.ImportRsaKeyInput— RSA variant ofPublicKeyImportInput/PrivateKeyImportInput.KdfLimitOptions— Caller-supplied bound on password-based KDF work.KeyAlgorithmInput— Input forgenerateKeyPair. Selects algorithm family and parameters.KeyPairMaterial— Key pair with convenience export helpers. Returned bygenerateKeyPair.LegacyPemEncryptionOptions— Options for OpenSSL-styleProc-Type: 4,ENCRYPTEDPEM encryption (PKCS#1/SEC1).Pbes2EncryptionOptions— Input forencryptPbes2.Pbes2EncryptionScheme— AES-CBC key sizes supported by this PBES2 implementation.Pbes2Parameters— Resolved PBES2 algorithm parameters, either parsed from DER or built byencryptPbes2.Pbes2Prf— PBKDF2 pseudo-random function choices.HMAC-SHA-1is the RFC default;HMAC-SHA-256is preferred.PrivateKeyImportInput— Algorithm descriptor for private key import functions. Same shape asPublicKeyImportInput.PublicKeyImportInput— Algorithm descriptor for public key import functions.RsaHash— Hash algorithm paired with an RSA key.RsaKeyAlgorithmInput— RSA variant ofKeyAlgorithmInput.RsaOaepOptions— Options shared byencryptRsaOaepanddecryptRsaOaep.RsaScheme— RSA padding scheme: a signature scheme, or'oaep'for RSA-OAEP encryptionRsaSignatureScheme— RSA signature padding scheme.