package sm

  1. Overview
  2. Docs

Module Sm3Source

Sourcetype t
Sourceval empty : t
Sourceval init : unit -> t
Sourceval update_subbytes : t -> bytes -> off:int -> len:int -> t
Sourceval update_bytes : t -> bytes -> t
Sourceval update_string : t -> string -> t
Sourceval finalize : t -> string
Sourceval finalize_hex : t -> string
Sourceval digest_string : string -> string
Sourceval digest_bytes : bytes -> string
Sourceval digest_hex : string -> string
Sourceval hmac : key:string -> string -> string

HMAC using SM3 as the underlying hash function.

  • parameter key

    secret key

  • parameter data

    message to authenticate

  • returns

    HMAC tag as raw bytes (string)

Sourceval hmac_hex : key:string -> string -> string

HMAC using SM3, returning the tag as a hexadecimal string.

Sourceval kdf : z:string -> klen:int -> string

KDF (Key Derivation Function) based on SM3, as specified in GM/T 0003.4-2012.

  • parameter z

    shared secret

  • parameter klen

    desired length of the derived key in bytes

  • returns

    derived key of length klen