Package javax.crypto

Examples of javax.crypto.KeyAgreement.generateSecret()


        if (!DESedeKeySpec.isParityAdjusted(key.getEncoded(), 0))
        {
            fail("DESEDE parity wrong");
        }

        key = keyAgreement.generateSecret("Blowfish");

        if (key.getEncoded().length != 56)
        {
            fail("Blowfish length wrong");
        }
View Full Code Here


        //
        aKeyAgree.doPhase(bKeyPair.getPublic(), true);
        bKeyAgree.doPhase(aKeyPair.getPublic(), true);

        BigInteger  k1 = new BigInteger(aKeyAgree.generateSecret());
        BigInteger  k2 = new BigInteger(bKeyAgree.generateSecret());

        if (!k1.equals(k2))
        {
            fail("2-way test failed");
        }
View Full Code Here

        // generate shared secret key
        KeyAgreement ka = KeyAgreement.getInstance("DH");
        ka.init(privateKey);
        ka.doPhase(vlPublic, true);
        byte[] secretKey = ka.generateSecret();

        if (debug) {
            Debug.logInfo("Secret Key : " + StringUtil.toHexString(secretKey) + " / " + secretKey.length,  module);
        }
View Full Code Here

    throws NoSuchAlgorithmException,
           InvalidKeyException {
    KeyAgreement ka = KeyAgreement.getInstance("DH");
    ka.init(keyPair.getPrivate());
    ka.doPhase(publicKey, true);
    return ka.generateSecret("DESede");
  }
 
  public EncryptionOptions getEncryptionOptions(
    Encryption enc)
      throws InvalidKeyException,
View Full Code Here

        KeyAgreement agreement = KeyAgreement.getInstance("DH");

        agreement.init(this.keys.getPrivate());
        agreement.doPhase(publicKey, true);

        byte[] secret = agreement.generateSecret();

        return Unpooled.wrappedBuffer(secret);
    }
}
View Full Code Here

        byte[] bobSS = new byte[len];
        String msg = "generateSecret(byte[" + bobSS.length
                     + "], 1) MUST throw ShortBufferException";
        try // with a shorter buffer first!
          {
            bobKA.generateSecret(bobSS, 1);
            harness.fail(msg);
          }
        catch (ShortBufferException e)
          {
            harness.check(true, msg);
View Full Code Here

        catch (ShortBufferException e)
          {
            harness.check(true, msg);
          }
        // now do it properly
        bobKA.generateSecret(bobSS, 0);

        harness.check(Arrays.equals(aliceSS, bobSS),
                      "Shared secrets MUST be equal");

        harness.verbose("*** Bob generates a new shared secret");
View Full Code Here

        harness.verbose("*** Bob generates a new shared secret");
        // The call to bobKA.generateSecret above resets the key-agreement
        // object, so we call doPhase() again before calling generateSecret()
        bobKA.doPhase(alicePubK, true);
        SecretKey bobSK = bobKA.generateSecret("DES");

        harness.verbose("*** Alice generates a new shared secret");
        aliceKA.doPhase(bobPubK, true);
        SecretKey aliceSK = aliceKA.generateSecret("DES");

View Full Code Here

        // generate shared secret key
        KeyAgreement ka = KeyAgreement.getInstance("DH");
        ka.init(privateKey);
        ka.doPhase(vlPublic, true);
        byte[] secretKey = ka.generateSecret();

        if (debug) {
            Debug.log("Secret Key : " + StringUtil.toHexString(secretKey) + " / " + secretKey.length,  module);
        }
View Full Code Here

        // generate shared secret key
        KeyAgreement ka = KeyAgreement.getInstance("DH");
        ka.init(privateKey);
        ka.doPhase(vlPublic, true);
        byte[] secretKey = ka.generateSecret();

        if (debug) {
            Debug.log("Secret Key : " + StringUtil.toHexString(secretKey) + " / " + secretKey.length,  module);
        }
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.