基于DH算法做SM4密钥的交换
in developCo-De with 0 comment

基于DH算法做SM4密钥的交换

in developCo-De with 0 comment

基于DH算法,BC实现SM4密钥的交换

C: Client
S: Server
M,N:提前约定的两个随机数(安全大素数和本原根)
CA: Client端持有的随机整数
SB:Server端持有的随机整数

DH算法

SM4Key生成(BC)

    final Provider provider = ProviderHelper.PROVIDER.getProvider();
    KeyGenerator kg = KeyGenerator.getInstance("SM4", provider);
    kg.init(new SecureRandom(String.valueOf(DH).getBytes()));
    SecretKey keye = kg.generateKey();
    byte[] sm4k = keye.getEncoded();
    System.out.println(new String(sm4k, "UTF-8"));
Comments are closed.