Examples of DSAPrivateKey


Examples of java.security.interfaces.DSAPrivateKey

        DSAPublicKey k1 = (DSAPublicKey)serializeDeserialize(vKey);

        checkPublic(k1, vKey);

        DSAPrivateKey k2 = (DSAPrivateKey)serializeDeserialize(sKey);

        checkPrivateKey(k2, sKey);

        //
        // ECDSA Fp generation test
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

     *             public key
     */
    public static PublicKey derivePublicKey(PrivateKey key) throws KeyException {
        KeyFactory factory;
        if (key instanceof DSAPrivateKey) {
            DSAPrivateKey dsaKey = (DSAPrivateKey) key;
            DSAParams keyParams = dsaKey.getParams();
            BigInteger y = keyParams.getQ().modPow(dsaKey.getX(), keyParams.getP());
            DSAPublicKeySpec pubKeySpec = new DSAPublicKeySpec(y, keyParams.getP(), keyParams.getQ(), keyParams.getG());

            try {
                factory = KeyFactory.getInstance("DSA");
                return factory.generatePublic(pubKeySpec);
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

    catch (IllegalArgumentException x)
      {
        harness.check(true, "Recognised unknown public key format ID");
      }

    DSAPrivateKey secK = (DSAPrivateKey) kp.getPrivate();
    try
      {
        ((DSSPrivateKey) secK).getEncoded(0);
        harness.fail("Private key succeeded with unknown format ID");
      }
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

    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);
    harness.check(secK.equals(newSecK),
                  "DSS private key Raw encoder/decoder test");
  }
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

    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),
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

    harness.checkPoint("testPrivateKeyValueOf");

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

    DSAPrivateKey p1 = (DSAPrivateKey) kp.getPrivate();

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

    pk = ((DSSPrivateKey) p1).getEncoded(IKeyPairCodec.PKCS8_FORMAT);
    PrivateKey p3 = DSSPrivateKey.valueOf(pk);
    harness.check(p1.equals(p3),
                  "DSS private key valueOf(<pkcs8-value>) test");
  }
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

  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();

    byte[] message = "1 if by land, 2 if by sea...".getBytes();
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

            final DHPrivateKey dh = (DHPrivateKey)privK;
            final BigInteger result = dh.getX();
            return result!=null && result.bitLength()>0;
        }
        if ( privK instanceof DSAPrivateKey) {
            final DSAPrivateKey dsa = (DSAPrivateKey)privK;
            final BigInteger result = dsa.getX();
            return result!=null && result.bitLength()>0;
        }
        return false;
    }
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

            if (keySpec == null) {
                throw new NullPointerException(Messages
                        .getString("security.19E")); //$NON-NLS-1$
            }
            if (key instanceof DSAPrivateKey) {
                DSAPrivateKey privateKey = (DSAPrivateKey) key;

                if (keySpec.equals(DSAPrivateKeySpec.class)) {

                    x = privateKey.getX();

                    DSAParams params = privateKey.getParams();

                    p = params.getP();
                    q = params.getQ();
                    g = params.getG();
View Full Code Here

Examples of java.security.interfaces.DSAPrivateKey

    protected Key engineTranslateKey(Key key) throws InvalidKeyException {

        if (key != null) {
            if (key instanceof DSAPrivateKey) {

                DSAPrivateKey privateKey = (DSAPrivateKey) key;
                DSAParams params = privateKey.getParams();

                try {
                    return engineGeneratePrivate(new DSAPrivateKeySpec(
                            privateKey.getX(), params.getP(), params.getQ(),
                            params.getG()));
                } catch (InvalidKeySpecException e) {
                    // Actually this exception shouldn't be thrown
                    throw new InvalidKeyException(Messages.getString(
                            "security.1A0", e)); //$NON-NLS-1$
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.