Module yogcrypt::sm4[][src]

An implementation of the SM4 block cipher standard.

Usage

extern crate yogcrypt;
use yogcrypt::sm4::{sm4_enc, sm4_dec};

let m = b"ajfkdljfldsjkfsd";
let p_txt = b"1234567890abcdef";

let c_txt = sm4_enc(m, p_txt);
let p_txt2 = sm4_dec(m, &c_txt);
assert_eq!(p_txt, &p_txt2);

Note

When implementing block cipher modes, one is highly encouraged to use [u32] representation to avoid frequent conversions. Also, the round keys can be computed only once at the beginning.

Reference

Most variable's name are same as those in the Document written by the Encryption Administration.

DACAS: sm4

Constants

BLOCK_SIZE
KEY_SIZE
RND_KEY_SIZE

Functions

get_sm4_r_k

Compute round keys from a given key.

sm4_dec

Decrypt c_txt using sk

sm4_dec_inner

Core function of sm4 decryption

sm4_enc

Encrypt p_txt under sk

sm4_enc_inner

Core function for sm4 encryption

Type Definitions

Block
Key