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密钥交换
517浏览 • 1回复 待解决
HarmonyOS SM2密钥问题
678浏览 • 1回复 待解决
HarmonyOS 生成SM2密钥对报错
741浏览 • 1回复 待解决
HarmonyOS SM2密钥对转换失败
1379浏览 • 1回复 待解决
HarmonyOS SM2数据签名
526浏览 • 1回复 待解决
HarmonyOS sm2验签失败
753浏览 • 1回复 待解决
HarmonyOS SM2加密算法
655浏览 • 1回复 待解决
HarmonyOS SM2公私钥转换
598浏览 • 1回复 待解决
HarmonyOS SM2/SM4结合加解密
747浏览 • 1回复 待解决
huks sm2签名验签失败
925浏览 • 1回复 待解决
huks密钥库导入自定义密钥
870浏览 • 1回复 待解决
HarmonyOS sm2签名后数据长度问题
458浏览 • 1回复 待解决
HarmonyOS SM2公钥PEM读取接口
732浏览 • 1回复 待解决
HarmonyOS Sm2和DES加解密问题
1096浏览 • 1回复 待解决
HarmonyOS SM2SM4国密加解密使用demo
938浏览 • 1回复 待解决
HarmonyOS SM2加签验签SM3摘要算法使用
1232浏览 • 1回复 待解决
HarmonyOS 指定私钥生成SM2秘钥的方法
660浏览 • 1回复 待解决