public class DataAuthCtrl extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
DEFAULT_IV_SIZE |
static int |
DEFAULT_TAG_SIZE |
static int |
SM4_KEY_SIZE |
| 构造器和说明 |
|---|
DataAuthCtrl() |
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
decryptData(byte[] logicKey,
byte[] ciphertext)
解密数据,使用逻辑秘钥进行对称解密。
|
static byte[] |
decryptLogicKey(byte[] prikey,
byte[] logicKey)
解密逻辑秘钥,保密传输逻辑秘钥后继续解密。
|
static byte[] |
deriveLogicKey(byte[] masterKey,
byte[] derivePathString)
派生逻辑密钥,由主秘钥根据密钥派生路径字符串派生逻辑密钥。
|
static byte[] |
encryptData(byte[] logicKey,
byte[] plaintext)
加密数据,使用逻辑秘钥进行对称加密。
|
static byte[] |
encryptLogicKey(byte[] pubkey,
byte[] logicKey)
加密逻辑秘钥,保密传输逻辑秘钥前进行加密。
|
static byte[] |
generateMasterKey()
产生master
|
static byte[] |
generatePrivateKey()
产生私钥
|
static byte[] |
generatePubKeyFromPrivateKey(byte[] sk)
由私钥计算公钥
|
static int |
process(boolean forEncrytion,
byte[] secretkey,
byte[] ivBuf,
int ivOff,
int ivLen,
byte[] inbuf,
int inOff,
int inLen,
byte[] outbuf,
int outOff) |
public static final int SM4_KEY_SIZE
public static final int DEFAULT_IV_SIZE
public static final int DEFAULT_TAG_SIZE
public static byte[] generateMasterKey()
throws Exception
Exceptionpublic static byte[] deriveLogicKey(byte[] masterKey,
byte[] derivePathString)
masterKey - 主秘钥,16字节。derivePathString - 密钥派生路径字符串Exceptionpublic static byte[] encryptData(byte[] logicKey,
byte[] plaintext)
throws Exception
logicKey - 逻辑秘钥, 16字节plaintext - 数据明文Exceptionpublic static byte[] decryptData(byte[] logicKey,
byte[] ciphertext)
throws Exception
logicKey - 逻辑秘钥, 16字节ciphertext - 数据密文Exceptionpublic static byte[] generatePrivateKey()
throws Exception
Exceptionpublic static byte[] generatePubKeyFromPrivateKey(byte[] sk)
throws Exception
sk - 私钥,32字节Exceptionpublic static byte[] encryptLogicKey(byte[] pubkey,
byte[] logicKey)
throws Exception
pubkey - 公钥logicKey - 逻辑秘钥Exceptionpublic static byte[] decryptLogicKey(byte[] prikey,
byte[] logicKey)
throws Exception
prikey - logicKey - Exceptionpublic static int process(boolean forEncrytion,
byte[] secretkey,
byte[] ivBuf,
int ivOff,
int ivLen,
byte[] inbuf,
int inOff,
int inLen,
byte[] outbuf,
int outOff)
throws Exception
secretkey - [in ] the secret keyinbuf - [in ] the plaintextoutbuf - [ out] the ciphertext || tag(16 bytes),ExceptionCopyright © 2022. All rights reserved.