Module org.htmlunit

Class SubtleCrypto

java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.crypto.SubtleCrypto
All Implemented Interfaces:
Serializable, Cloneable, org.htmlunit.corejs.javascript.ConstProperties<org.htmlunit.corejs.javascript.Scriptable>, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable

public class SubtleCrypto extends HtmlUnitScriptable
A JavaScript object for SubtleCrypto.
Author:
Ahmed Ashour, Ronald Brill, Atsushi Nakagawa, Lai Quang Duong
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo, org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator, org.htmlunit.corejs.javascript.ScriptableObject.LambdaGetterFunction, org.htmlunit.corejs.javascript.ScriptableObject.LambdaSetterFunction
  • Field Summary

    Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST

    Fields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

    isSealed

    Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

    NOT_FOUND
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.htmlunit.corejs.javascript.NativePromise
    decrypt(Object algorithm, CryptoKey key, Object data)
    Decrypts data using the given key and algorithm.
    org.htmlunit.corejs.javascript.NativePromise
    Not yet implemented.
    org.htmlunit.corejs.javascript.NativePromise
    Not yet implemented.
    org.htmlunit.corejs.javascript.NativePromise
    digest(Object hashAlgorithm, Object data)
    Generates a digest of the given data.
    org.htmlunit.corejs.javascript.NativePromise
    encrypt(Object algorithm, CryptoKey key, Object data)
    Encrypts data using the given key and algorithm.
    org.htmlunit.corejs.javascript.NativePromise
    exportKey(String format, CryptoKey key)
    Exports a key in the specified format.
    org.htmlunit.corejs.javascript.NativePromise
    generateKey(org.htmlunit.corejs.javascript.Scriptable keyGenParams, boolean isExtractable, org.htmlunit.corejs.javascript.Scriptable keyUsages)
    Generates a new key (for symmetric algorithms) or key pair (for public-key algorithms).
    org.htmlunit.corejs.javascript.NativePromise
    importKey(String format, org.htmlunit.corejs.javascript.Scriptable keyData, org.htmlunit.corejs.javascript.Scriptable keyImportParams, boolean isExtractable, org.htmlunit.corejs.javascript.Scriptable keyUsages)
    Imports a key from external, portable key material.
    void
    Creates an instance.
    org.htmlunit.corejs.javascript.NativePromise
    sign(Object algorithm, CryptoKey key, Object data)
    Signs data using the given key.
    org.htmlunit.corejs.javascript.NativePromise
    Not yet implemented.
    org.htmlunit.corejs.javascript.NativePromise
    verify(Object algorithm, CryptoKey key, Object signature, Object data)
    Verifies a signature using the given key.
    org.htmlunit.corejs.javascript.NativePromise
    Not yet implemented.

    Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size

    Methods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

    associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMaps

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.htmlunit.corejs.javascript.Scriptable

    get, getIds, has, has

    Methods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable

    get, has
  • Constructor Details

    • SubtleCrypto

      public SubtleCrypto()
  • Method Details

    • jsConstructor

      public void jsConstructor()
      Creates an instance.
    • encrypt

      public org.htmlunit.corejs.javascript.NativePromise encrypt(Object algorithm, CryptoKey key, Object data)
      Encrypts data using the given key and algorithm.
      Parameters:
      algorithm - the algorithm identifier with parameters
      key - the CryptoKey to encrypt with
      data - the data to encrypt
      Returns:
      a Promise that fulfills with an ArrayBuffer containing the ciphertext
      See Also:
    • decrypt

      public org.htmlunit.corejs.javascript.NativePromise decrypt(Object algorithm, CryptoKey key, Object data)
      Decrypts data using the given key and algorithm.
      Parameters:
      algorithm - the algorithm identifier with parameters
      key - the CryptoKey to decrypt with
      data - the data to decrypt
      Returns:
      a Promise that fulfills with an ArrayBuffer containing the plaintext
      See Also:
    • sign

      public org.htmlunit.corejs.javascript.NativePromise sign(Object algorithm, CryptoKey key, Object data)
      Signs data using the given key.
      Parameters:
      algorithm - the algorithm identifier (String or object with name property)
      key - the CryptoKey to sign with
      data - the data to sign
      Returns:
      a Promise that fulfills with an ArrayBuffer containing the signature
      See Also:
    • verify

      public org.htmlunit.corejs.javascript.NativePromise verify(Object algorithm, CryptoKey key, Object signature, Object data)
      Verifies a signature using the given key.
      Parameters:
      algorithm - the algorithm identifier (String or object with name property)
      key - the CryptoKey to verify with
      signature - the signature to verify
      data - the data that was signed
      Returns:
      a Promise that fulfills with a boolean indicating whether the signature is valid
      See Also:
    • digest

      public org.htmlunit.corejs.javascript.NativePromise digest(Object hashAlgorithm, Object data)
      Generates a digest of the given data.
      Parameters:
      hashAlgorithm - a string or an object with a single property name containing the hash algorithm to use
      data - an object containing the data to be digested
      Returns:
      a Promise that fulfills with an ArrayBuffer containing the digest
      See Also:
    • generateKey

      public org.htmlunit.corejs.javascript.NativePromise generateKey(org.htmlunit.corejs.javascript.Scriptable keyGenParams, boolean isExtractable, org.htmlunit.corejs.javascript.Scriptable keyUsages)
      Generates a new key (for symmetric algorithms) or key pair (for public-key algorithms).
      Parameters:
      keyGenParams - algorithm-specific key generation parameters
      isExtractable - whether the key(s) can be exported
      keyUsages - permitted operations for the key(s)
      Returns:
      a Promise that fulfills with a CryptoKey or CryptoKeyPair
      See Also:
    • deriveKey

      public org.htmlunit.corejs.javascript.NativePromise deriveKey()
      Not yet implemented.
      Returns:
      a Promise which will be fulfilled with a CryptoKey object representing the new key
    • deriveBits

      public org.htmlunit.corejs.javascript.NativePromise deriveBits()
      Not yet implemented.
      Returns:
      a Promise which will be fulfilled with an ArrayBuffer containing the derived bits
    • importKey

      public org.htmlunit.corejs.javascript.NativePromise importKey(String format, org.htmlunit.corejs.javascript.Scriptable keyData, org.htmlunit.corejs.javascript.Scriptable keyImportParams, boolean isExtractable, org.htmlunit.corejs.javascript.Scriptable keyUsages)
      Imports a key from external, portable key material.
      Parameters:
      format - the data format ("raw", "pkcs8", "spki", "jwk")
      keyData - the key material (BufferSource for raw/pkcs8/spki, JsonWebKey for jwk)
      keyImportParams - algorithm-specific import parameters
      isExtractable - whether the key can be exported
      keyUsages - permitted operations for this key
      Returns:
      a Promise that fulfills with the imported CryptoKey
      See Also:
    • exportKey

      public org.htmlunit.corejs.javascript.NativePromise exportKey(String format, CryptoKey key)
      Exports a key in the specified format.
      Parameters:
      format - the data format ("raw", "pkcs8", "spki", "jwk")
      key - the CryptoKey to export
      Returns:
      a Promise that fulfills with the key data
      See Also:
    • wrapKey

      public org.htmlunit.corejs.javascript.NativePromise wrapKey()
      Not yet implemented.
      Returns:
      a Promise that fulfills with an ArrayBuffer containing the encrypted exported key
    • unwrapKey

      public org.htmlunit.corejs.javascript.NativePromise unwrapKey()
      Not yet implemented.
      Returns:
      a Promise that fulfills with the unwrapped key as a CryptoKey object