8333364: Minor cleanup could be done in com.sun.crypto.provider

Reviewed-by: mullan, valeriep
This commit is contained in:
Mark Powers 2024-07-09 20:38:09 +00:00
parent 7e11fb7026
commit 1472124489
47 changed files with 313 additions and 367 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2024, 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
@ -285,7 +285,7 @@ abstract class KeyWrapCipher extends CipherSpi {
padLen = SEMI_BLKSIZE - n;
}
}
// then add the first semiblock and padLen to result
// then add the first semi-block and padLen to result
result = Math.addExact(result, SEMI_BLKSIZE + padLen);
} else {
result = inLen - SEMI_BLKSIZE;
@ -339,7 +339,7 @@ abstract class KeyWrapCipher extends CipherSpi {
protected void engineInit(int opmode, Key key, SecureRandom random)
throws InvalidKeyException {
try {
implInit(opmode, key, (byte[])null, random);
implInit(opmode, key, null, random);
} catch (InvalidAlgorithmParameterException iae) {
// should never happen
throw new AssertionError(iae);
@ -394,9 +394,9 @@ abstract class KeyWrapCipher extends CipherSpi {
byte[] iv = null;
if (params != null) {
try {
AlgorithmParameterSpec spec =
IvParameterSpec spec =
params.getParameterSpec(IvParameterSpec.class);
iv = ((IvParameterSpec)spec).getIV();
iv = spec.getIV();
} catch (InvalidParameterSpecException ispe) {
throw new InvalidAlgorithmParameterException(
"Only IvParameterSpec is accepted");
@ -462,7 +462,7 @@ abstract class KeyWrapCipher extends CipherSpi {
if (inLen <= 0) return;
if (opmode == Cipher.ENCRYPT_MODE && dataIdx == 0) {
// the first semiblock is for iv, store data after it
// the first semi-block is for iv, store data after it
dataIdx = SEMI_BLKSIZE;
}
store(in, inOfs, inLen);
@ -595,8 +595,8 @@ abstract class KeyWrapCipher extends CipherSpi {
}
// helper routine for in-place encryption.
// 'inBuf' = semiblock | plain text | extra bytes if padding is used
// 'inLen' = semiblock length + plain text length
// 'inBuf' = semi-block | plain text | extra bytes if padding is used
// 'inLen' = semi-block length + plain text length
private int helperEncrypt(byte[] inBuf, int inLen)
throws IllegalBlockSizeException, ShortBufferException {
@ -646,7 +646,7 @@ abstract class KeyWrapCipher extends CipherSpi {
*/
@Override
protected AlgorithmParameters engineGetParameters() {
AlgorithmParameters params = null;
AlgorithmParameters params;
byte[] iv = cipher.getIV();
if (iv == null) {
@ -711,7 +711,7 @@ abstract class KeyWrapCipher extends CipherSpi {
// output size is known, allocate output buffer
byte[] out = new byte[engineGetOutputSize(encoded.length)];
// reserve the first semiblock and do not write data
// reserve the first semi-block and do not write data
int len = SEMI_BLKSIZE;
System.arraycopy(encoded, 0, out, len, encoded.length);
len += encoded.length;