[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bouncycastle-crypto-dev
Subject:    Re: [dev-crypto] PBE not getting slower with iteration count
From:       David Hook <dgh () lockboxlabs ! com>
Date:       2011-11-22 0:11:08
Message-ID: 1321920668.2349.15.camel () konkolo
[Download RAW message or body]


These refer to the v1 algorithms which have a hard coded iteration count
of 1.

Regards,

David

On Wed, 2011-11-16 at 19:42 +0100, ilab wrote:
> Hello,
> 
> In my understanding, initializing PBE encryption should get slower with 
> iteration count grow - well, this is the point of iteration in the 
> process. This works as excepted in case of for example 
> PBEWITHMD5AND128BITAES-CBC-OPENSSL or PBEWithMD5AndDES or 
> PBEWithSHA1AndDESede. However, for example with 
> PBEWITHMD5AND128BITAES-CBC-OPENSSL, the initialization seems to take 
> constant time whatever the iteration count is (i.e. 1 or 10000000).
> 
> I used the following code for testing:
> 
>          long s = Calendar.getInstance().getTimeInMillis();
> 
>          // Generate salt
>          SecureRandom rand = new SecureRandom();
>          byte[] salt = new byte[PBESaltLength];
>          rand.nextBytes(salt);
> 
>          // Create PBE parameter set
>          PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 
> PBEIterationCount);
>          PBEKeySpec pbeKeySpec = new PBEKeySpec(password.toCharArray());
>          SecretKeyFactory keyFac = 
> SecretKeyFactory.getInstance(PBEAlgorythm);
>          SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);
> 
>          // Initialize PBE Cipher with key and parameters
>          Cipher pbeCipher = Cipher.getInstance(PBEAlgorythm);
>          pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);
> 
>          long e = Calendar.getInstance().getTimeInMillis();
>          System.out.println("elapsed: " + (e - s));
> 
> 
> Is it a bug, or I miss something?
> 
> Thanks,
> ilab
> 



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic