const BLOCK_SIZE
pub const BLOCK_SIZE = 16Purpose
Constant BLOCK_SIZE, defining protocol or algorithm parameters.
#crypto/sm4SM4 block plus CBC/CTR/CFB/OFB/GCM. Pure Xu, not commercial-crypto certified.
const BLOCK_SIZEpub const BLOCK_SIZE = 16Constant BLOCK_SIZE, defining protocol or algorithm parameters.
struct Cipherpub struct Cipher {
pub rk []int
pub sbox []int
}Sm4 Cipher context for block or stream encryption/decryption.
rk []intsbox []int(&Cipher) crypt_arr16pub fn (c &Cipher) crypt_arr16(dst $&[16]int, src &[16]int, inv int) intOperation on &Cipher: crypt arr16.
c &CipherCipher instance used by this call (borrow).dst $&[16]intsrc &[16]intinv intint — a value of this type
new_cipherpub fn new_cipher(key &string) CipherConstruct cipher. Throws on failure; handle the error or propagate it to the caller.
key &stringCipher — a value of this type
(&Cipher) block_sizepub fn (c &Cipher) block_size() intOperation on &Cipher: block size.
c &CipherCipher instance used by this call (borrow).int — a value of this type
(&Cipher) encrypt_arr16pub fn (c &Cipher) encrypt_arr16(dst $&[16]int, src &[16]int) intOperation on &Cipher: encrypt arr16.
c &CipherCipher instance used by this call (borrow).dst $&[16]intsrc &[16]intint — a value of this type
(&Cipher) decrypt_arr16pub fn (c &Cipher) decrypt_arr16(dst $&[16]int, src &[16]int) intOperation on &Cipher: decrypt arr16.
c &CipherCipher instance used by this call (borrow).dst $&[16]intsrc &[16]intint — a value of this type
(&Cipher) encryptpub fn (c &Cipher) encrypt(src &string) stringOperation on &Cipher: encrypt. Throws on failure; handle the error or propagate it to the caller.
c &CipherCipher instance used by this call (borrow).src &stringstring — result string
(&Cipher) decryptpub fn (c &Cipher) decrypt(src &string) stringOperation on &Cipher: decrypt. Throws on failure; handle the error or propagate it to the caller.
c &CipherCipher instance used by this call (borrow).src &stringstring — result string
struct GcmKeypub struct GcmKey {
}GcmKey context or state structure.
This type has no public fields.
empty_gcmpub fn empty_gcm() GcmKeyEmpty gcm.
No arguments are required.
GcmKey — a value of this type
new_gcmpub fn new_gcm(c Cipher) GcmKeyConstruct gcm. Throws on failure; handle the error or propagate it to the caller.
c CipherGcmKey — a value of this type
(&GcmKey) sealpub fn (g &GcmKey) seal(nonce &string, plaintext &string, aad &string) stringExecute seal on &GcmKey. Throws on failure; handle the error or propagate it to the caller.
g &GcmKeyGcmKey instance used by this call (borrow).nonce &stringplaintext &stringaad &stringstring — result string
(&GcmKey) openpub fn (g &GcmKey) open(nonce &string, sealed &string, aad &string) stringOperation on &GcmKey: open resource or establish connection. Throws on failure; handle the error or propagate it to the caller.
g &GcmKeyGcmKey instance used by this call (borrow).nonce &stringsealed &stringaad &stringstring — result string
seal_gcmpub fn seal_gcm(c &Cipher, nonce &string, plaintext &string, aad &string) stringSeal gcm. Throws on failure; handle the error or propagate it to the caller.
c &Ciphernonce &stringplaintext &stringaad &stringstring — result string
open_gcmpub fn open_gcm(c &Cipher, nonce &string, sealed &string, aad &string) stringOpen gcm. Throws on failure; handle the error or propagate it to the caller.
c &Ciphernonce &stringsealed &stringaad &stringstring — result string
encrypt_cbcpub fn encrypt_cbc(c &Cipher, iv &string, src &string) stringEncrypt cbc. Throws on failure; handle the error or propagate it to the caller.
c &Cipheriv &stringsrc &stringstring — result string
decrypt_cbcpub fn decrypt_cbc(c &Cipher, iv &string, src &string) stringDecrypt cbc. Throws on failure; handle the error or propagate it to the caller.
c &Cipheriv &stringsrc &stringstring — result string
encrypt_cbc_pkcs7pub fn encrypt_cbc_pkcs7(c &Cipher, iv &string, src &string) stringEncrypt cbc pkcs7. Throws on failure; handle the error or propagate it to the caller.
c &Cipheriv &stringsrc &stringstring — result string
decrypt_cbc_pkcs7pub fn decrypt_cbc_pkcs7(c &Cipher, iv &string, src &string) stringDecrypt cbc pkcs7. Throws on failure; handle the error or propagate it to the caller.
c &Cipheriv &stringsrc &stringstring — result string
encrypt_ctrpub fn encrypt_ctr(c &Cipher, iv &string, src &string) stringEncrypt ctr. Throws on failure; handle the error or propagate it to the caller.
c &Cipheriv &stringsrc &stringstring — result string
decrypt_ctrpub fn decrypt_ctr(c &Cipher, iv &string, src &string) stringDecrypt ctr. Throws on failure; handle the error or propagate it to the caller.
c &Cipheriv &stringsrc &stringstring — result string
encrypt_cfbpub fn encrypt_cfb(c &Cipher, iv &string, src &string) stringEncrypt cfb. Throws on failure; handle the error or propagate it to the caller.
c &Cipheriv &stringsrc &stringstring — result string
decrypt_cfbpub fn decrypt_cfb(c &Cipher, iv &string, src &string) stringDecrypt cfb. Throws on failure; handle the error or propagate it to the caller.
c &Cipheriv &stringsrc &stringstring — result string
encrypt_ofbpub fn encrypt_ofb(c &Cipher, iv &string, src &string) stringEncrypt ofb. Throws on failure; handle the error or propagate it to the caller.
c &Cipheriv &stringsrc &stringstring — result string
decrypt_ofbpub fn decrypt_ofb(c &Cipher, iv &string, src &string) stringDecrypt ofb. Throws on failure; handle the error or propagate it to the caller.
c &Cipheriv &stringsrc &stringstring — result string