plinth/browser/crypto/subtle

Types

pub type CryptoKey
pub type DigestAlgorithm {
  SHA1
  SHA256
  SHA384
  SHA512
}

Constructors

  • SHA1
  • SHA256
  • SHA384
  • SHA512
pub type ImportAlgorithm {
  RsaHashedImportParams(name: String, hash: DigestAlgorithm)
  EcKeyImportParams(name: String, named_curve: NamedCurve)
  HmacImportParams(hash: DigestAlgorithm)
  OtherImportParams(name: String)
}

Constructors

pub type KeyUsage {
  Encrypt
  Decrypt
  Sign
  Verify
  DeriveKey
  DeriveBits
  WrapKey
  UnwrapKey
}

Constructors

  • Encrypt
  • Decrypt
  • Sign
  • Verify
  • DeriveKey
  • DeriveBits
  • WrapKey
  • UnwrapKey
pub type NamedCurve {
  P256
  P384
  P521
}

Constructors

  • P256
  • P384
  • P521
pub type PublicKeyAlgorithm {
  EcKeyGenParams(name: String, named_curve: String)
}

Constructors

  • EcKeyGenParams(name: String, named_curve: String)
pub type SignAlgorithm {
  RsaSsaPkcs1v15
  RsaPssParams(salt_length: Int)
  EcdsaParams(hash: DigestAlgorithm)
  Hmac
  Ed25519
}

Constructors

  • RsaSsaPkcs1v15
  • RsaPssParams(salt_length: Int)
  • EcdsaParams(hash: DigestAlgorithm)
  • Hmac
  • Ed25519

Values

pub fn digest(
  algorithm: DigestAlgorithm,
  data: BitArray,
) -> promise.Promise(Result(BitArray, String))
pub fn digest_algorithm_to_string(
  algorithm: DigestAlgorithm,
) -> String
pub fn export_jwk(
  key: CryptoKey,
) -> promise.Promise(Result(json.Json, String))

export Jwk is separate because it returns JSON, other formats return array buffer

pub fn generate_key(
  algorithm: PublicKeyAlgorithm,
  extractable: Bool,
  key_usages: List(KeyUsage),
) -> promise.Promise(Result(#(CryptoKey, CryptoKey), String))
pub fn import_jwk(
  key_data: json.Json,
  algorithm: ImportAlgorithm,
  extractable: Bool,
  key_usages: List(KeyUsage),
) -> promise.Promise(Result(CryptoKey, String))
pub fn import_key(
  format: String,
  key_data: BitArray,
  algorithm: ImportAlgorithm,
  extractable: Bool,
  key_usages: List(KeyUsage),
) -> promise.Promise(Result(CryptoKey, String))
pub fn sign(
  algorithm: SignAlgorithm,
  key: CryptoKey,
  data: BitArray,
) -> promise.Promise(Result(BitArray, String))
pub fn verify(
  algorithm: SignAlgorithm,
  key: CryptoKey,
  signature: BitArray,
  data: BitArray,
) -> promise.Promise(Result(Bool, String))
Search Document