Examples of SecureRandom


Examples of java.security.SecureRandom

            byte[]  d = new byte[16];
            byte[]  e = new byte[16];

            if (random == null)
            {
                random = new SecureRandom();
            }

            random.nextBytes(d);
            random.nextBytes(e);
View Full Code Here

Examples of java.security.SecureRandom

    // System.out.println( "get( " + keys + ") " + this );

    try{
      putInt( buffer, VERSION, 255 );
           
      SecureRandom random = SecureRandom.getInstance("SHA1PRNG");

      Signature sig = CryptoECCUtils.getSignature(myPrivateKey);
     
      if ( keys ){
               
        final byte[] rawMyPubkey = CryptoECCUtils.keyToRawdata(myPublicKey);
       
        final byte[] rawEphemeralPubkey = CryptoECCUtils.keyToRawdata(ephemeralKeyPair.getPublic());
       
        sig.update(rawMyPubkey);
         
        sig.update(rawEphemeralPubkey);
         
        final byte[] rawSign = sig.sign();
       
        final byte[] pad = new byte[random.nextInt(32)];
       
        random.nextBytes(pad);
       
        putBytes( buffer, rawMyPubkey, 65535 );
       
        putBytes( buffer, rawEphemeralPubkey, 65535 );
       
        putBytes( buffer, rawSign, 65535 );
       
        putBytes( buffer, pad, 65535 );
 
      }else{
         
        if ( sharedSecret == null ){
         
          throw( new CryptoManagerException( "phase error: keys not received" ));
        }
       
        final byte[] IV = new byte[20 + random.nextInt(32)];
       
        random.nextBytes(IV);

        sig.update(IV);
       
        sig.update(sharedSecret);
       
View Full Code Here

Examples of java.security.SecureRandom

      sslContext = SSLContext.getInstance("SSLv3");
      if (trustManager == null) {
        trustManager = new TrustManager[]{DummyTrustManager.getInstance()};
      }

      sslContext.init(new KeyManager[0], trustManager, new SecureRandom());
    }

    if (getSslSocketFactory() == null) {
      sslSocketFactory = sslContext.getSocketFactory();
    }
View Full Code Here

Examples of java.security.SecureRandom

        km = kmf.getKeyManagers();
      } else {
        km = new KeyManager[0];
      }

      context.init(km, getTrustManager(), new SecureRandom());
      setSslContext(context);
    }
   
    if(getSslSocketFactory()==null) {
      SSLSocketFactory factory = getSslContext().getSocketFactory();
View Full Code Here

Examples of java.security.SecureRandom

            this.random = rParam.getRandom();
            kParam = (AsymmetricKeyParameter)rParam.getParameters();
        }
        else
        {  
            this.random = new SecureRandom();
            kParam = (AsymmetricKeyParameter)param;
        }

        engine.init(forEncryption, kParam);
View Full Code Here

Examples of java.security.SecureRandom

                this.random = rParam.getRandom();
                this.key = (ECPrivateKeyParameters)rParam.getParameters();
            }
            else
            {
                this.random = new SecureRandom();
                this.key = (ECPrivateKeyParameters)param;
            }
        }
        else
        {
View Full Code Here

Examples of java.security.SecureRandom

      {
        pGen.init(strength, 20, random);
      }
      else
      {
        pGen.init(strength, 20, new SecureRandom());
      }

            DHParameters                p = pGen.generateParameters();

            AlgorithmParameters params;
View Full Code Here

Examples of java.security.SecureRandom

      {
        pGen.init(strength, 20, random);
      }
      else
      {
        pGen.init(strength, 20, new SecureRandom());
      }

            DSAParameters p = pGen.generateParameters();

            AlgorithmParameters params;
View Full Code Here

Examples of java.security.SecureRandom

      {
        pGen.init(strength, 20, random);
      }
      else
      {
        pGen.init(strength, 20, new SecureRandom());
      }

            ElGamalParameters p = pGen.generateParameters();

            AlgorithmParameters params;
View Full Code Here

Examples of java.security.SecureRandom

        {
            byte[]  iv = new byte[8];

      if (random == null)
      {
                random = new SecureRandom();
      }

            random.nextBytes(iv);

            AlgorithmParameters params;
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.