Module Eio_brr_webcrypto.Subtle_crypto

SubtleCrypto objects

val encrypt : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_algo.t -> Brr_webcrypto.Crypto_algo.t -> ('a, 'b) Brr.Tarray.t -> Brr.Tarray.Buffer.t

encrypt s a k data is data encrypted with key k and algorithm a.

val decrypt : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_algo.t -> Brr_webcrypto.Crypto_algo.t -> ('a, 'b) Brr.Tarray.t -> Brr.Tarray.Buffer.t

decrypt s a k data is data decrypted with key k and algorithm a.

val digest : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_algo.t -> ('a, 'b) Brr.Tarray.t -> Brr.Tarray.Buffer.t

digest s a data is the digest of data according to algorithm a.

Signatures

val sign : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_algo.t -> Brr_webcrypto.Crypto_algo.t -> ('a, 'b) Brr.Tarray.t -> Brr.Tarray.Buffer.t

sign s a k data is the signature of data with key k and algorithm a.

val verify : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_algo.t -> Brr_webcrypto.Crypto_algo.t -> sig':('a, 'b) Brr.Tarray.t -> ('c, 'd) Brr.Tarray.t -> bool

verify s a k ~sig' data is true iff the signature of data with key k and algorithm a matches sig'.

Key generation

val generate_key : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_algo.t -> extractable:bool -> usages:Brr_webcrypto.Crypto_key.Usage.t list -> Brr_webcrypto.Crypto_algo.t

generate_key s a ~extractable ~usage is a key generated for algorithm a and usages usages. Warning if the algorithm generates a key pair use generate_key_pair.

val generate_key_pair : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_algo.t -> extractable:bool -> usages:Brr_webcrypto.Crypto_key.Usage.t list -> Brr_webcrypto.Crypto_key.pair

generate_key_pair s a ~extractable ~usage is a key generated of type and parameters a and usages usages. Warning if the algorithm generates a single key use generate_key.

Key derivation

val derive_bits : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_algo.t -> Brr_webcrypto.Crypto_algo.t -> int -> Brr.Tarray.Buffer.t

derive_bits s a k l are l bits derived from k with algorithm a.

val derive_key : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_algo.t -> Brr_webcrypto.Crypto_algo.t -> derived:Brr_webcrypto.Crypto_algo.t -> extractable:bool -> usages:Brr_webcrypto.Crypto_key.Usage.t list -> Brr_webcrypto.Crypto_algo.t

derive_key s a k ~derived_type ~extractable ~usages is a key of type and parameters ~derived and usages usages derived from key k of type and parameters a.

Key encoding and decoding

val export_key : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_key.Format.t -> Brr_webcrypto.Crypto_algo.t -> [ `Buffer of Brr.Tarray.Buffer.t | `Json_web_key of Brr.Json.t ]

export_key s f k is the key k exported in format f. `Json_web_key is only returned if Brr_webcrypto.Crypto_key.Format.jwk is specified.

val import_key : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_key.Format.t -> [ `Buffer of Brr.Tarray.Buffer.t | `Json_web_key of Brr.Json.t ] -> Brr_webcrypto.Crypto_algo.t -> extractable:bool -> usages:Brr_webcrypto.Crypto_key.Usage.t list -> Brr_webcrypto.Crypto_algo.t

import_key s f k a ~extractable ~usages is the key k imported from format f and type a used for usages.

val wrap_key : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_key.Format.t -> Brr_webcrypto.Crypto_algo.t -> wrap_key:Brr_webcrypto.Crypto_algo.t -> wrapper:Brr_webcrypto.Crypto_algo.t -> Brr.Tarray.Buffer.t

wrap_key s f k ~wrap_key ~wrapper is like export_key but encrypts the result with wrap_key ad algorithm wrapper.

val unwrap_key : Brr_webcrypto.Subtle_crypto.t -> Brr_webcrypto.Crypto_key.Format.t -> ('a, 'b) Brr.Tarray.t -> wrap_key:Brr_webcrypto.Crypto_algo.t -> wrapper:Brr_webcrypto.Crypto_algo.t -> unwrapped:Brr_webcrypto.Crypto_algo.t -> extractable:bool -> usages:Brr_webcrypto.Crypto_key.Usage.t list -> Brr_webcrypto.Crypto_algo.t

unwrap_key s f b ~wrap_key ~wrapper ~unwrapped ~extractable ~usages is like import_key but unwraps the wrapper of b made wtih wrap_key and algorithm wrapped.