Ejemplo n.º 1
0
  public PublicKey getPublicCAKey()
      throws InvalidKeySpecException, IOException, NoSuchAlgorithmException,
          NoSuchProviderException {
    ChipAuthenticationPublicKeyInfo info =
        securityInfos.getDefaultChipAuthenticationPublicKeyInfo();
    AlgorithmParameterSpec algorithmParameterSpec =
        securityInfos.getDefaultCADomainParameter().getAlgorithmParameterSpec();
    Type type = securityInfos.getDefaultCADomainParameter().getType();

    PublicKey pubKey = null;
    if (type == Type.ECDH) {
      ECParameterSpec eps = (ECParameterSpec) algorithmParameterSpec;
      DEROctetString dos =
          new DEROctetString(info.getSubjectPublicKeyInfo().getPublicKeyData().getBytes());

      ECPoint point = new X9ECPoint(eps.getCurve(), dos).getPoint();
      ECPublicKeySpec eks = new ECPublicKeySpec(point, eps);

      pubKey = new JCEECPublicKey(type.toString(), eks);

    } else {

      DHParameterSpec dps = (DHParameterSpec) algorithmParameterSpec;
      ASN1Integer dos =
          new ASN1Integer(info.getSubjectPublicKeyInfo().getPublicKeyData().getBytes());
      DHPublicKeySpec keySpec = new DHPublicKeySpec(dos.getPositiveValue(), dps.getP(), dps.getG());
      KeyFactory kf = KeyFactory.getInstance(type.toString());
      return kf.generatePublic(keySpec);
    }

    return pubKey;
  }
Ejemplo n.º 2
0
 public DHDomainParameter.Type getCAAlgorithmType() {
   return securityInfos.getDefaultCADomainParameter().getType();
 }