Examples of DSAPublicKey


Examples of java.security.interfaces.DSAPublicKey

    private static final class PublicKeyComparator implements Comparator<PublicKey> {

        public int compare(PublicKey a, PublicKey b) {
            if (a instanceof DSAPublicKey) {
                if (b instanceof DSAPublicKey) {
                    DSAPublicKey da = (DSAPublicKey) a;
                    DSAPublicKey db = (DSAPublicKey) b;
                    int r = da.getParams().getG().compareTo(db.getParams().getG());
                    if (r != 0) {
                        return r;
                    }
                    r = da.getParams().getP().compareTo(db.getParams().getP());
                    if (r != 0) {
                        return r;
                    }
                    r = da.getParams().getQ().compareTo(db.getParams().getQ());
                    if (r != 0) {
                        return r;
                    }
                    return da.getY().compareTo(db.getY());
                } else {
                    return -1;
                }
            } else if (a instanceof RSAPublicKey) {
                if (b instanceof RSAPublicKey) {
                    RSAPublicKey da = (RSAPublicKey) a;
                    RSAPublicKey db = (RSAPublicKey) b;
                    int r = da.getPublicExponent().compareTo(db.getPublicExponent());
                    if (r != 0) {
                        return r;
                    }
                    return da.getModulus().compareTo(db.getModulus());
                } else {
                    return -1;
                }
            } else {
                throw new IllegalArgumentException("Only RSA and DAS keys are supported.");
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

  if (key == null) {
      throw new NullPointerException("key cannot be null");
  }
  this.publicKey = key;
  if (key instanceof DSAPublicKey) {
      DSAPublicKey dkey = (DSAPublicKey) key;
      DSAParams params = dkey.getParams();
      p = new DOMCryptoBinary(params.getP());
      q = new DOMCryptoBinary(params.getQ());
      g = new DOMCryptoBinary(params.getG());
      y = new DOMCryptoBinary(dkey.getY());
  } else if (key instanceof RSAPublicKey) {
      RSAPublicKey rkey = (RSAPublicKey) key;
      exponent = new DOMCryptoBinary(rkey.getPublicExponent());
      modulus = new DOMCryptoBinary(rkey.getModulus());
  } else {
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

    assertEquals("SHA1WithECDSA", OCSPUtil.getSigningAlgFromAlgSelection("SHA1WithECDSA;SHA1WithDSA", ecdsa));
    assertEquals("SHA1WithECDSA", OCSPUtil.getSigningAlgFromAlgSelection("SHA1WithDSA;SHA1WithRSA;SHA1WithECDSA", ecdsa));
    assertEquals("SHA1WithECDSA", OCSPUtil.getSigningAlgFromAlgSelection("SHA1WithECDSA", ecdsa));
    assertEquals("SHA1WithECDSA", OCSPUtil.getSigningAlgFromAlgSelection("SHA1WithDSA;SHA1WithECDSA", ecdsa));
   
    DSAPublicKey dsa = new MockDSAPublicKey();
    assertEquals("SHA1WithDSA", OCSPUtil.getSigningAlgFromAlgSelection("SHA1WithECDSA;SHA1WithDSA", dsa));
    assertEquals("SHA1WithDSA", OCSPUtil.getSigningAlgFromAlgSelection("SHA256WithECDSA;SHA1WithECDSA;SHA1WithDSA", dsa));
    assertEquals("SHA1WithDSA", OCSPUtil.getSigningAlgFromAlgSelection("SHA1WithDSA", dsa));
    assertEquals("SHA1WithDSA", OCSPUtil.getSigningAlgFromAlgSelection("SHA1WithECDSA;SHA1WithDSA", dsa));
   
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

      } else {
        // We support the key, but we don't know the key length
        len = 0;
      }
    } else if (pk instanceof DSAPublicKey) {
      final DSAPublicKey dsapub = (DSAPublicKey) pk;
      if ( dsapub.getParams() != null ) {
        len = dsapub.getParams().getP().bitLength();
      } else {
        len = dsapub.getY().bitLength();
      }
    }
    return len;
  }
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

      log.debug("getKeyGenSpec: RSA");
      final RSAPublicKey rpk = (RSAPublicKey)pk;
      ret = new RSAKeyGenParameterSpec(getKeyLength(pk), rpk.getPublicExponent());
    } else if (pk instanceof DSAPublicKey) {
      log.debug("getKeyGenSpec: DSA");
      final DSAPublicKey dpk = (DSAPublicKey)pk;
      final DSAParams params = dpk.getParams();
      ret = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
    } else if (pk instanceof ECPublicKey) {
      log.debug("getKeyGenSpec: ECPublicKey");
      final ECPublicKey ecpub = (ECPublicKey) pk;
      final java.security.spec.ECParameterSpec sunsp = ecpub.getParams();
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

            ps.println("  the public value y: "+dh.getY().toString(16));
            return;
        }
        if ( publK instanceof DSAPublicKey ) {
            ps.println("DSA key:");
            final DSAPublicKey dsa = (DSAPublicKey)publK;
            ps.println("  the public value y: "+dsa.getY().toString(16));
            return;
        }
    }
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

            assertEquals(AlgorithmConstants.SIGALG_SHA1_WITH_DSA, sigAlg);
            assertTrue("Error in created ca certificate", cert.getSubjectDN().toString().equals("CN=TESTDSA"));
            assertTrue("Creating CA failed", info.getSubjectDN().equals("CN=TESTDSA"));
            PublicKey pk = cert.getPublicKey();
            if (pk instanceof DSAPublicKey) {
                DSAPublicKey rsapk = (DSAPublicKey) pk;
                assertEquals(rsapk.getAlgorithm(), "DSA");
            } else {
                assertTrue("Public key is not DSA", false);
            }
            assertTrue("CA is not valid for the specified duration.", cert.getNotAfter().after(
                    new Date(new Date().getTime() + 10 * 364 * 24 * 60 * 60 * 1000L))
 
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

        X509Certificate cert = (X509Certificate) signSession.createCertificate(admin, "foo", "foo123", selfcert);
        assertNotNull("Misslyckades skapa cert", cert);
        log.debug("Cert=" + cert.toString());
        PublicKey pk = cert.getPublicKey();
        if (pk instanceof DSAPublicKey) {
            DSAPublicKey ecpk = (DSAPublicKey) pk;
            assertEquals(ecpk.getAlgorithm(), "DSA");
        } else {
            assertTrue("Public key is not DSA", false);
        }
        try {
            cert.verify(rsacacert.getPublicKey());
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

        Certificate cert = CertTools.getCertfromByteArray(resp.getResponseMessage());
        assertNotNull("Failed to create certificate", cert);
        log.debug("Cert=" + cert.toString());
        PublicKey pk = cert.getPublicKey();
        if (pk instanceof DSAPublicKey) {
            DSAPublicKey dsapk = (DSAPublicKey) pk;
            assertEquals(dsapk.getAlgorithm(), "DSA");
        } else {
            assertTrue("Public key is not DSA", false);
        }
        try {
            cert.verify(rsacacert.getPublicKey());
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

        X509Certificate cert = (X509Certificate) signSession.createCertificate(admin, "foodsa", "foo123", selfcert);
        assertNotNull("Misslyckades skapa cert", cert);
        log.debug("Cert=" + cert.toString());
        PublicKey pk = cert.getPublicKey();
        if (pk instanceof DSAPublicKey) {
            DSAPublicKey dsapk = (DSAPublicKey) pk;
            assertEquals(dsapk.getAlgorithm(), "DSA");
        } else {
            assertTrue("Public key is not DSA", false);
        }
        try {
            cert.verify(dsacacert.getPublicKey());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.