jdk/src/share/classes/com/sun/crypto/provider/PBES2Core.java
changeset 16909 78a1749a43e2
parent 15010 ec6b49ce42b1
equal deleted inserted replaced
16850:f6f6c2182678 16909:78a1749a43e2
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package com.sun.crypto.provider;
    26 package com.sun.crypto.provider;
    27 
    27 
    28 import java.io.UnsupportedEncodingException;
       
    29 import java.security.*;
    28 import java.security.*;
    30 import java.security.spec.*;
    29 import java.security.spec.*;
    31 import javax.crypto.*;
    30 import javax.crypto.*;
    32 import javax.crypto.interfaces.*;
       
    33 import javax.crypto.spec.*;
    31 import javax.crypto.spec.*;
    34 
    32 
    35 /**
    33 /**
    36  * This class represents password-based encryption as defined by the PKCS #5
    34  * This class represents password-based encryption as defined by the PKCS #5
    37  * standard.
    35  * standard.
   143             SunJCE.getRandom().nextBytes(ivBytes);
   141             SunJCE.getRandom().nextBytes(ivBytes);
   144             ivSpec = new IvParameterSpec(ivBytes);
   142             ivSpec = new IvParameterSpec(ivBytes);
   145         }
   143         }
   146         PBEParameterSpec pbeSpec = new PBEParameterSpec(salt, iCount, ivSpec);
   144         PBEParameterSpec pbeSpec = new PBEParameterSpec(salt, iCount, ivSpec);
   147         try {
   145         try {
   148             params = AlgorithmParameters.getInstance(pbeAlgo, "SunJCE");
   146             params = AlgorithmParameters.getInstance(pbeAlgo,
       
   147                 SunJCE.getInstance());
       
   148             params.init(pbeSpec);
   149         } catch (NoSuchAlgorithmException nsae) {
   149         } catch (NoSuchAlgorithmException nsae) {
   150             // should never happen
   150             // should never happen
   151             throw new RuntimeException("SunJCE called, but not configured");
   151             throw new RuntimeException("SunJCE called, but not configured");
   152         } catch (NoSuchProviderException nspe) {
       
   153             // should never happen
       
   154             throw new RuntimeException("SunJCE called, but not configured");
       
   155         }
       
   156         try {
       
   157             params.init(pbeSpec);
       
   158         } catch (InvalidParameterSpecException ipse) {
   152         } catch (InvalidParameterSpecException ipse) {
   159             // should never happen
   153             // should never happen
   160             throw new RuntimeException("PBEParameterSpec not supported");
   154             throw new RuntimeException("PBEParameterSpec not supported");
   161         }
   155         }
   162         return params;
   156         return params;