@haxall/haxall
    Preparing search index...

    Interface SubtleCrypto

    v15.0.0

    interface SubtleCrypto {
        decrypt(
            algorithm:
                | AlgorithmIdentifier
                | AesCbcParams
                | AesCtrParams
                | AesGcmParams
                | RsaOaepParams,
            key: CryptoKey,
            data: BufferSource,
        ): Promise<ArrayBuffer>;
        deriveBits(
            algorithm: EcdhKeyDeriveParams,
            baseKey: CryptoKey,
            length?: number,
        ): Promise<ArrayBuffer>;
        deriveBits(
            algorithm: EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
            baseKey: CryptoKey,
            length: number,
        ): Promise<ArrayBuffer>;
        deriveKey(
            algorithm: EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
            baseKey: CryptoKey,
            derivedKeyAlgorithm:
                | AlgorithmIdentifier
                | HmacImportParams
                | AesDerivedKeyParams,
            extractable: boolean,
            keyUsages: readonly KeyUsage[],
        ): Promise<CryptoKey>;
        digest(
            algorithm: AlgorithmIdentifier,
            data: BufferSource,
        ): Promise<ArrayBuffer>;
        encrypt(
            algorithm:
                | AlgorithmIdentifier
                | AesCbcParams
                | AesCtrParams
                | AesGcmParams
                | RsaOaepParams,
            key: CryptoKey,
            data: BufferSource,
        ): Promise<ArrayBuffer>;
        exportKey(format: "jwk", key: CryptoKey): Promise<webcrypto.JsonWebKey>;
        exportKey(
            format: "spki" | "pkcs8" | "raw",
            key: CryptoKey,
        ): Promise<ArrayBuffer>;
        generateKey(
            algorithm: EcKeyGenParams | RsaHashedKeyGenParams,
            extractable: boolean,
            keyUsages: readonly KeyUsage[],
        ): Promise<CryptoKeyPair>;
        generateKey(
            algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params,
            extractable: boolean,
            keyUsages: readonly KeyUsage[],
        ): Promise<CryptoKey>;
        generateKey(
            algorithm: AlgorithmIdentifier,
            extractable: boolean,
            keyUsages: KeyUsage[],
        ): Promise<CryptoKey | CryptoKeyPair>;
        importKey(
            format: "jwk",
            keyData: webcrypto.JsonWebKey,
            algorithm:
                | AlgorithmIdentifier
                | RsaHashedImportParams
                | EcKeyImportParams
                | HmacImportParams
                | AesKeyAlgorithm,
            extractable: boolean,
            keyUsages: readonly KeyUsage[],
        ): Promise<CryptoKey>;
        importKey(
            format: "spki" | "pkcs8" | "raw",
            keyData: BufferSource,
            algorithm:
                | AlgorithmIdentifier
                | RsaHashedImportParams
                | EcKeyImportParams
                | HmacImportParams
                | AesKeyAlgorithm,
            extractable: boolean,
            keyUsages: KeyUsage[],
        ): Promise<CryptoKey>;
        sign(
            algorithm:
                | AlgorithmIdentifier
                | EcdsaParams
                | Ed448Params
                | RsaPssParams,
            key: CryptoKey,
            data: BufferSource,
        ): Promise<ArrayBuffer>;
        unwrapKey(
            format: webcrypto.KeyFormat,
            wrappedKey: BufferSource,
            unwrappingKey: CryptoKey,
            unwrapAlgorithm:
                | AlgorithmIdentifier
                | AesCbcParams
                | AesCtrParams
                | AesGcmParams
                | RsaOaepParams,
            unwrappedKeyAlgorithm:
                | AlgorithmIdentifier
                | RsaHashedImportParams
                | EcKeyImportParams
                | HmacImportParams
                | AesKeyAlgorithm,
            extractable: boolean,
            keyUsages: KeyUsage[],
        ): Promise<CryptoKey>;
        verify(
            algorithm:
                | AlgorithmIdentifier
                | EcdsaParams
                | Ed448Params
                | RsaPssParams,
            key: CryptoKey,
            signature: BufferSource,
            data: BufferSource,
        ): Promise<boolean>;
        wrapKey(
            format: webcrypto.KeyFormat,
            key: CryptoKey,
            wrappingKey: CryptoKey,
            wrapAlgorithm:
                | AlgorithmIdentifier
                | AesCbcParams
                | AesCtrParams
                | AesGcmParams
                | RsaOaepParams,
        ): Promise<ArrayBuffer>;
    }
    Index

    Methods

    • Using the method and parameters specified in algorithm and the keying material provided by baseKey, subtle.deriveBits() attempts to generate length bits. The Node.js implementation requires that when length is a number it must be multiple of 8. When length is null the maximum number of bits for a given algorithm is generated. This is allowed for the 'ECDH', 'X25519', and 'X448' algorithms. If successful, the returned promise will be resolved with an <ArrayBuffer> containing the generated data.

      The algorithms currently supported include:

      • 'ECDH'
      • 'X25519'
      • 'X448'
      • 'HKDF'
      • 'PBKDF2'

      Parameters

      Returns Promise<ArrayBuffer>

      v15.0.0

    • Parameters

      Returns Promise<ArrayBuffer>

    • Using the method identified by algorithm, subtle.digest() attempts to generate a digest of data. If successful, the returned promise is resolved with an <ArrayBuffer> containing the computed digest.

      If algorithm is provided as a <string>, it must be one of:

      • 'SHA-1'
      • 'SHA-256'
      • 'SHA-384'
      • 'SHA-512'

      If algorithm is provided as an <Object>, it must have a name property whose value is one of the above.

      Parameters

      Returns Promise<ArrayBuffer>

      v15.0.0

    • Exports the given key into the specified format, if supported.

      If the <CryptoKey> is not extractable, the returned promise will reject.

      When format is either 'pkcs8' or 'spki' and the export is successful, the returned promise will be resolved with an <ArrayBuffer> containing the exported key data.

      When format is 'jwk' and the export is successful, the returned promise will be resolved with a JavaScript object conforming to the JSON Web Key specification.

      Parameters

      • format: "jwk"

        Must be one of 'raw', 'pkcs8', 'spki', or 'jwk'.

      • key: CryptoKey

      Returns Promise<webcrypto.JsonWebKey>

      <Promise> containing <ArrayBuffer>.

      v15.0.0

    • Parameters

      • format: "spki" | "pkcs8" | "raw"
      • key: CryptoKey

      Returns Promise<ArrayBuffer>

    • Using the method and parameters given by algorithm and the keying material provided by key, subtle.sign() attempts to generate a cryptographic signature of data. If successful, the returned promise is resolved with an <ArrayBuffer> containing the generated signature.

      The algorithms currently supported include:

      • 'RSASSA-PKCS1-v1_5'
      • 'RSA-PSS'
      • 'ECDSA'
      • 'Ed25519'
      • 'Ed448'
      • 'HMAC'

      Returns Promise<ArrayBuffer>

      v15.0.0

    • In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material. The subtle.wrapKey() method exports the keying material into the format identified by format, then encrypts it using the method and parameters specified by wrapAlgo and the keying material provided by wrappingKey. It is the equivalent to calling subtle.exportKey() using format and key as the arguments, then passing the result to the subtle.encrypt() method using wrappingKey and wrapAlgo as inputs. If successful, the returned promise will be resolved with an <ArrayBuffer> containing the encrypted key data.

      The wrapping algorithms currently supported include:

      • 'RSA-OAEP'
      • 'AES-CTR'
      • 'AES-CBC'
      • 'AES-GCM'
      • 'AES-KW'

      Parameters

      Returns Promise<ArrayBuffer>

      v15.0.0