Home | History | Annotate | Download | only in spec
      1 /* GENERATED SOURCE. DO NOT MODIFY. */
      2 package com.android.org.bouncycastle.jcajce.spec;
      3 
      4 import javax.crypto.spec.PBEKeySpec;
      5 
      6 import com.android.org.bouncycastle.asn1.DERNull;
      7 import com.android.org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
      8 import com.android.org.bouncycastle.asn1.x509.AlgorithmIdentifier;
      9 
     10 /**
     11  * Extension of PBEKeySpec which takes into account the PRF algorithm setting available in PKCS#5 PBKDF2.
     12  * @hide This class is not part of the Android public SDK API
     13  */
     14 public class PBKDF2KeySpec
     15     extends PBEKeySpec
     16 {
     17     private static final AlgorithmIdentifier defaultPRF = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_hmacWithSHA1, DERNull.INSTANCE);
     18 
     19     private AlgorithmIdentifier prf;
     20 
     21     /**
     22      * Base constructor.
     23      *
     24      * @param password password to use as the seed of the PBE key generator.
     25      * @param salt salt to use in the generator,
     26      * @param iterationCount iteration count to use in the generator.
     27      * @param keySize size of the key to be generated (in bits).
     28      * @param prf identifier and parameters for the PRF algorithm to use.
     29      */
     30     public PBKDF2KeySpec(char[] password, byte[] salt, int iterationCount, int keySize, AlgorithmIdentifier prf)
     31     {
     32         super(password, salt, iterationCount, keySize);
     33 
     34         this.prf = prf;
     35     }
     36 
     37     /**
     38      * Return true if this spec is for the default PRF (HmacSHA1), false otherwise.
     39      *
     40      * @return true if this spec uses the default PRF, false otherwise.
     41      */
     42     public boolean isDefaultPrf()
     43     {
     44         return defaultPRF.equals(prf);
     45     }
     46 
     47     /**
     48      * Return an AlgorithmIdentifier representing the PRF.
     49      *
     50      * @return the PRF's AlgorithmIdentifier.
     51      */
     52     public AlgorithmIdentifier getPrf()
     53     {
     54         return prf;
     55     }
     56 }
     57