8266103: Better specified spec values

Reviewed-by: mullan, rhalade, mschoene
This commit is contained in:
Valerie Peng 2021-06-03 22:42:55 +00:00 committed by Henry Jen
parent dd199ee063
commit 470e8a0fda
3 changed files with 20 additions and 9 deletions

View file

@ -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");