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));
}

参见上述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密钥交换
871浏览 • 1回复 待解决
HarmonyOS SM2密钥问题
1096浏览 • 1回复 待解决
HarmonyOS 生成SM2密钥对报错
1149浏览 • 1回复 待解决
HarmonyOS SM2密钥对转换失败
2241浏览 • 1回复 待解决
HarmonyOS SM2数据签名
866浏览 • 1回复 待解决
HarmonyOS SM2加密算法
1079浏览 • 1回复 待解决
HarmonyOS sm2验签失败
1203浏览 • 1回复 待解决
HarmonyOS SM2公私钥转换
1172浏览 • 1回复 待解决
HarmonyOS SM2/SM4结合加解密
1394浏览 • 1回复 待解决
huks密钥库导入自定义密钥
1321浏览 • 1回复 待解决
huks sm2签名验签失败
1391浏览 • 1回复 待解决
HarmonyOS SM2公钥PEM读取接口
1357浏览 • 1回复 待解决
HarmonyOS sm2签名后数据长度问题
856浏览 • 1回复 待解决
HarmonyOS Sm2和DES加解密问题
1740浏览 • 1回复 待解决
HarmonyOS SM2加签验签SM3摘要算法使用
1597浏览 • 1回复 待解决
HarmonyOS SM2SM4国密加解密使用demo
1506浏览 • 1回复 待解决
HarmonyOS 指定私钥生成SM2秘钥的方法
1067浏览 • 1回复 待解决