mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8266103: Better specified spec values
Reviewed-by: mullan, rhalade, mschoene
This commit is contained in:
parent
dd199ee063
commit
470e8a0fda
3 changed files with 20 additions and 9 deletions
|
@ -157,13 +157,16 @@ public class SecretKeySpec implements KeySpec, SecretKey {
|
|||
if (key.length == 0) {
|
||||
throw new IllegalArgumentException("Empty key");
|
||||
}
|
||||
if (key.length-offset < len) {
|
||||
throw new IllegalArgumentException
|
||||
("Invalid offset/length combination");
|
||||
if (offset < 0) {
|
||||
throw new ArrayIndexOutOfBoundsException("offset is negative");
|
||||
}
|
||||
if (len < 0) {
|
||||
throw new ArrayIndexOutOfBoundsException("len is negative");
|
||||
}
|
||||
if (key.length - offset < len) {
|
||||
throw new IllegalArgumentException
|
||||
("Invalid offset/length combination");
|
||||
}
|
||||
this.key = new byte[len];
|
||||
System.arraycopy(key, offset, this.key, 0, len);
|
||||
this.algorithm = algorithm;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue