Package cn.gmkit.sm2
Class SM2Ciphertexts
java.lang.Object
cn.gmkit.sm2.SM2Ciphertexts
SM2 密文编码转换工具。
负责在原始 C1/C2/C3 布局、GmSSL 兼容布局以及 ASN.1 DER 编码之间做转换。
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]decodeAsn1(byte[] asn1Ciphertext, SM2CipherMode mode) 将 ASN.1 DER 密文解码为原始 SM2 密文。static byte[]decodeAuto(byte[] ciphertext, SM2CipherMode mode) 自动识别原始密文和 ASN.1 DER 密文。static byte[]decodeDer(byte[] derCiphertext, SM2CipherMode mode) 将DER格式的密文解码为原始格式static byte[]encodeAsn1(byte[] ciphertext, SM2CipherMode mode) 将原始密文编码为 ASN.1 DER 格式。static byte[]encodeDer(byte[] ciphertext, SM2CipherMode mode) 将密文编码为DER格式static SM2Ciphertextparse(byte[] ciphertext, SM2CipherMode mode) 解析SM2密文数据
-
Method Details
-
parse
解析SM2密文数据- Parameters:
ciphertext- 密文字节数组mode- 密文排列模式- Returns:
- SM2密文对象
- Throws:
GmkitException- 如果密文格式无效
-
encodeDer
将密文编码为DER格式- Parameters:
ciphertext- 原始密文字节数组mode- 密文排列模式- Returns:
- DER编码的密文
- Throws:
GmkitException- 如果编码失败
-
encodeAsn1
将原始密文编码为 ASN.1 DER 格式。- Parameters:
ciphertext- 原始密文字节数组mode- 密文排列模式- Returns:
- ASN.1 DER 编码密文
-
decodeDer
将DER格式的密文解码为原始格式- Parameters:
derCiphertext- DER编码的密文mode- 密文排列模式- Returns:
- 原始格式的密文字节数组
- Throws:
GmkitException- 如果解码失败
-
decodeAsn1
将 ASN.1 DER 密文解码为原始 SM2 密文。- Parameters:
asn1Ciphertext- ASN.1 DER 编码密文mode- 密文排列模式- Returns:
- 原始 SM2 密文
-
decodeAuto
自动识别原始密文和 ASN.1 DER 密文。- Parameters:
ciphertext- 密文字节数组mode- 密文排列模式- Returns:
- 原始 SM2 密文
-