public final class DHKeyExchanger extends Object
(a^b) mod p = ((a mod p)^b) mod p = (g^XA mod p)^XB mod p = (YA)^XB mod p g^(a*b) mod p = g^(b*a) mod p
| 构造器和说明 |
|---|
DHKeyExchanger() |
| 限定符和类型 | 方法和说明 |
|---|---|
static DHPrivateKey |
decodePrivateKey(byte[] privateKey)
取得私钥
|
static DHPublicKey |
decodePublicKey(byte[] publicKey)
取得公钥
|
static byte[] |
decrypt(byte[] data,
SecretKey secretKey)
解密
|
static byte[] |
encode(DHPrivateKey key)
DHPrivateKey convert to byte array
|
static byte[] |
encode(DHPublicKey key)
DHPublicKey convert to byte array
|
static byte[] |
encrypt(byte[] data,
SecretKey secretKey)
加密
|
static SecretKey |
genSecretKey(byte[] bPriKey,
byte[] aPubKey)
双方公私钥生成(协商)对称密钥
|
static SecretKey |
genSecretKey(DHPrivateKey bPriKey,
DHPublicKey aPubKey)
双方公私钥生成(协商)对称密钥
|
static org.apache.commons.lang3.tuple.Pair<DHPublicKey,DHPrivateKey> |
initPartAKey() |
static org.apache.commons.lang3.tuple.Pair<DHPublicKey,DHPrivateKey> |
initPartAKey(int keySize)
初始化甲方密钥
|
static org.apache.commons.lang3.tuple.Pair<DHPublicKey,DHPrivateKey> |
initPartBKey(byte[] partAPubKey)
初始化乙方密钥
|
static org.apache.commons.lang3.tuple.Pair<DHPublicKey,DHPrivateKey> |
initPartBKey(DHPublicKey partAPublicKey)
初始化乙方密钥
|
public static org.apache.commons.lang3.tuple.Pair<DHPublicKey,DHPrivateKey> initPartAKey()
public static org.apache.commons.lang3.tuple.Pair<DHPublicKey,DHPrivateKey> initPartAKey(int keySize)
keySize - must be a multiple of 64, ranging from 512 to 1024 (inclusive).public static org.apache.commons.lang3.tuple.Pair<DHPublicKey,DHPrivateKey> initPartBKey(byte[] partAPubKey)
partAPubKey - 甲方公钥public static org.apache.commons.lang3.tuple.Pair<DHPublicKey,DHPrivateKey> initPartBKey(DHPublicKey partAPublicKey)
partAPublicKey - 甲方公钥public static byte[] encode(DHPublicKey key)
key - the DHPublicKeypublic static byte[] encode(DHPrivateKey key)
key - the DHPrivateKeypublic static DHPrivateKey decodePrivateKey(byte[] privateKey)
privateKey - public static DHPublicKey decodePublicKey(byte[] publicKey)
publicKey - public static SecretKey genSecretKey(byte[] bPriKey, byte[] aPubKey)
bPriKey - aPubKey - public static SecretKey genSecretKey(DHPrivateKey bPriKey, DHPublicKey aPubKey)
bPriKey - aPubKey - public static byte[] encrypt(byte[] data,
SecretKey secretKey)
data - 待加密数据secretKey - 双方公私钥协商的对称密钥public static byte[] decrypt(byte[] data,
SecretKey secretKey)
data - 待解密数据secretKey - 双方公私钥协商的对称密钥Copyright © 2023. All rights reserved.