Package gnu.javax.crypto.key.dh

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


  {
    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("testPublicKeyValueOf");

    kp = kpg.generate();

    GnuDHPublicKey pubK = (GnuDHPublicKey) kp.getPublic();

    byte[] pk = ((GnuDHPublicKey) pubK).getEncoded(IKeyPairCodec.RAW_FORMAT);
    PublicKey newPubK = GnuDHPublicKey.valueOf(pk);

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

      throws InvalidKeySpecException
  {
    BigInteger p = spec.getP();
    BigInteger g = spec.getG();
    BigInteger y = spec.getY();
    return new GnuDHPublicKey(Registry.X509_ENCODING_ID, null, p, g, y);
  }
View Full Code Here

                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")
                  {
                    sig = new SSLRSASignature();
                  }
                else
                  {
                    sig = SignatureFactory.getInstance(Registry.DSS_SIG);
                  }
                sig.setupSign(Collections.singletonMap(ISignature.SIGNER_KEY,
                                                       signPair.getPrivate()));
                byte[] buf = clientRandom.getEncoded();
                sig.update(buf, 0, buf.length);
                buf = serverRandom.getEncoded();
                sig.update(buf, 0, buf.length);
                updateSig(sig, pubkey.getParams().getP());
                updateSig(sig, pubkey.getParams().getG());
                updateSig(sig, pubkey.getY());
                s = new Signature(sig.sign(), suite.getSignature());
              }
            skex = new ServerKeyExchange(pubkey, s);
          }
        else if (suite.getKeyExchange() == "SRP")
View Full Code Here

TOP

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

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.