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.
|
||||
*
|
||||
* 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) {
|
||||
throw new IllegalArgumentException("IV missing");
|
||||
}
|
||||
if (iv.length - offset < len) {
|
||||
throw new IllegalArgumentException
|
||||
("IV buffer too short for given offset/length combination");
|
||||
if (offset < 0) {
|
||||
throw new ArrayIndexOutOfBoundsException("offset is negative");
|
||||
}
|
||||
if (len < 0) {
|
||||
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];
|
||||
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.
|
||||
*
|
||||
* 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.rounds = rounds;
|
||||
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;
|
||||
if (iv.length - offset < blockSize) {
|
||||
throw new IllegalArgumentException("IV too short");
|
||||
|
@ -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…
Reference in New Issue
Block a user