jdk/src/share/classes/com/sun/crypto/provider/PBEParameters.java
changeset 14405 e7fff80005c1
parent 10336 0bb1999251f8
equal deleted inserted replaced
14404:7a5587e58dd2 14405:e7fff80005c1
     1 /*
     1 /*
     2  * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    55     private byte[] salt = null;
    55     private byte[] salt = null;
    56 
    56 
    57     // the iteration count
    57     // the iteration count
    58     private int iCount = 0;
    58     private int iCount = 0;
    59 
    59 
       
    60     // the cipher parameter
       
    61     private AlgorithmParameterSpec cipherParam = null;
       
    62 
    60     protected void engineInit(AlgorithmParameterSpec paramSpec)
    63     protected void engineInit(AlgorithmParameterSpec paramSpec)
    61         throws InvalidParameterSpecException
    64         throws InvalidParameterSpecException
    62    {
    65    {
    63        if (!(paramSpec instanceof PBEParameterSpec)) {
    66        if (!(paramSpec instanceof PBEParameterSpec)) {
    64            throw new InvalidParameterSpecException
    67            throw new InvalidParameterSpecException
    65                ("Inappropriate parameter specification");
    68                ("Inappropriate parameter specification");
    66        }
    69        }
    67        this.salt = ((PBEParameterSpec)paramSpec).getSalt().clone();
    70        this.salt = ((PBEParameterSpec)paramSpec).getSalt().clone();
    68        this.iCount = ((PBEParameterSpec)paramSpec).getIterationCount();
    71        this.iCount = ((PBEParameterSpec)paramSpec).getIterationCount();
       
    72        this.cipherParam = ((PBEParameterSpec)paramSpec).getParameterSpec();
    69     }
    73     }
    70 
    74 
    71     protected void engineInit(byte[] encoded)
    75     protected void engineInit(byte[] encoded)
    72         throws IOException
    76         throws IOException
    73     {
    77     {
   100     protected <T extends AlgorithmParameterSpec>
   104     protected <T extends AlgorithmParameterSpec>
   101             T engineGetParameterSpec(Class<T> paramSpec)
   105             T engineGetParameterSpec(Class<T> paramSpec)
   102         throws InvalidParameterSpecException
   106         throws InvalidParameterSpecException
   103     {
   107     {
   104         if (PBEParameterSpec.class.isAssignableFrom(paramSpec)) {
   108         if (PBEParameterSpec.class.isAssignableFrom(paramSpec)) {
   105             return paramSpec.cast(new PBEParameterSpec(this.salt, this.iCount));
   109             return paramSpec.cast(
       
   110                 new PBEParameterSpec(this.salt, this.iCount, this.cipherParam));
   106         } else {
   111         } else {
   107             throw new InvalidParameterSpecException
   112             throw new InvalidParameterSpecException
   108                 ("Inappropriate parameter specification");
   113                 ("Inappropriate parameter specification");
   109         }
   114         }
   110     }
   115     }