mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
6227536: KeyGenerator.init() methods do not throw IllegalArgumentException for keysize == 0
Reviewed-by: wetmore
This commit is contained in:
parent
cc2861a993
commit
0bcf17674e
3 changed files with 76 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2022, 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
|
||||
|
@ -88,6 +88,11 @@ public final class HmacMD5KeyGenerator extends KeyGeneratorSpi {
|
|||
* @param random the source of randomness for this key generator
|
||||
*/
|
||||
protected void engineInit(int keysize, SecureRandom random) {
|
||||
|
||||
if (keysize <= 0) {
|
||||
throw new IllegalArgumentException("keysize must not be <= 0");
|
||||
}
|
||||
|
||||
this.keysize = (keysize+7) / 8;
|
||||
this.engineInit(random);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2022, 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
|
||||
|
@ -88,6 +88,11 @@ public final class HmacSHA1KeyGenerator extends KeyGeneratorSpi {
|
|||
* @param random the source of randomness for this key generator
|
||||
*/
|
||||
protected void engineInit(int keysize, SecureRandom random) {
|
||||
|
||||
if (keysize <= 0) {
|
||||
throw new IllegalArgumentException("keysize must not be <= 0");
|
||||
}
|
||||
|
||||
this.keysize = (keysize+7) / 8;
|
||||
this.engineInit(random);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue