PKI-Lite - v1.0.5
    Preparing search index...

    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.

    const provider = new WebCryptoExtendedProvider();
    const hash = await provider.digest(data, 'MD5');
    const encrypted = await provider.encryptSymmetric(data, key, { type: 'AES_128_ECB' });
    const decrypted = await provider.decryptSymmetric(encryptedData, key, { type: 'AES_128_ECB' });
    const rsaEncrypted = await provider.encrypt(data, publicKeyInfo, { type: 'RSASSA_PKCS1_v1_5' });
    const rsaDecrypted = await provider.decrypt(rsaEncryptedData, privateKeyInfo, { type: 'RSASSA_PKCS1_v1_5' });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    crypto: { subtle: SubtleCrypto }

    Reference to the Web Crypto API interface. Protected to allow testing with mock implementations.

    Methods

    • Converts symmetric encryption algorithm parameters to a content encryption algorithm identifier.

      Parameters

      • encryptionParams:
            | SymmetricEncryptionAlgorithmParams
            | {
                params: {
                    derivationAlgorithm: {
                        params: {
                            hash: HashAlgorithm;
                            iterationCount: number;
                            keyLength?: number;
                            salt: Uint8Array;
                        };
                        type: "PBKDF2";
                    };
                    encryptionAlgorithm: SymmetricEncryptionAlgorithmParams;
                };
                type: "PBES2";
            }

        The symmetric encryption algorithm parameters

      Returns AlgorithmIdentifier

      Content encryption algorithm as an AlgorithmIdentifier

    • Parameters

      • password: string | Uint8Array<ArrayBufferLike> | CryptoKey
      • algorithm: {
            params: {
                derivationAlgorithm: {
                    params: {
                        hash: HashAlgorithm;
                        iterationCount: number;
                        keyLength?: number;
                        salt: Uint8Array;
                    };
                    type: "PBKDF2";
                };
                encryptionAlgorithm: SymmetricEncryptionAlgorithmParams;
            };
            type: "PBES2";
        }

      Returns Promise<CryptoKey>

    • Derives a cryptographic key from a password using the specified algorithm.

      Parameters

      • password: string | Uint8Array<ArrayBufferLike> | CryptoKey

        The password or key material to derive from

      • algorithm: {
            params: {
                derivationAlgorithm: {
                    params: {
                        hash: HashAlgorithm;
                        iterationCount: number;
                        keyLength?: number;
                        salt: Uint8Array;
                    };
                    type: "PBKDF2";
                };
                encryptionAlgorithm: SymmetricEncryptionAlgorithmParams;
            };
            type: "PBES2";
        }

        The key derivation algorithm parameters

      Returns Promise<Uint8Array<ArrayBufferLike>>

      Promise resolving to the derived key as a Uint8Array

    • Generates an asymmetric key pair for the specified algorithm and options.

      Parameters

      • options: {
            algorithm: "RSA" | "EC";
            hash?: string;
            keySize?: number;
            namedCurve?: string;
            publicExponent?: Uint8Array<ArrayBufferLike>;
        }

        Configuration options including algorithm, key size, and other parameters

      Returns Promise<{ privateKey: Uint8Array; publicKey: Uint8Array }>

      A Promise that resolves to an object containing the public and private keys

    • Parameters

      • password: string | Uint8Array<ArrayBufferLike>

      Returns Promise<CryptoKey>

    • Generates cryptographically secure random bytes.

      Parameters

      • length: number

        The number of random bytes to generate

      Returns Uint8Array

      Array containing the random bytes

    • Internal

      Converts PKI algorithm parameters to Web Crypto API algorithm specification.

      Parameters

      Returns RsaPssParams | EcKeyImportParams | RsaOaepParams | RsaHashedKeyAlgorithm

      Web Crypto API compatible algorithm specification

    • Parameters

      • algorithm: {
            params: {
                hash: HashAlgorithm;
                iterationCount: number;
                keyLength?: number;
                salt: Uint8Array;
            };
            type: "PBKDF2";
        }

      Returns Pbkdf2Params

    • Parameters

      • algorithm:
            | "SHA1_3DES_2KEY_CBC"
            | "SHA1_3DES_3KEY_CBC"
            | "SHA1_RC2_40_CBC"
            | "SHA1_RC2_128_CBC"
            | "AES_128_GCM"
            | "AES_192_GCM"
            | "AES_256_GCM"
            | "AES_128_CCM"
            | "AES_192_CCM"
            | "AES_256_CCM"
            | "AES_128_CBC"
            | "AES_192_CBC"
            | "AES_256_CBC"
            | "AES_128_ECB"
            | "AES_192_ECB"
            | "AES_256_ECB"
            | "PBES2"

      Returns AesDerivedKeyParams

    • Parameters

      Returns {
          params: {
              hash: HashAlgorithm;
              iterationCount: number;
              keyLength?: number;
              salt: Uint8Array;
          };
          type: "PBKDF2";
      }

    • Parameters

      Returns {
          params: {
              derivationAlgorithm: {
                  params: {
                      hash: HashAlgorithm;
                      iterationCount: number;
                      keyLength?: number;
                      salt: Uint8Array;
                  };
                  type: "PBKDF2";
              };
              encryptionAlgorithm: SymmetricEncryptionAlgorithmParams;
          };
          type: "PBES2";
      }