8266103: Better specified spec values
Reviewed-by: mullan, rhalade, mschoene
This commit is contained in:
parent
dd199ee063
commit
470e8a0fda
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -76,13 +76,16 @@ public class IvParameterSpec implements AlgorithmParameterSpec {
|
|||||||
if (iv == null) {
|
if (iv == null) {
|
||||||
throw new IllegalArgumentException("IV missing");
|
throw new IllegalArgumentException("IV missing");
|
||||||
}
|
}
|
||||||
if (iv.length - offset < len) {
|
if (offset < 0) {
|
||||||
throw new IllegalArgumentException
|
throw new ArrayIndexOutOfBoundsException("offset is negative");
|
||||||
("IV buffer too short for given offset/length combination");
|
|
||||||
}
|
}
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
throw new ArrayIndexOutOfBoundsException("len is negative");
|
throw new ArrayIndexOutOfBoundsException("len is negative");
|
||||||
}
|
}
|
||||||
|
if (iv.length - offset < len) {
|
||||||
|
throw new IllegalArgumentException
|
||||||
|
("IV buffer too short for given offset/length combination");
|
||||||
|
}
|
||||||
this.iv = new byte[len];
|
this.iv = new byte[len];
|
||||||
System.arraycopy(iv, offset, this.iv, 0, len);
|
System.arraycopy(iv, offset, this.iv, 0, len);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -114,7 +114,12 @@ public class RC5ParameterSpec implements AlgorithmParameterSpec {
|
|||||||
this.version = version;
|
this.version = version;
|
||||||
this.rounds = rounds;
|
this.rounds = rounds;
|
||||||
this.wordSize = wordSize;
|
this.wordSize = wordSize;
|
||||||
if (iv == null) throw new IllegalArgumentException("IV missing");
|
if (iv == null) {
|
||||||
|
throw new IllegalArgumentException("IV missing");
|
||||||
|
}
|
||||||
|
if (offset < 0) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException("offset is negative");
|
||||||
|
}
|
||||||
int blockSize = (wordSize / 8) * 2;
|
int blockSize = (wordSize / 8) * 2;
|
||||||
if (iv.length - offset < blockSize) {
|
if (iv.length - offset < blockSize) {
|
||||||
throw new IllegalArgumentException("IV too short");
|
throw new IllegalArgumentException("IV too short");
|
||||||
|
@ -157,13 +157,16 @@ public class SecretKeySpec implements KeySpec, SecretKey {
|
|||||||
if (key.length == 0) {
|
if (key.length == 0) {
|
||||||
throw new IllegalArgumentException("Empty key");
|
throw new IllegalArgumentException("Empty key");
|
||||||
}
|
}
|
||||||
if (key.length-offset < len) {
|
if (offset < 0) {
|
||||||
throw new IllegalArgumentException
|
throw new ArrayIndexOutOfBoundsException("offset is negative");
|
||||||
("Invalid offset/length combination");
|
|
||||||
}
|
}
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
throw new ArrayIndexOutOfBoundsException("len is negative");
|
throw new ArrayIndexOutOfBoundsException("len is negative");
|
||||||
}
|
}
|
||||||
|
if (key.length - offset < len) {
|
||||||
|
throw new IllegalArgumentException
|
||||||
|
("Invalid offset/length combination");
|
||||||
|
}
|
||||||
this.key = new byte[len];
|
this.key = new byte[len];
|
||||||
System.arraycopy(key, offset, this.key, 0, len);
|
System.arraycopy(key, offset, this.key, 0, len);
|
||||||
this.algorithm = algorithm;
|
this.algorithm = algorithm;
|
||||||
|
Loading…
Reference in New Issue
Block a user