const BLOCK_SIZE
pub const BLOCK_SIZE = 16用途
常量 BLOCK_SIZE,定义了相关的协议或算法配置参数。
#crypto/sm4SM4 单块与 CBC/CTR/CFB/OFB/GCM。零 C、非商密认证。
const BLOCK_SIZEpub const BLOCK_SIZE = 16常量 BLOCK_SIZE,定义了相关的协议或算法配置参数。
struct Cipherpub struct Cipher {
pub rk []int
pub sbox []int
}Sm4 密码算法的分组或流式加解密上下文。
rk []intsbox []int(&Cipher) crypt_arr16pub fn (c &Cipher) crypt_arr16(dst $&[16]int, src &[16]int, inv int) int&Cipher 上的操作:执行 crypt arr16 操作。
c &CipherCipher 实例;以只读借用传入,调用方仍持有实例。dst $&[16]intsrc &[16]intinv intint — 该类型的值
new_cipherpub fn new_cipher(key &string) Cipher构造 cipher。失败时抛出错误,调用方需处理或继续传播。
key &stringCipher — 该类型的值
(&Cipher) block_sizepub fn (c &Cipher) block_size() int&Cipher 上的操作:块尺寸。
c &CipherCipher 实例;以只读借用传入,调用方仍持有实例。int — 该类型的值
(&Cipher) encrypt_arr16pub fn (c &Cipher) encrypt_arr16(dst $&[16]int, src &[16]int) int&Cipher 上的操作:加密arr16。
c &CipherCipher 实例;以只读借用传入,调用方仍持有实例。dst $&[16]intsrc &[16]intint — 该类型的值
(&Cipher) decrypt_arr16pub fn (c &Cipher) decrypt_arr16(dst $&[16]int, src &[16]int) int&Cipher 上的操作:解密arr16。
c &CipherCipher 实例;以只读借用传入,调用方仍持有实例。dst $&[16]intsrc &[16]intint — 该类型的值
(&Cipher) encryptpub fn (c &Cipher) encrypt(src &string) string&Cipher 上的操作:加密。失败时抛出错误,调用方需处理或继续传播。
c &CipherCipher 实例;以只读借用传入,调用方仍持有实例。src &stringstring — 结果字符串
(&Cipher) decryptpub fn (c &Cipher) decrypt(src &string) string&Cipher 上的操作:解密。失败时抛出错误,调用方需处理或继续传播。
c &CipherCipher 实例;以只读借用传入,调用方仍持有实例。src &stringstring — 结果字符串
struct GcmKeypub struct GcmKey {
}GcmKey 上下文或状态结构体。
此类型没有公开字段。
empty_gcmpub fn empty_gcm() GcmKey执行 empty gcm 操作。
无需传入参数。
GcmKey — 该类型的值
new_gcmpub fn new_gcm(c Cipher) GcmKey构造 gcm。失败时抛出错误,调用方需处理或继续传播。
c CipherGcmKey — 该类型的值
(&GcmKey) sealpub fn (g &GcmKey) seal(nonce &string, plaintext &string, aad &string) string&GcmKey 上的操作:封装。失败时抛出错误,调用方需处理或继续传播。
g &GcmKeyGcmKey 实例;以只读借用传入,调用方仍持有实例。nonce &stringplaintext &stringaad &stringstring — 结果字符串
(&GcmKey) openpub fn (g &GcmKey) open(nonce &string, sealed &string, aad &string) string&GcmKey 上的操作:打开资源或建立网络连接。失败时抛出错误,调用方需处理或继续传播。
g &GcmKeyGcmKey 实例;以只读借用传入,调用方仍持有实例。nonce &stringsealed &stringaad &stringstring — 结果字符串
seal_gcmpub fn seal_gcm(c &Cipher, nonce &string, plaintext &string, aad &string) string执行 seal gcm 操作。失败时抛出错误,调用方需处理或继续传播。
c &Ciphernonce &stringplaintext &stringaad &stringstring — 结果字符串
open_gcmpub fn open_gcm(c &Cipher, nonce &string, sealed &string, aad &string) string执行 open gcm 操作。失败时抛出错误,调用方需处理或继续传播。
c &Ciphernonce &stringsealed &stringaad &stringstring — 结果字符串
encrypt_cbcpub fn encrypt_cbc(c &Cipher, iv &string, src &string) string执行 encrypt cbc 操作。失败时抛出错误,调用方需处理或继续传播。
c &Cipheriv &stringsrc &stringstring — 结果字符串
decrypt_cbcpub fn decrypt_cbc(c &Cipher, iv &string, src &string) string执行 decrypt cbc 操作。失败时抛出错误,调用方需处理或继续传播。
c &Cipheriv &stringsrc &stringstring — 结果字符串
encrypt_cbc_pkcs7pub fn encrypt_cbc_pkcs7(c &Cipher, iv &string, src &string) string执行 encrypt cbc pkcs7 操作。失败时抛出错误,调用方需处理或继续传播。
c &Cipheriv &stringsrc &stringstring — 结果字符串
decrypt_cbc_pkcs7pub fn decrypt_cbc_pkcs7(c &Cipher, iv &string, src &string) string执行 decrypt cbc pkcs7 操作。失败时抛出错误,调用方需处理或继续传播。
c &Cipheriv &stringsrc &stringstring — 结果字符串
encrypt_ctrpub fn encrypt_ctr(c &Cipher, iv &string, src &string) string执行 encrypt ctr 操作。失败时抛出错误,调用方需处理或继续传播。
c &Cipheriv &stringsrc &stringstring — 结果字符串
decrypt_ctrpub fn decrypt_ctr(c &Cipher, iv &string, src &string) string执行 decrypt ctr 操作。失败时抛出错误,调用方需处理或继续传播。
c &Cipheriv &stringsrc &stringstring — 结果字符串
encrypt_cfbpub fn encrypt_cfb(c &Cipher, iv &string, src &string) string执行 encrypt cfb 操作。失败时抛出错误,调用方需处理或继续传播。
c &Cipheriv &stringsrc &stringstring — 结果字符串
decrypt_cfbpub fn decrypt_cfb(c &Cipher, iv &string, src &string) string执行 decrypt cfb 操作。失败时抛出错误,调用方需处理或继续传播。
c &Cipheriv &stringsrc &stringstring — 结果字符串
encrypt_ofbpub fn encrypt_ofb(c &Cipher, iv &string, src &string) string执行 encrypt ofb 操作。失败时抛出错误,调用方需处理或继续传播。
c &Cipheriv &stringsrc &stringstring — 结果字符串
decrypt_ofbpub fn decrypt_ofb(c &Cipher, iv &string, src &string) string执行 decrypt ofb 操作。失败时抛出错误,调用方需处理或继续传播。
c &Cipheriv &stringsrc &stringstring — 结果字符串