equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 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 |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package javax.crypto.spec; |
26 package javax.crypto.spec; |
27 |
27 |
28 import java.io.UnsupportedEncodingException; |
|
29 import java.security.Key; |
|
30 import java.security.spec.KeySpec; |
28 import java.security.spec.KeySpec; |
31 import javax.crypto.SecretKey; |
29 import javax.crypto.SecretKey; |
32 |
30 |
33 /** |
31 /** |
34 * This class specifies a secret key in a provider-independent fashion. |
32 * This class specifies a secret key in a provider-independent fashion. |
93 throw new IllegalArgumentException("Missing argument"); |
91 throw new IllegalArgumentException("Missing argument"); |
94 } |
92 } |
95 if (key.length == 0) { |
93 if (key.length == 0) { |
96 throw new IllegalArgumentException("Empty key"); |
94 throw new IllegalArgumentException("Empty key"); |
97 } |
95 } |
98 this.key = (byte[])key.clone(); |
96 this.key = key.clone(); |
99 this.algorithm = algorithm; |
97 this.algorithm = algorithm; |
100 } |
98 } |
101 |
99 |
102 /** |
100 /** |
103 * Constructs a secret key from the given byte array, using the first |
101 * Constructs a secret key from the given byte array, using the first |
179 * |
177 * |
180 * @return the key material. Returns a new array |
178 * @return the key material. Returns a new array |
181 * each time this method is called. |
179 * each time this method is called. |
182 */ |
180 */ |
183 public byte[] getEncoded() { |
181 public byte[] getEncoded() { |
184 return (byte[])this.key.clone(); |
182 return this.key.clone(); |
185 } |
183 } |
186 |
184 |
187 /** |
185 /** |
188 * Calculates a hash code value for the object. |
186 * Calculates a hash code value for the object. |
189 * Objects that are equal will also have the same hashcode. |
187 * Objects that are equal will also have the same hashcode. |