equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 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 |
225 if (salt == null) { |
225 if (salt == null) { |
226 // Cipher is not initialized with parameters; |
226 // Cipher is not initialized with parameters; |
227 // follow the recommendation in PKCS12 v1.0 |
227 // follow the recommendation in PKCS12 v1.0 |
228 // section B.4 to generate salt and iCount. |
228 // section B.4 to generate salt and iCount. |
229 salt = new byte[DEFAULT_SALT_LENGTH]; |
229 salt = new byte[DEFAULT_SALT_LENGTH]; |
230 SunJCE.RANDOM.nextBytes(salt); |
230 SunJCE.getRandom().nextBytes(salt); |
231 iCount = DEFAULT_COUNT; |
231 iCount = DEFAULT_COUNT; |
232 } |
232 } |
233 PBEParameterSpec pbeSpec = new PBEParameterSpec(salt, iCount); |
233 PBEParameterSpec pbeSpec = new PBEParameterSpec(salt, iCount); |
234 try { |
234 try { |
235 params = AlgorithmParameters.getInstance(pbeAlgo, "SunJCE"); |
235 params = AlgorithmParameters.getInstance(pbeAlgo, "SunJCE"); |
292 if (salt == null) { |
292 if (salt == null) { |
293 salt = new byte[DEFAULT_SALT_LENGTH]; |
293 salt = new byte[DEFAULT_SALT_LENGTH]; |
294 if (random != null) { |
294 if (random != null) { |
295 random.nextBytes(salt); |
295 random.nextBytes(salt); |
296 } else { |
296 } else { |
297 SunJCE.RANDOM.nextBytes(salt); |
297 SunJCE.getRandom().nextBytes(salt); |
298 } |
298 } |
299 } |
299 } |
300 if (iCount == 0) iCount = DEFAULT_COUNT; |
300 if (iCount == 0) iCount = DEFAULT_COUNT; |
301 } else if (!(params instanceof PBEParameterSpec)) { |
301 } else if (!(params instanceof PBEParameterSpec)) { |
302 throw new InvalidAlgorithmParameterException |
302 throw new InvalidAlgorithmParameterException |