Package org.ejbca.cvc

Examples of org.ejbca.cvc.PublicKeyEC


     * @throws InvalidKeySpecException
     */
    public static PublicKey getECPublicKeyWithParams(final PublicKey pk, final String keySpec) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException {
      PublicKey ret = pk;
      if ( (pk instanceof PublicKeyEC) && (keySpec != null) ) {
        final PublicKeyEC pkec = (PublicKeyEC) pk;
        // The public key of IS and DV certificate do not have any parameters so we have to do some magic to get a complete EC public key
        final ECParameterSpec spec = pkec.getParams();
        if (spec == null) {
          // we did not have the parameter specs, lets create them because we know which curve we are using
          final org.bouncycastle.jce.spec.ECParameterSpec bcspec = ECNamedCurveTable.getParameterSpec(keySpec);
          final java.security.spec.ECPoint p = pkec.getW();
          final org.bouncycastle.math.ec.ECPoint ecp = EC5Util.convertPoint(bcspec.getCurve(), p, false);
          final ECPublicKeySpec pubKey = new ECPublicKeySpec(ecp, bcspec);
          final KeyFactory keyfact = KeyFactory.getInstance("ECDSA", "BC");
              ret = keyfact.generatePublic(pubKey);
        }
View Full Code Here


    }
   
    public static PublicKey getECPublicKeyWithParams(final PublicKey pk, final PublicKey pkwithparams) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException {
      PublicKey ret = pk;
      if ( (pk instanceof PublicKeyEC) && (pkwithparams instanceof PublicKeyEC) ) {
        final PublicKeyEC pkec = (PublicKeyEC) pk;
        // The public key of IS and DV certificate do not have any parameters so we have to do some magic to get a complete EC public key
        final ECParameterSpec spec = pkec.getParams();
        if (spec == null) {
          final PublicKeyEC pkecp = (PublicKeyEC) pkwithparams;
          final ECParameterSpec pkspec = pkecp.getParams();
            if (pkspec != null) {
              final org.bouncycastle.jce.spec.ECParameterSpec bcspec = EC5Util.convertSpec(pkspec, false);
              final java.security.spec.ECPoint p = pkec.getW();
              final org.bouncycastle.math.ec.ECPoint ecp = EC5Util.convertPoint(pkspec, p, false);
              final ECPublicKeySpec pubKey = new ECPublicKeySpec(ecp, bcspec);
View Full Code Here

        username = StringTools.strip(username);

        // We need special handling here of CVC certificate with EC keys, because they lack EC parameters in all certs except the Root certificate (CVCA)
      PublicKey pubk = incert.getPublicKey();
      if ((pubk instanceof PublicKeyEC)) {
        PublicKeyEC pkec = (PublicKeyEC) pubk;
        // The public key of IS and DV certificate (CVC) do not have any parameters so we have to do some magic to get a complete EC public key
        ECParameterSpec spec = pkec.getParams();
        if (spec == null) {
          // We need to enrich this public key with parameters
          try {
            if (cafp != null) {
              String cafingerp = cafp;
View Full Code Here

TOP

Related Classes of org.ejbca.cvc.PublicKeyEC

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.