package sm

  1. Overview
  2. Docs
Pure OCaml Chinese National Cryptographic Algorithm Library (SM2/SM3/SM4/ZUC)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

sm-0.1.1.tbz
sha256=4d85071a2448f91c7d6d792c1563ca2690c20e22ba188ed7bd20356e4ba684dc
sha512=0e2bbcaaeeab12a9af1287ff4ae3e0197eb6f2eafdcc337d8baf9feefca0b1575fbc043517033b22b78918d214e9ae613c2db033fd51c97a5ca5a8d28cd2198c

doc/sm/Sm3/index.html

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