SubtleCrypto

open class SubtleCrypto(source)

The SubtleCrypto interface of the Web Crypto API provides a number of low-level cryptographic functions. Available only in secure contexts.

MDN Reference

Functions

Link copied to clipboard
inline suspend fun SubtleCrypto.decrypt(algorithm: String, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.decrypt(algorithm: AesCbcParams, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.decrypt(algorithm: AesCtrParams, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.decrypt(algorithm: AesGcmParams, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.decrypt(algorithm: Algorithm, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.decrypt(algorithm: RsaOaepParams, key: CryptoKey, data: BufferSource): ArrayBuffer

The decrypt() method of the SubtleCrypto interface decrypts some encrypted data. It takes as arguments a key to decrypt with, some optional extra parameters, and the data to decrypt (also known as "ciphertext"). It returns a Promise which will be fulfilled with the decrypted data (also known as "plaintext").

Link copied to clipboard
external fun decryptAsync(algorithm: String, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun decryptAsync(algorithm: AesCbcParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun decryptAsync(algorithm: AesCtrParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun decryptAsync(algorithm: AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun decryptAsync(algorithm: Algorithm, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun decryptAsync(algorithm: RsaOaepParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>

The decrypt() method of the SubtleCrypto interface decrypts some encrypted data. It takes as arguments a key to decrypt with, some optional extra parameters, and the data to decrypt (also known as "ciphertext"). It returns a Promise which will be fulfilled with the decrypted data (also known as "plaintext").

Link copied to clipboard
inline suspend fun SubtleCrypto.deriveBits(algorithm: String, baseKey: CryptoKey): ArrayBuffer
inline suspend fun SubtleCrypto.deriveBits(algorithm: Algorithm, baseKey: CryptoKey): ArrayBuffer
inline suspend fun SubtleCrypto.deriveBits(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey): ArrayBuffer
inline suspend fun SubtleCrypto.deriveBits(algorithm: HkdfParams, baseKey: CryptoKey): ArrayBuffer
inline suspend fun SubtleCrypto.deriveBits(algorithm: Pbkdf2Params, baseKey: CryptoKey): ArrayBuffer
inline suspend fun SubtleCrypto.deriveBits(algorithm: String, baseKey: CryptoKey, length: Int?): ArrayBuffer
inline suspend fun SubtleCrypto.deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: Int?): ArrayBuffer
inline suspend fun SubtleCrypto.deriveBits(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, length: Int?): ArrayBuffer
inline suspend fun SubtleCrypto.deriveBits(algorithm: HkdfParams, baseKey: CryptoKey, length: Int?): ArrayBuffer
inline suspend fun SubtleCrypto.deriveBits(algorithm: Pbkdf2Params, baseKey: CryptoKey, length: Int?): ArrayBuffer

The deriveBits() method of the SubtleCrypto interface can be used to derive an array of bits from a base key.

Link copied to clipboard
external fun deriveBitsAsync(algorithm: String, baseKey: CryptoKey, length: Int? = definedExternally): Promise<ArrayBuffer>
external fun deriveBitsAsync(algorithm: Algorithm, baseKey: CryptoKey, length: Int? = definedExternally): Promise<ArrayBuffer>
external fun deriveBitsAsync(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, length: Int? = definedExternally): Promise<ArrayBuffer>
external fun deriveBitsAsync(algorithm: HkdfParams, baseKey: CryptoKey, length: Int? = definedExternally): Promise<ArrayBuffer>
external fun deriveBitsAsync(algorithm: Pbkdf2Params, baseKey: CryptoKey, length: Int? = definedExternally): Promise<ArrayBuffer>

The deriveBits() method of the SubtleCrypto interface can be used to derive an array of bits from a base key.

Link copied to clipboard
inline suspend fun SubtleCrypto.deriveKey(algorithm: String, baseKey: CryptoKey, derivedKeyType: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: String, baseKey: CryptoKey, derivedKeyType: AesDerivedKeyParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: String, baseKey: CryptoKey, derivedKeyType: HkdfParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: String, baseKey: CryptoKey, derivedKeyType: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: String, baseKey: CryptoKey, derivedKeyType: Pbkdf2Params, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: AesDerivedKeyParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: HkdfParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Pbkdf2Params, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, derivedKeyType: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, derivedKeyType: AesDerivedKeyParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, derivedKeyType: HkdfParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, derivedKeyType: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, derivedKeyType: Pbkdf2Params, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: AesDerivedKeyParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: HkdfParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: Pbkdf2Params, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AesDerivedKeyParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: HkdfParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.deriveKey(algorithm: Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: Pbkdf2Params, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey

The deriveKey() method of the SubtleCrypto interface can be used to derive a secret key from a master key.

Link copied to clipboard
external fun deriveKeyAsync(algorithm: String, baseKey: CryptoKey, derivedKeyType: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: String, baseKey: CryptoKey, derivedKeyType: AesDerivedKeyParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: String, baseKey: CryptoKey, derivedKeyType: HkdfParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: String, baseKey: CryptoKey, derivedKeyType: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: String, baseKey: CryptoKey, derivedKeyType: Pbkdf2Params, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: AesDerivedKeyParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: HkdfParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Pbkdf2Params, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, derivedKeyType: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, derivedKeyType: AesDerivedKeyParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, derivedKeyType: HkdfParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, derivedKeyType: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, derivedKeyType: Pbkdf2Params, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: AesDerivedKeyParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: HkdfParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: HkdfParams, baseKey: CryptoKey, derivedKeyType: Pbkdf2Params, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AesDerivedKeyParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: HkdfParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun deriveKeyAsync(algorithm: Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: Pbkdf2Params, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>

The deriveKey() method of the SubtleCrypto interface can be used to derive a secret key from a master key.

Link copied to clipboard
inline suspend fun SubtleCrypto.digest(algorithm: String, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.digest(algorithm: Algorithm, data: BufferSource): ArrayBuffer

The digest() method of the SubtleCrypto interface generates a digest of the given data, using the specified hash function. A digest is a short fixed-length value derived from some variable-length input. Cryptographic digests should exhibit collision-resistance, meaning that it's hard to come up with two different inputs that have the same digest value.

Link copied to clipboard
external fun digestAsync(algorithm: String, data: BufferSource): Promise<ArrayBuffer>
external fun digestAsync(algorithm: Algorithm, data: BufferSource): Promise<ArrayBuffer>

The digest() method of the SubtleCrypto interface generates a digest of the given data, using the specified hash function. A digest is a short fixed-length value derived from some variable-length input. Cryptographic digests should exhibit collision-resistance, meaning that it's hard to come up with two different inputs that have the same digest value.

Link copied to clipboard
inline suspend fun SubtleCrypto.encrypt(algorithm: String, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.encrypt(algorithm: AesCbcParams, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.encrypt(algorithm: AesCtrParams, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.encrypt(algorithm: AesGcmParams, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.encrypt(algorithm: Algorithm, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.encrypt(algorithm: RsaOaepParams, key: CryptoKey, data: BufferSource): ArrayBuffer

The encrypt() method of the SubtleCrypto interface encrypts data.

Link copied to clipboard
external fun encryptAsync(algorithm: String, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun encryptAsync(algorithm: AesCbcParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun encryptAsync(algorithm: AesCtrParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun encryptAsync(algorithm: AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun encryptAsync(algorithm: Algorithm, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun encryptAsync(algorithm: RsaOaepParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>

The encrypt() method of the SubtleCrypto interface encrypts data.

Link copied to clipboard
inline suspend fun SubtleCrypto.exportKey(format: KeyFormat, key: CryptoKey): ArrayBuffer

inline suspend fun SubtleCrypto.exportKey(format: KeyFormat.jwk, key: CryptoKey): JsonWebKey

The exportKey() method of the SubtleCrypto interface exports a key: that is, it takes as input a CryptoKey object and gives you the key in an external, portable format.

Link copied to clipboard
external fun exportKeyAsync(format: KeyFormat, key: CryptoKey): Promise<ArrayBuffer>

The exportKey() method of the SubtleCrypto interface exports a key: that is, it takes as input a CryptoKey object and gives you the key in an external, portable format.

Link copied to clipboard
inline suspend fun SubtleCrypto.generateKey(algorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): JsAny
inline suspend fun SubtleCrypto.generateKey(algorithm: AesKeyGenParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.generateKey(algorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): JsAny
inline suspend fun SubtleCrypto.generateKey(algorithm: EcKeyGenParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKeyPair
inline suspend fun SubtleCrypto.generateKey(algorithm: HmacKeyGenParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.generateKey(algorithm: Pbkdf2Params, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.generateKey(algorithm: RsaHashedKeyGenParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKeyPair
inline suspend fun SubtleCrypto.generateKey(algorithm: X25519Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKeyPair

inline suspend fun SubtleCrypto.generateKey(algorithm: Ed25519Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKeyPair

The generateKey() method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).

Link copied to clipboard
external fun generateKeyAsync(algorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<JsAny>
external fun generateKeyAsync(algorithm: AesKeyGenParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun generateKeyAsync(algorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<JsAny>
external fun generateKeyAsync(algorithm: EcKeyGenParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>
external fun generateKeyAsync(algorithm: HmacKeyGenParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun generateKeyAsync(algorithm: Pbkdf2Params, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun generateKeyAsync(algorithm: RsaHashedKeyGenParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>
external fun generateKeyAsync(algorithm: X25519Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>

external fun generateKeyAsync(algorithm: Ed25519Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>

The generateKey() method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).

Link copied to clipboard
inline suspend fun SubtleCrypto.importKey(format: KeyFormat, keyData: BufferSource, algorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.importKey(format: KeyFormat, keyData: BufferSource, algorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.importKey(format: KeyFormat, keyData: BufferSource, algorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.importKey(format: KeyFormat, keyData: BufferSource, algorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.importKey(format: KeyFormat, keyData: BufferSource, algorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.importKey(format: KeyFormat, keyData: BufferSource, algorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey

inline suspend fun SubtleCrypto.importKey(format: KeyFormat.jwk, keyData: JsonWebKey, algorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.importKey(format: KeyFormat.jwk, keyData: JsonWebKey, algorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.importKey(format: KeyFormat.jwk, keyData: JsonWebKey, algorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.importKey(format: KeyFormat.jwk, keyData: JsonWebKey, algorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.importKey(format: KeyFormat.jwk, keyData: JsonWebKey, algorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.importKey(format: KeyFormat.jwk, keyData: JsonWebKey, algorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey

The importKey() method of the SubtleCrypto interface imports a key: that is, it takes as input a key in an external, portable format and gives you a CryptoKey object that you can use in the Web Crypto API.

Link copied to clipboard
external fun importKeyAsync(format: KeyFormat, keyData: BufferSource, algorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun importKeyAsync(format: KeyFormat, keyData: BufferSource, algorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun importKeyAsync(format: KeyFormat, keyData: BufferSource, algorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun importKeyAsync(format: KeyFormat, keyData: BufferSource, algorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun importKeyAsync(format: KeyFormat, keyData: BufferSource, algorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun importKeyAsync(format: KeyFormat, keyData: BufferSource, algorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>

external fun importKeyAsync(format: KeyFormat.jwk, keyData: JsonWebKey, algorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun importKeyAsync(format: KeyFormat.jwk, keyData: JsonWebKey, algorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun importKeyAsync(format: KeyFormat.jwk, keyData: JsonWebKey, algorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun importKeyAsync(format: KeyFormat.jwk, keyData: JsonWebKey, algorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun importKeyAsync(format: KeyFormat.jwk, keyData: JsonWebKey, algorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun importKeyAsync(format: KeyFormat.jwk, keyData: JsonWebKey, algorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>

The importKey() method of the SubtleCrypto interface imports a key: that is, it takes as input a key in an external, portable format and gives you a CryptoKey object that you can use in the Web Crypto API.

Link copied to clipboard
inline suspend fun SubtleCrypto.sign(algorithm: String, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.sign(algorithm: Algorithm, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.sign(algorithm: EcdsaParams, key: CryptoKey, data: BufferSource): ArrayBuffer
inline suspend fun SubtleCrypto.sign(algorithm: RsaPssParams, key: CryptoKey, data: BufferSource): ArrayBuffer

The sign() method of the SubtleCrypto interface generates a digital signature.

Link copied to clipboard
external fun signAsync(algorithm: String, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun signAsync(algorithm: Algorithm, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun signAsync(algorithm: EcdsaParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
external fun signAsync(algorithm: RsaPssParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>

The sign() method of the SubtleCrypto interface generates a digital signature.

Link copied to clipboard
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: String, unwrappedKeyAlgorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: String, unwrappedKeyAlgorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: String, unwrappedKeyAlgorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: String, unwrappedKeyAlgorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: String, unwrappedKeyAlgorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams, unwrappedKeyAlgorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams, unwrappedKeyAlgorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams, unwrappedKeyAlgorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams, unwrappedKeyAlgorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams, unwrappedKeyAlgorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams, unwrappedKeyAlgorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCtrParams, unwrappedKeyAlgorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCtrParams, unwrappedKeyAlgorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCtrParams, unwrappedKeyAlgorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCtrParams, unwrappedKeyAlgorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCtrParams, unwrappedKeyAlgorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCtrParams, unwrappedKeyAlgorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesGcmParams, unwrappedKeyAlgorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesGcmParams, unwrappedKeyAlgorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesGcmParams, unwrappedKeyAlgorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesGcmParams, unwrappedKeyAlgorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesGcmParams, unwrappedKeyAlgorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesGcmParams, unwrappedKeyAlgorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: RsaOaepParams, unwrappedKeyAlgorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: RsaOaepParams, unwrappedKeyAlgorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: RsaOaepParams, unwrappedKeyAlgorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: RsaOaepParams, unwrappedKeyAlgorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: RsaOaepParams, unwrappedKeyAlgorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey
inline suspend fun SubtleCrypto.unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: RsaOaepParams, unwrappedKeyAlgorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): CryptoKey

The unwrapKey() method of the SubtleCrypto interface "unwraps" a key. This means that it takes as its input a key that has been exported and then encrypted (also called "wrapped"). It decrypts the key and then imports it, returning a CryptoKey object that can be used in the Web Crypto API.

Link copied to clipboard
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: String, unwrappedKeyAlgorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: String, unwrappedKeyAlgorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: String, unwrappedKeyAlgorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: String, unwrappedKeyAlgorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: String, unwrappedKeyAlgorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams, unwrappedKeyAlgorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams, unwrappedKeyAlgorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams, unwrappedKeyAlgorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams, unwrappedKeyAlgorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams, unwrappedKeyAlgorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams, unwrappedKeyAlgorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCtrParams, unwrappedKeyAlgorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCtrParams, unwrappedKeyAlgorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCtrParams, unwrappedKeyAlgorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCtrParams, unwrappedKeyAlgorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCtrParams, unwrappedKeyAlgorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCtrParams, unwrappedKeyAlgorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesGcmParams, unwrappedKeyAlgorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesGcmParams, unwrappedKeyAlgorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesGcmParams, unwrappedKeyAlgorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesGcmParams, unwrappedKeyAlgorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesGcmParams, unwrappedKeyAlgorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesGcmParams, unwrappedKeyAlgorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: RsaOaepParams, unwrappedKeyAlgorithm: String, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: RsaOaepParams, unwrappedKeyAlgorithm: AesKeyAlgorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: RsaOaepParams, unwrappedKeyAlgorithm: Algorithm, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: RsaOaepParams, unwrappedKeyAlgorithm: EcKeyImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: RsaOaepParams, unwrappedKeyAlgorithm: HmacImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
external fun unwrapKeyAsync(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: RsaOaepParams, unwrappedKeyAlgorithm: RsaHashedImportParams, extractable: Boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>

The unwrapKey() method of the SubtleCrypto interface "unwraps" a key. This means that it takes as its input a key that has been exported and then encrypted (also called "wrapped"). It decrypts the key and then imports it, returning a CryptoKey object that can be used in the Web Crypto API.

Link copied to clipboard
inline suspend fun SubtleCrypto.verify(algorithm: String, key: CryptoKey, signature: BufferSource, data: BufferSource): Boolean
inline suspend fun SubtleCrypto.verify(algorithm: Algorithm, key: CryptoKey, signature: BufferSource, data: BufferSource): Boolean
inline suspend fun SubtleCrypto.verify(algorithm: EcdsaParams, key: CryptoKey, signature: BufferSource, data: BufferSource): Boolean
inline suspend fun SubtleCrypto.verify(algorithm: RsaPssParams, key: CryptoKey, signature: BufferSource, data: BufferSource): Boolean

The verify() method of the SubtleCrypto interface verifies a digital signature.

Link copied to clipboard
external fun verifyAsync(algorithm: String, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise<JsBoolean>
external fun verifyAsync(algorithm: Algorithm, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise<JsBoolean>
external fun verifyAsync(algorithm: EcdsaParams, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise<JsBoolean>
external fun verifyAsync(algorithm: RsaPssParams, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise<JsBoolean>

The verify() method of the SubtleCrypto interface verifies a digital signature.

Link copied to clipboard
inline suspend fun SubtleCrypto.wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: String): ArrayBuffer
inline suspend fun SubtleCrypto.wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AesCbcParams): ArrayBuffer
inline suspend fun SubtleCrypto.wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AesCtrParams): ArrayBuffer
inline suspend fun SubtleCrypto.wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AesGcmParams): ArrayBuffer
inline suspend fun SubtleCrypto.wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): ArrayBuffer
inline suspend fun SubtleCrypto.wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: RsaOaepParams): ArrayBuffer

The wrapKey() method of the SubtleCrypto interface "wraps" a key. This means that it exports the key in an external, portable format, then encrypts the exported key. Wrapping a key helps protect it in untrusted environments, such as inside an otherwise unprotected data store or in transmission over an unprotected network.

Link copied to clipboard
external fun wrapKeyAsync(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: String): Promise<ArrayBuffer>
external fun wrapKeyAsync(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AesCbcParams): Promise<ArrayBuffer>
external fun wrapKeyAsync(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AesCtrParams): Promise<ArrayBuffer>
external fun wrapKeyAsync(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AesGcmParams): Promise<ArrayBuffer>
external fun wrapKeyAsync(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): Promise<ArrayBuffer>
external fun wrapKeyAsync(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: RsaOaepParams): Promise<ArrayBuffer>

The wrapKey() method of the SubtleCrypto interface "wraps" a key. This means that it exports the key in an external, portable format, then encrypts the exported key. Wrapping a key helps protect it in untrusted environments, such as inside an otherwise unprotected data store or in transmission over an unprotected network.