Skip to content

SubtleCrypto

Types

algorithm

type algorithm = WebAPI.WebCryptoTypes.algorithm

Record fields

name
string
hash
option<keyAlgorithm>
length
option<int>
namedCurve
option<string>
tagLength
option<int>
iterations
option<int>
publicKey
option<cryptoKey>
saltLength
option<int>
modulusLength
option<int>
publicExponent
option<Uint8Array.t>
primeLength
option<int>
subprimeLength
option<int>

algorithmIdentifier

type algorithmIdentifier = WebAPI.WebCryptoTypes.algorithmIdentifier

binaryData

type binaryData = WebAPI.ArrayBufferTypedArrayOrDataView.t

binaryKeyFormat

type binaryKeyFormat =
| @as("raw") Raw
| @as("pkcs8") Pkcs8
| @as("spki") Spki

cryptoKey

type cryptoKey = WebAPI.WebCryptoTypes.cryptoKey

Record fields

extractable
bool

cryptoKeyPair

type cryptoKeyPair = WebAPI.WebCryptoTypes.cryptoKeyPair

Record fields

privateKey
publicKey

jwkKeyFormat

type jwkKeyFormat = @as("jwk") Jwk

keyAlgorithm

type keyAlgorithm = WebAPI.WebCryptoTypes.keyAlgorithm

Record fields

name
string

keyFormat

type keyFormat = WebAPI.WebCryptoTypes.keyFormat

keyType

type keyType = WebAPI.WebCryptoTypes.keyType

keyUsage

type keyUsage = WebAPI.WebCryptoTypes.keyUsage

t

type t = WebAPI.WebCryptoTypes.subtleCrypto

Values

algorithmObject

let algorithmObject: algorithm => algorithmIdentifier

Parameters

Return type

algorithmIdentifier

algorithmString

let algorithmString: string => algorithmIdentifier

Parameters

string

Return type

algorithmIdentifier

binaryDataFromArrayBuffer

let binaryDataFromArrayBuffer: ArrayBuffer.t => binaryData

Parameters

ArrayBuffer.t

Return type

binaryData

binaryDataFromDataView

let binaryDataFromDataView: DataView.t => binaryData

Parameters

DataView.t

Return type

binaryData

binaryDataFromUint8Array

let binaryDataFromUint8Array: Uint8Array.t => binaryData

Parameters

Uint8Array.t

Return type

binaryData

decrypt

let decrypt: (
t,
~algorithm: algorithmIdentifier,
~key: cryptoKey,
~data: WebAPI.ArrayBufferTypedArrayOrDataView.t,
) => promise<ArrayBuffer.t>

Parameters

~key: cryptoKey

Return type

promise<ArrayBuffer.t>

decryptUsage

let decryptUsage: WebAPI.WebCryptoTypes.keyUsage

deriveBits

let deriveBits: (
t,
~algorithm: algorithmIdentifier,
~baseKey: cryptoKey,
~length: int=?,
) => promise<ArrayBuffer.t>

Parameters

~baseKey: cryptoKey
~length: int=?

Return type

promise<ArrayBuffer.t>

deriveBits2

let deriveBits2: (
t,
~algorithm: string,
~baseKey: cryptoKey,
~length: int=?,
) => promise<ArrayBuffer.t>

Parameters

~algorithm: string
~baseKey: cryptoKey
~length: int=?

Return type

promise<ArrayBuffer.t>

deriveBitsUsage

let deriveBitsUsage: WebAPI.WebCryptoTypes.keyUsage

deriveKey

let deriveKey: (
t,
~algorithm: algorithmIdentifier,
~baseKey: cryptoKey,
~derivedKeyType: algorithmIdentifier,
~extractable: bool,
~keyUsages: array<keyUsage>,
) => promise<cryptoKey>

Parameters

~baseKey: cryptoKey
~derivedKeyType: algorithmIdentifier
~extractable: bool
~keyUsages: array<keyUsage>

Return type

promise<cryptoKey>

deriveKeyUsage

let deriveKeyUsage: WebAPI.WebCryptoTypes.keyUsage

digest

let digest: (
t,
~algorithm: algorithmIdentifier,
~data: WebAPI.ArrayBufferTypedArrayOrDataView.t,
) => promise<ArrayBuffer.t>

Parameters

Return type

promise<ArrayBuffer.t>

encrypt

let encrypt: (
t,
~algorithm: algorithmIdentifier,
~key: cryptoKey,
~data: WebAPI.ArrayBufferTypedArrayOrDataView.t,
) => promise<ArrayBuffer.t>

Parameters

~key: cryptoKey

Return type

promise<ArrayBuffer.t>

encryptUsage

let encryptUsage: WebAPI.WebCryptoTypes.keyUsage

exportKey

let exportKey: (t, ~format: keyFormat, ~key: cryptoKey) => promise<unknown>

Parameters

~format: keyFormat
~key: cryptoKey

Return type

promise<unknown>

exportKeyBinary

let exportKeyBinary: (
t,
~format: binaryKeyFormat,
~key: cryptoKey,
) => promise<ArrayBuffer.t>

Parameters

~key: cryptoKey

Return type

promise<ArrayBuffer.t>

exportKeyJwk

let exportKeyJwk: (
t,
~format: jwkKeyFormat,
~key: cryptoKey,
) => promise<JSON.t>

Parameters

~format: jwkKeyFormat
~key: cryptoKey

Return type

promise<JSON.t>

generateEcdsaKeyPair

Generates an ECDSA public/private key pair. The fixed algorithm guarantees the native result shape.

let generateEcdsaKeyPair: (
t,
~namedCurve: string,
~extractable: bool,
~keyUsages: array<keyUsage>,
) => promise<cryptoKeyPair>

Parameters

~namedCurve: string
~extractable: bool
~keyUsages: array<keyUsage>

Return type

promise<cryptoKeyPair>

generateKey

let generateKey: (
t,
~algorithm: algorithmIdentifier,
~extractable: bool,
~keyUsages: array<keyUsage>,
) => promise<unknown>

Parameters

~extractable: bool
~keyUsages: array<keyUsage>

Return type

promise<unknown>

generateKey2

let generateKey2: (
t,
~algorithm: string,
~extractable: bool,
~keyUsages: array<keyUsage>,
) => promise<unknown>

Parameters

~algorithm: string
~extractable: bool
~keyUsages: array<keyUsage>

Return type

promise<unknown>

generateKeySymmetric

let generateKeySymmetric: (
t,
~hash: algorithmIdentifier,
~length: int,
~extractable: bool,
~keyUsages: array<keyUsage>,
) => promise<cryptoKey>

Parameters

~length: int
~extractable: bool
~keyUsages: array<keyUsage>

Return type

promise<cryptoKey>

importKey

let importKey: (
t,
~format: keyFormat,
~keyData: WebAPI.ArrayBufferTypedArrayOrDataView.t,
~algorithm: algorithmIdentifier,
~extractable: bool,
~keyUsages: array<keyUsage>,
) => promise<cryptoKey>

Parameters

~format: keyFormat
~extractable: bool
~keyUsages: array<keyUsage>

Return type

promise<cryptoKey>

jwkFormat

let jwkFormat: WebAPI.WebCryptoTypes.keyFormat

pkcs8KeyFormat

let pkcs8KeyFormat: WebAPI.WebCryptoTypes.keyFormat

rawKeyFormat

let rawKeyFormat: WebAPI.WebCryptoTypes.keyFormat

sign

let sign: (
t,
~algorithm: algorithmIdentifier,
~key: cryptoKey,
~data: WebAPI.ArrayBufferTypedArrayOrDataView.t,
) => promise<ArrayBuffer.t>

Parameters

~key: cryptoKey

Return type

promise<ArrayBuffer.t>

signUsage

let signUsage: WebAPI.WebCryptoTypes.keyUsage

spkiKeyFormat

let spkiKeyFormat: WebAPI.WebCryptoTypes.keyFormat

unwrapKey

let unwrapKey: (
t,
~format: keyFormat,
~wrappedKey: WebAPI.ArrayBufferTypedArrayOrDataView.t,
~unwrappingKey: cryptoKey,
~unwrapAlgorithm: algorithmIdentifier,
~unwrappedKeyAlgorithm: algorithmIdentifier,
~extractable: bool,
~keyUsages: array<keyUsage>,
) => promise<cryptoKey>

Parameters

~format: keyFormat
~unwrappingKey: cryptoKey
~unwrapAlgorithm: algorithmIdentifier
~unwrappedKeyAlgorithm: algorithmIdentifier
~extractable: bool
~keyUsages: array<keyUsage>

Return type

promise<cryptoKey>

unwrapKeyUsage

let unwrapKeyUsage: WebAPI.WebCryptoTypes.keyUsage

verify

let verify: (
t,
~algorithm: algorithmIdentifier,
~key: cryptoKey,
~signature: WebAPI.ArrayBufferTypedArrayOrDataView.t,
~data: WebAPI.ArrayBufferTypedArrayOrDataView.t,
) => promise<bool>

verifyUsage

let verifyUsage: WebAPI.WebCryptoTypes.keyUsage

wrapKey

let wrapKey: (
t,
~format: keyFormat,
~key: cryptoKey,
~wrappingKey: cryptoKey,
~wrapAlgorithm: algorithmIdentifier,
) => promise<ArrayBuffer.t>

Parameters

~format: keyFormat
~key: cryptoKey
~wrappingKey: cryptoKey
~wrapAlgorithm: algorithmIdentifier

Return type

promise<ArrayBuffer.t>

wrapKey2

let wrapKey2: (
t,
~format: keyFormat,
~key: cryptoKey,
~wrappingKey: cryptoKey,
~wrapAlgorithm: string,
) => promise<ArrayBuffer.t>

Parameters

~format: keyFormat
~key: cryptoKey
~wrappingKey: cryptoKey
~wrapAlgorithm: string

Return type

promise<ArrayBuffer.t>

wrapKeyUsage

let wrapKeyUsage: WebAPI.WebCryptoTypes.keyUsage