equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2011, 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 |
131 int intR = keyLength - (intL - 1)*hlen; // residue |
131 int intR = keyLength - (intL - 1)*hlen; // residue |
132 byte[] ui = new byte[hlen]; |
132 byte[] ui = new byte[hlen]; |
133 byte[] ti = new byte[hlen]; |
133 byte[] ti = new byte[hlen]; |
134 // SecretKeySpec cannot be used, since password can be empty here. |
134 // SecretKeySpec cannot be used, since password can be empty here. |
135 SecretKey macKey = new SecretKey() { |
135 SecretKey macKey = new SecretKey() { |
|
136 private static final long serialVersionUID = 7874493593505141603L; |
136 @Override |
137 @Override |
137 public String getAlgorithm() { |
138 public String getAlgorithm() { |
138 return prf.getAlgorithm(); |
139 return prf.getAlgorithm(); |
139 } |
140 } |
140 @Override |
141 @Override |
192 } |
193 } |
193 return key; |
194 return key; |
194 } |
195 } |
195 |
196 |
196 public byte[] getEncoded() { |
197 public byte[] getEncoded() { |
197 return (byte[]) key.clone(); |
198 return key.clone(); |
198 } |
199 } |
199 |
200 |
200 public String getAlgorithm() { |
201 public String getAlgorithm() { |
201 return "PBKDF2With" + prf.getAlgorithm(); |
202 return "PBKDF2With" + prf.getAlgorithm(); |
202 } |
203 } |
204 public int getIterationCount() { |
205 public int getIterationCount() { |
205 return iterCount; |
206 return iterCount; |
206 } |
207 } |
207 |
208 |
208 public char[] getPassword() { |
209 public char[] getPassword() { |
209 return (char[]) passwd.clone(); |
210 return passwd.clone(); |
210 } |
211 } |
211 |
212 |
212 public byte[] getSalt() { |
213 public byte[] getSalt() { |
213 return salt.clone(); |
214 return salt.clone(); |
214 } |
215 } |
266 * erased when there are no more references to it. |
267 * erased when there are no more references to it. |
267 */ |
268 */ |
268 protected void finalize() throws Throwable { |
269 protected void finalize() throws Throwable { |
269 try { |
270 try { |
270 if (this.passwd != null) { |
271 if (this.passwd != null) { |
271 java.util.Arrays.fill(this.passwd, (char) '0'); |
272 java.util.Arrays.fill(this.passwd, '0'); |
272 this.passwd = null; |
273 this.passwd = null; |
273 } |
274 } |
274 if (this.key != null) { |
275 if (this.key != null) { |
275 java.util.Arrays.fill(this.key, (byte)0x00); |
276 java.util.Arrays.fill(this.key, (byte)0x00); |
276 this.key = null; |
277 this.key = null; |