Protected
cryptoReference to the Web Crypto API interface. Protected to allow testing with mock implementations.
Converts symmetric encryption algorithm parameters to a content encryption algorithm identifier.
The symmetric encryption algorithm parameters
Content encryption algorithm as an AlgorithmIdentifier
Decrypts the given data using the specified private key and asymmetric algorithm.
The data to decrypt
The private key information
The decryption algorithm to use
Promise resolving to the decrypted data as a Uint8Array
Decrypts the given data using the specified symmetric key and algorithm.
The data to decrypt
The symmetric key to use for decryption
The decryption algorithm to use
Promise resolving to the decrypted data as a Uint8Array
Protected
deriveDerives a cryptographic key from a password using the specified algorithm.
The password or key material to derive from
The key derivation algorithm parameters
Promise resolving to the derived key as a Uint8Array
Computes a cryptographic hash of the input data.
The data to hash
The hash algorithm to use
The computed hash bytes
Converts a hash algorithm to a digest algorithm identifier.
The hash algorithm
Digest algorithm as a Uint8Array or AlgorithmIdentifier
Encrypts data using asymmetric (public key) cryptography.
The data to encrypt
The public key information
The encryption algorithm to use
Promise resolving to the encrypted data as a Uint8Array
Encrypts the given data using the specified symmetric key and algorithm.
The data to encrypt
The symmetric key to use for encryption
The encryption algorithm to use
Promise resolving to the encrypted data as a Uint8Array
Generates an asymmetric key pair for the specified algorithm and options.
Configuration options including algorithm, key size, and other parameters
A Promise that resolves to an object containing the public and private keys
Generates a symmetric key for the specified encryption algorithm.
The encryption algorithm to use
The generated symmetric key as a Uint8Array
Gets the EC curve parameters for a given asymmetric encryption algorithm.
The asymmetric encryption algorithm parameters
EC curve parameters as a Uint8Array or ObjectIdentifier
Extracts the EC named curve from an algorithm identifier or public key.
The ASN.1 algorithm identifier
Optional
publicKeyInfo: SubjectPublicKeyInfoOptional public key information to extract curve from
The EC named curve identifier
Protected
getGenerates cryptographically secure random bytes.
The number of random bytes to generate
Array containing the random bytes
Internal
Converts PKI algorithm parameters to Web Crypto API algorithm specification.
The PKI algorithm parameters
Web Crypto API compatible algorithm specification
Converts asymmetric encryption algorithm parameters to a key encryption algorithm identifier.
The asymmetric encryption algorithm parameters
Key encryption algorithm as an AlgorithmIdentifier
Creates a digital signature for the given data.
The data to sign
The signer's private key
The signature algorithm and parameters
Promise resolving to the signature bytes
Converts asymmetric encryption algorithm parameters to a signature algorithm identifier.
The asymmetric encryption algorithm parameters
Signature algorithm as a Uint8Array or AlgorithmIdentifier
Converts an ASN.1 algorithm identifier to asymmetric encryption algorithm parameters.
The ASN.1 algorithm identifier
Optional
publicKeyInfo: SubjectPublicKeyInfoOptional public key information for context
Asymmetric encryption algorithm parameters
Converts an ASN.1 algorithm identifier to a hash algorithm.
The ASN.1 algorithm identifier
The hash algorithm
Converts an ASN.1 algorithm identifier to symmetric encryption algorithm parameters.
The ASN.1 algorithm identifier
Symmetric encryption algorithm parameters
Verifies a digital signature against the original data.
The original data that was signed
The signer's public key
The signature to verify
The signature algorithm and parameters
Promise resolving to true if signature is valid
Extended WebCryptoProvider that adds support for additional algorithms such as MD5 hashing, AES ECB mode, and certain PBE algorithms.
Note: This implementation uses the 'node-forge' library for RSA encryption/decryption with PKCS#1 v1.5 padding, as WebCrypto does not support this mode directly.
Caution: MD5 is considered cryptographically weak and should be used with caution. This provider is intended for compatibility with legacy systems and not for secure applications.
Example