第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Javascript - Java ECDH

Javascript - Java ECDH

九州編程 2021-07-16 18:15:52
在我的場景中,Alice 和 Bob 就使用哪條曲線達成了一致。Alice 生成公鑰和私鑰Alice 將公鑰發(fā)送給 BobBob 生成他的密鑰并根據(jù)他收到的 Alice 公鑰生成會話密鑰(或秘密密鑰或共享密鑰)。我的問題是 Alice 的公鑰實際上是一個點,因此它具有 xy 格式。我需要將 x,y 坐標(biāo)字節(jié)轉(zhuǎn)換為 ECPublicKey。這是我正在使用的源代碼// outerPublicKey is the raw bytes from x,y coordinates in hex format    KeyFactory kf = KeyFactory.getInstance("EC");    PublicKey remoteAlicePub = kf.generatePublic(new X509EncodedKeySpec(outerPublicKey));    KeyPairGenerator bobKeyGen = KeyPairGenerator.getInstance("ECDH", "BC");    bobKeyGen.initialize(new ECGenParameterSpec(properties.getCurveName()), new SecureRandom());    KeyPair bobPair = bobKeyGen.generateKeyPair();    ECPublicKey bobPub = (ECPublicKey)bobPair.getPublic();    ECPrivateKey bobPvt = (ECPrivateKey)bobPair.getPrivate();    byte[] bobPubEncoded = bobPub.getEncoded();    byte[] bobPvtEncoded = bobPvt.getEncoded();    KeyAgreement bobKeyAgree = KeyAgreement.getInstance("ECDH");    bobKeyAgree.init(bobPvt);    bobKeyAgree.doPhase(remoteAlicePub, true);    return DatatypeConverter.printHexBinary(bobKeyAgree.generateSecret());問題是:    new X509EncodedKeySpec(outerPublicKey);如何從點的 xy 坐標(biāo)創(chuàng)建公鑰?因為outerPublicKey是 x,y 坐標(biāo)的原始字節(jié)數(shù)組,我應(yīng)該使用哪種格式?
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 250 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號