Examples of DSAPublicKey


Examples of java.security.interfaces.DSAPublicKey

        //
        // key decoding test - serialisation test
        //

        DSAPublicKey k1 = (DSAPublicKey)serializeDeserialize(vKey);

        checkPublic(k1, vKey);

        DSAPrivateKey k2 = (DSAPrivateKey)serializeDeserialize(sKey);
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

        return kp;
    }

    protected static boolean areKeyEquals(PublicKey k1, PublicKey k2) {
        if (k1 instanceof DSAPublicKey && k2 instanceof DSAPublicKey) {
            DSAPublicKey d1 = (DSAPublicKey) k1;
            DSAPublicKey d2 = (DSAPublicKey) k2;
            DSAParams p1 = d1.getParams();
            DSAParams p2 = d2.getParams();
            return d1.getY().equals(d2.getY())
                        && p1.getG().equals(p2.getG())
                        && p1.getP().equals(p2.getP())
                        && p1.getQ().equals(p2.getQ());
        } else if (k1 instanceof ECPublicKey && k2 instanceof ECPublicKey) {
            ECPublicKey e1 = (ECPublicKey) k1;
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

   @Test
   public void testEncodeAsOpenSSH() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
      String dsa = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-dsa.txt"));
      DSAPublicKeySpec spec = DSAKeys.publicKeySpecFromOpenSSH(dsa);
      DSAPublicKey key = (DSAPublicKey) KeyFactory.getInstance("DSA").generatePublic(spec);

      assertEquals(DSAKeys.encodeAsOpenSSH(key), dsa);
   }
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

    }

    private String getString(PublicKey key) throws FailedLoginException {
        try {
            if (key instanceof DSAPublicKey) {
                DSAPublicKey dsa = (DSAPublicKey) key;
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                DataOutputStream dos = new DataOutputStream(baos);
                write(dos, "ssh-dss");
                write(dos, dsa.getParams().getP());
                write(dos, dsa.getParams().getQ());
                write(dos, dsa.getParams().getG());
                write(dos, dsa.getY());
                dos.close();
                return base64Encode(baos.toByteArray());
            } else if (key instanceof RSAKey) {
                RSAPublicKey rsa = (RSAPublicKey) key;
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

  {
    harness.checkPoint("testUnknownKeyPairCodec");

    kp = kpg.generate();

    DSAPublicKey pubK = (DSAPublicKey) kp.getPublic();
    try
      {
        ((DSSPublicKey) pubK).getEncoded(0);
        harness.fail("Public key succeeded with unknown format ID");
      }
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

    kp = kpg.generate();

    IKeyPairCodec codec = new DSSKeyPairRawCodec();
    byte[] pk;

    DSAPublicKey pubK = (DSAPublicKey) kp.getPublic();
    pk = ((DSSPublicKey) pubK).getEncoded(IKeyPairCodec.RAW_FORMAT);
    PublicKey newPubK = codec.decodePublicKey(pk);
    harness.check(pubK.equals(newPubK),
                  "DSS public key Raw encoder/decoder test");

    DSAPrivateKey secK = (DSAPrivateKey) kp.getPrivate();
    pk = ((DSSPrivateKey) secK).getEncoded(IKeyPairCodec.RAW_FORMAT);
    PrivateKey newSecK = codec.decodePrivateKey(pk);
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

    kp = kpg.generate();

    byte[] pk;

    DSAPublicKey pubK = (DSAPublicKey) kp.getPublic();
    DSAPrivateKey secK = (DSAPrivateKey) kp.getPrivate();

    pk = ((DSSPrivateKey) secK).getEncoded(IKeyPairCodec.PKCS8_FORMAT);
    PrivateKey newSecK = new DSSKeyPairPKCS8Codec().decodePrivateKey(pk);
    harness.check(secK.equals(newSecK),
                  "DSS private key ASN.1 encoder/decoder test");

    pk = ((DSSPublicKey) pubK).getEncoded(IKeyPairCodec.X509_FORMAT);
    PublicKey newPubK = new DSSKeyPairX509Codec().decodePublicKey(pk);
    harness.check(pubK.equals(newPubK),
                  "DSS public key ASN.1 encoder/decoder test");
  }
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

    harness.checkPoint("testPublicKeyValueOf");

    kp = kpg.generate();
    byte[] pk;

    DSAPublicKey p1 = (DSAPublicKey) kp.getPublic();

    pk = ((DSSPublicKey) p1).getEncoded(IKeyPairCodec.RAW_FORMAT);
    PublicKey p2 = DSSPublicKey.valueOf(pk);
    harness.check(p1.equals(p2),
                  "DSS public key valueOf(<raw-value>) test");

    pk = ((DSSPublicKey) p1).getEncoded(IKeyPairCodec.X509_FORMAT);
    PublicKey p3 = DSSPublicKey.valueOf(pk);
    harness.check(p1.equals(p3),
                  "DSS public key valueOf(<x509-value>) test");
  }
View Full Code Here

Examples of java.security.interfaces.DSAPublicKey

  public void test(TestHarness harness)
  {
    harness.checkPoint("TestOfDSSSignature");

    DSAPublicKey publicK = new DSSPublicKey(Registry.ASN1_ENCODING_ID, p, q, g, y);
    DSAPrivateKey privateK = new DSSPrivateKey(Registry.ASN1_ENCODING_ID, p, q, g, x);

    DSSSignature alice = new DSSSignature();
    DSSSignature bob = (DSSSignature) alice.clone();
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.