Package gnu.javax.crypto.key.dh

Examples of gnu.javax.crypto.key.dh.GnuDHPrivateKey


    harness.checkPoint("testKeyPairRawCodec");

    kp = kpg.generate();

    GnuDHPublicKey pubK = (GnuDHPublicKey) kp.getPublic();
    GnuDHPrivateKey secK = (GnuDHPrivateKey) kp.getPrivate();

    byte[] pk1, pk2;

    pk1 = ((GnuDHPublicKey) pubK).getEncoded(IKeyPairCodec.RAW_FORMAT);
    pk2 = ((GnuDHPrivateKey) secK).getEncoded(IKeyPairCodec.RAW_FORMAT);

    IKeyPairCodec codec = new DHKeyPairRawCodec();
    PublicKey newPubK = codec.decodePublicKey(pk1);
    PrivateKey newSecK = codec.decodePrivateKey(pk2);

    harness.check(pubK.equals(newPubK),
                  "DH public key Raw encoder/decoder test");
    harness.check(secK.equals(newSecK),
                  "DH private key Raw encoder/decoder test");
  }
View Full Code Here


  {
    harness.checkPoint("testPrivateKeyValueOf");

    kp = kpg.generate();

    GnuDHPrivateKey privateK = (GnuDHPrivateKey) kp.getPrivate();

    byte[] pk = ((GnuDHPrivateKey) privateK).getEncoded(IKeyPairCodec.RAW_FORMAT);
    PrivateKey newSecK = GnuDHPrivateKey.valueOf(pk);

    harness.check(privateK.equals(newSecK),
                  "DH public key valueOf(<raw-value>) test");
  }
View Full Code Here

      throws InvalidKeySpecException
  {
    BigInteger p = spec.getP();
    BigInteger g = spec.getG();
    BigInteger x = spec.getX();
    return new GnuDHPrivateKey(Registry.PKCS8_ENCODING_ID, null, p, g, x);
  }
View Full Code Here

        else if (suite.getKeyExchange().startsWith("DH"))
          {
            if (clientKeys == null ||
                !(clientKeys.getPublic() instanceof DHPublicKey))
              {
                GnuDHPrivateKey tmpKey =
                  new GnuDHPrivateKey(null, ((DHPublicKey) serverKex).getParams().getP(),
                      ((DHPublicKey) serverKex).getParams().getG(), null);
                clientKA = KeyAgreementFactory.getPartyBInstance(Registry.DH_KA);
                Map attr = new HashMap();
                attr.put(DiffieHellmanKeyAgreement.KA_DIFFIE_HELLMAN_OWNER_PRIVATE_KEY,
                         tmpKey);
View Full Code Here

          }
        else if (suite.getKeyExchange() == "DHE")
          {
            serverKA = KeyAgreementFactory.getPartyAInstance(Registry.DH_KA);
            Map attr = new HashMap();
            GnuDHPrivateKey servParams = DiffieHellman.getParams();
            attr.put(DiffieHellmanKeyAgreement.KA_DIFFIE_HELLMAN_OWNER_PRIVATE_KEY,
                     servParams);
            attr.put(DiffieHellmanKeyAgreement.SOURCE_OF_RANDOMNESS,
                     session.random);
            BigInteger serv_y = null;
            try
              {
                serverKA.init(attr);
                out = serverKA.processMessage(null);
                in = new IncomingMessage(out.toByteArray());
                serv_y = in.readMPI();
              }
            catch (KeyAgreementException kae)
              {
                if (DEBUG_KEY_EXCHANGE)
                  {
                    logger.log (Component.SSL_KEY_EXCHANGE, "DHE exception", kae);
                  }
                internalError();
                RuntimeException re = new RuntimeException (kae.getMessage());
                re.initCause (kae);
                throw re;
              }
            GnuDHPublicKey pubkey =
              new GnuDHPublicKey(null, servParams.getParams().getP(),
                                 servParams.getParams().getG(), serv_y);
            Signature s = null;
            if (suite.getSignature() != "anon")
              {
                ISignature sig = null;
                if (suite.getSignature() == "RSA")
View Full Code Here

TOP

Related Classes of gnu.javax.crypto.key.dh.GnuDHPrivateKey

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.