椭圆曲线键对Generation和键工厂上的Bouncy
Castle示例代码使我非常接近。
一旦我成功创建了ECDSA密钥工厂和
secp256r1/
NIST P-256/
P-256/
prime256v1曲线的曲线规范,便可以
ECPointUtil.deprePoint用来获取曲线点。然后,我可以生成一个公共密钥规范,该规范使我能够生成这样的公共密钥:
private PublicKey getPublicKeyFromBytes(byte[] pubKey) throws NoSuchAlgorithmException, InvalidKeySpecException { ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("prime256v1"); KeyFactory kf = KeyFactory.getInstance("ECDSA", new BouncyCastleProvider()); ECNamedCurveSpec params = new ECNamedCurveSpec("prime256v1", spec.getCurve(), spec.getG(), spec.getN()); ECPoint point = ECPointUtil.deprePoint(params.getCurve(), pubKey); ECPublicKeySpec pubKeySpec = new ECPublicKeySpec(point, params); ECPublicKey pk = (ECPublicKey) kf.generatePublic(pubKeySpec); return pk;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)