Examples of DHBasicAgreement


Examples of org.bouncycastle.crypto.agreement.DHBasicAgreement

        // Testing ECIES with 1024-bit prime in streaming mode
        g.initialize(1024, new SecureRandom());
        doTest("DHIES with 1024-bit", g, "DHIES", params);

        c1 = new IESCipher(new IESEngine(new DHBasicAgreement(),
                new KDF2BytesGenerator(new SHA1Digest()),
                new HMac(new SHA1Digest()),
                new PaddedBufferedBlockCipher(new DESEngine())));
       
        c2 = new IESCipher(new IESEngine(new DHBasicAgreement(),
                new KDF2BytesGenerator(new SHA1Digest()),
                new HMac(new SHA1Digest()),
                new PaddedBufferedBlockCipher(new DESEngine())))
   
        params = new IESParameterSpec(derivation, encoding, 128, 192);
View Full Code Here

Examples of org.bouncycastle.crypto.agreement.DHBasicAgreement

            throw new IllegalArgumentException("'privateKey' must be private");
        }

        if (privateKey instanceof DHPrivateKeyParameters)
        {
            basicAgreement = new DHBasicAgreement();
            truncateAgreement = true;
        }
        else if (privateKey instanceof ECPrivateKeyParameters)
        {
            basicAgreement = new ECDHBasicAgreement();
View Full Code Here

Examples of org.bouncycastle.crypto.agreement.DHBasicAgreement

    public static byte[] calculateDHBasicAgreement(DHPublicKeyParameters publicKey,
                                                   DHPrivateKeyParameters privateKey)
    {

        DHBasicAgreement basicAgreement = new DHBasicAgreement();
        basicAgreement.init(privateKey);
        BigInteger agreementValue = basicAgreement.calculateAgreement(publicKey);

        /*
         * RFC 5246 8.1.2. Leading bytes of Z that contain all zero bits are stripped before it is
         * used as the pre_master_secret.
         */
 
View Full Code Here

Examples of org.bouncycastle.crypto.agreement.DHBasicAgreement

        extends CipherSpi
    {
        public IES()
        {
            super(new IESEngine(
                   new DHBasicAgreement(),
                   new KDF2BytesGenerator(new SHA1Digest()),
                   new HMac(new SHA1Digest())));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.agreement.DHBasicAgreement

        extends JCEIESCipher
    {
        public BrokenIES()
        {
            super(new IESEngine(
                   new DHBasicAgreement(),
                   new BrokenKDF2BytesGenerator(new SHA1Digest()),
                   new HMac(new SHA1Digest())));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.agreement.DHBasicAgreement

        extends JCEIESCipher
    {
        public IES()
        {
            super(new IESEngine(
                   new DHBasicAgreement(),
                   new KDF2BytesGenerator(new SHA1Digest()),
                   new HMac(new SHA1Digest())));
        }
View Full Code Here

Examples of org.bouncycastle.crypto.agreement.DHBasicAgreement

        DHPrivateKeyParameters      pv2 = (DHPrivateKeyParameters)pair.getPrivate();

        //
        // two way
        //
        DHBasicAgreement    e1 = new DHBasicAgreement();
        DHBasicAgreement    e2 = new DHBasicAgreement();

        e1.init(pv1);
        e2.init(pv2);

        BigInteger   k1 = e1.calculateAgreement(pu2);
        BigInteger   k2 = e2.calculateAgreement(pu1);

        if (!k1.equals(k2))
        {
            return new SimpleTestResult(false, "basic " + size + " bit 2-way test failed");
        }
View Full Code Here

Examples of org.bouncycastle.crypto.agreement.DHBasicAgreement

        DHPrivateKeyParameters      pv2 = (DHPrivateKeyParameters)pair.getPrivate();

        //
        // two way
        //
        DHBasicAgreement    e1 = new DHBasicAgreement();
        DHBasicAgreement    e2 = new DHBasicAgreement();

        e1.init(pv1);
        e2.init(pv2);

        BigInteger   k1 = e1.calculateAgreement(pu2);
        BigInteger   k2 = e2.calculateAgreement(pu1);

        if (!k1.equals(k2))
        {
            return new SimpleTestResult(false, "basic " + size + " bit 2-way test failed");
        }
View Full Code Here

Examples of org.bouncycastle.crypto.agreement.DHBasicAgreement

  private DHBasicAgreement myKeyAgree;
  private DHParameters param=null;

  public void init() throws Exception{
    myKeyAgree=new DHBasicAgreement();
  }
View Full Code Here

Examples of org.bouncycastle.crypto.agreement.DHBasicAgreement

         // Store the public value to send to server
         this.Yc = ((DHPublicKeyParameters)dhPair.getPublic()).getY();

         // Calculate the shared secret
         DHBasicAgreement dhAgree = new DHBasicAgreement();
         dhAgree.init(dhPair.getPrivate());

         BigInteger agreement = dhAgree.calculateAgreement(new DHPublicKeyParameters(Ys, dhParams));

         this.pms = BigIntegers.asUnsignedByteArray(agreement);
    }
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.