HarmonyOS SM2密钥交换计算协商密钥

这边有使用bouncycastle的SM2KeyExchange,想咨询下ArkTS实现方法。

java源码如下:

public static byte[] calculateKey(boolean initiator, int keyBits,
ECPrivateKeyParameters selfStaticPriv, ECPrivateKeyParameters selfEphemeralPriv, byte[] selfId,
ECPublicKeyParameters otherStaticPub, ECPublicKeyParameters otherEphemeralPub, byte[] otherId) {
  SM2KeyExchange exch = new SM2KeyExchange();
  exch.init(new ParametersWithID(
    new SM2KeyExchangePrivateParameters(initiator, selfStaticPriv, selfEphemeralPriv),
    selfId));
  return exch.calculateKey(
    keyBits,
    new ParametersWithID(new SM2KeyExchangePublicParameters(otherStaticPub, otherEphemeralPub), otherId));
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.

参见上述java代码,入参两对公私钥加selfId\otherId,计算key。

SM2密钥交换协议参考:https://tools.ietf.org/html/draft-shen-sm2-ecdsa-02

HarmonyOS
2025-01-10 08:06:29
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
put_get

当前使用的密钥交换协商的方法不支持。

分享
微博
QQ
微信
回复
2025-01-10 11:20:21
相关问题
HarmonyOS SM2密钥交换
640浏览 • 1回复 待解决
HarmonyOS SM2密钥问题
799浏览 • 1回复 待解决
HarmonyOS 生成SM2密钥对报错
905浏览 • 1回复 待解决
HarmonyOS SM2密钥对转换失败
1592浏览 • 1回复 待解决
HarmonyOS SM2数据签名
644浏览 • 1回复 待解决
HarmonyOS sm2验签失败
897浏览 • 1回复 待解决
HarmonyOS SM2加密算法
836浏览 • 1回复 待解决
HarmonyOS SM2公私钥转换
817浏览 • 1回复 待解决
HarmonyOS SM2/SM4结合加解密
945浏览 • 1回复 待解决
huks sm2签名验签失败
1077浏览 • 1回复 待解决
HarmonyOS SM2公钥PEM读取接口
926浏览 • 1回复 待解决
HarmonyOS sm2签名后数据长度问题
598浏览 • 1回复 待解决
huks密钥库导入自定义密钥
1021浏览 • 1回复 待解决
HarmonyOS Sm2和DES加解密问题
1281浏览 • 1回复 待解决
HarmonyOS SM2加签验签SM3摘要算法使用
1360浏览 • 1回复 待解决
HarmonyOS SM2SM4国密加解密使用demo
1125浏览 • 1回复 待解决
HarmonyOS 指定私钥生成SM2秘钥的方法
810浏览 • 1回复 待解决