public class SM4Util extends GMBaseUtil
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
ALGORITHM_NAME |
static String |
ALGORITHM_NAME_CBC_NOPADDING |
static String |
ALGORITHM_NAME_CBC_PADDING |
static String |
ALGORITHM_NAME_ECB_NOPADDING |
static String |
ALGORITHM_NAME_ECB_PADDING |
static int |
DEFAULT_KEY_SIZE
SM4算法目前只支持128位(即密钥16字节)
|
| 构造器和说明 |
|---|
SM4Util() |
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
decrypt_CBC_NoPadding(byte[] key,
byte[] iv,
byte[] cipherText) |
static byte[] |
decrypt_CBC_Padding(byte[] key,
byte[] iv,
byte[] cipherText) |
static byte[] |
decrypt_ECB_NoPadding(byte[] key,
byte[] cipherText) |
static byte[] |
decrypt_ECB_Padding(byte[] key,
byte[] cipherText) |
static byte[] |
doCBCMac(byte[] key,
byte[] iv,
org.bouncycastle.crypto.paddings.BlockCipherPadding padding,
byte[] data) |
static byte[] |
doCBCMac(byte[] key,
byte[] iv,
byte[] data)
默认使用PKCS7Padding/PKCS5Padding填充的CBCMAC
|
static byte[] |
doCMac(byte[] key,
byte[] data) |
static byte[] |
doGMac(byte[] key,
byte[] iv,
int tagLength,
byte[] data) |
static byte[] |
encrypt_CBC_NoPadding(byte[] key,
byte[] iv,
byte[] data) |
static byte[] |
encrypt_CBC_Padding(byte[] key,
byte[] iv,
byte[] data) |
static byte[] |
encrypt_ECB_NoPadding(byte[] key,
byte[] data) |
static byte[] |
encrypt_ECB_Padding(byte[] key,
byte[] data) |
static byte[] |
generateKey() |
static byte[] |
generateKey(int keySize) |
public static final int DEFAULT_KEY_SIZE
public static byte[] generateKey()
throws NoSuchAlgorithmException,
NoSuchProviderException
public static byte[] generateKey(int keySize)
throws NoSuchAlgorithmException,
NoSuchProviderException
public static byte[] encrypt_ECB_Padding(byte[] key,
byte[] data)
throws InvalidKeyException,
NoSuchAlgorithmException,
NoSuchProviderException,
NoSuchPaddingException,
IllegalBlockSizeException,
BadPaddingException
public static byte[] decrypt_ECB_Padding(byte[] key,
byte[] cipherText)
throws IllegalBlockSizeException,
BadPaddingException,
InvalidKeyException,
NoSuchAlgorithmException,
NoSuchProviderException,
NoSuchPaddingException
public static byte[] encrypt_ECB_NoPadding(byte[] key,
byte[] data)
throws InvalidKeyException,
NoSuchAlgorithmException,
NoSuchProviderException,
NoSuchPaddingException,
IllegalBlockSizeException,
BadPaddingException
public static byte[] decrypt_ECB_NoPadding(byte[] key,
byte[] cipherText)
throws IllegalBlockSizeException,
BadPaddingException,
InvalidKeyException,
NoSuchAlgorithmException,
NoSuchProviderException,
NoSuchPaddingException
public static byte[] encrypt_CBC_Padding(byte[] key,
byte[] iv,
byte[] data)
throws InvalidKeyException,
NoSuchAlgorithmException,
NoSuchProviderException,
NoSuchPaddingException,
IllegalBlockSizeException,
BadPaddingException,
InvalidAlgorithmParameterException
public static byte[] decrypt_CBC_Padding(byte[] key,
byte[] iv,
byte[] cipherText)
throws IllegalBlockSizeException,
BadPaddingException,
InvalidKeyException,
NoSuchAlgorithmException,
NoSuchProviderException,
NoSuchPaddingException,
InvalidAlgorithmParameterException
public static byte[] encrypt_CBC_NoPadding(byte[] key,
byte[] iv,
byte[] data)
throws InvalidKeyException,
NoSuchAlgorithmException,
NoSuchProviderException,
NoSuchPaddingException,
IllegalBlockSizeException,
BadPaddingException,
InvalidAlgorithmParameterException
public static byte[] decrypt_CBC_NoPadding(byte[] key,
byte[] iv,
byte[] cipherText)
throws IllegalBlockSizeException,
BadPaddingException,
InvalidKeyException,
NoSuchAlgorithmException,
NoSuchProviderException,
NoSuchPaddingException,
InvalidAlgorithmParameterException
public static byte[] doCMac(byte[] key,
byte[] data)
throws NoSuchProviderException,
NoSuchAlgorithmException,
InvalidKeyException
public static byte[] doGMac(byte[] key,
byte[] iv,
int tagLength,
byte[] data)
public static byte[] doCBCMac(byte[] key,
byte[] iv,
byte[] data)
key - iv - data - Copyright © 2021. All rights reserved.