1 /* |
1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2012, 2013, 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 |
132 protected AlgorithmParameters engineGetParameters() { |
132 protected AlgorithmParameters engineGetParameters() { |
133 AlgorithmParameters params = null; |
133 AlgorithmParameters params = null; |
134 if (salt == null) { |
134 if (salt == null) { |
135 // generate random salt and use default iteration count |
135 // generate random salt and use default iteration count |
136 salt = new byte[DEFAULT_SALT_LENGTH]; |
136 salt = new byte[DEFAULT_SALT_LENGTH]; |
137 SunJCE.RANDOM.nextBytes(salt); |
137 SunJCE.getRandom().nextBytes(salt); |
138 iCount = DEFAULT_COUNT; |
138 iCount = DEFAULT_COUNT; |
139 } |
139 } |
140 if (ivSpec == null) { |
140 if (ivSpec == null) { |
141 // generate random IV |
141 // generate random IV |
142 byte[] ivBytes = new byte[blkSize]; |
142 byte[] ivBytes = new byte[blkSize]; |
143 SunJCE.RANDOM.nextBytes(ivBytes); |
143 SunJCE.getRandom().nextBytes(ivBytes); |
144 ivSpec = new IvParameterSpec(ivBytes); |
144 ivSpec = new IvParameterSpec(ivBytes); |
145 } |
145 } |
146 PBEParameterSpec pbeSpec = new PBEParameterSpec(salt, iCount, ivSpec); |
146 PBEParameterSpec pbeSpec = new PBEParameterSpec(salt, iCount, ivSpec); |
147 try { |
147 try { |
148 params = AlgorithmParameters.getInstance(pbeAlgo, "SunJCE"); |
148 params = AlgorithmParameters.getInstance(pbeAlgo, "SunJCE"); |