mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8315974: Make fields final in 'com.sun.crypto.provider' package
Reviewed-by: valeriep
This commit is contained in:
parent
8dd809642e
commit
4e77b3c378
31 changed files with 91 additions and 106 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2023, 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
|
||||
|
@ -44,7 +44,7 @@ import java.security.spec.InvalidParameterSpecException;
|
|||
*/
|
||||
public final class AESParameters extends AlgorithmParametersSpi {
|
||||
|
||||
private BlockCipherParamsCore core;
|
||||
private final BlockCipherParamsCore core;
|
||||
|
||||
public AESParameters() {
|
||||
core = new BlockCipherParamsCore(AESConstants.AES_BLOCK_SIZE, 4, 8);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2023, 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
|
||||
|
@ -46,10 +46,10 @@ import javax.crypto.spec.IvParameterSpec;
|
|||
*
|
||||
*/
|
||||
final class BlockCipherParamsCore {
|
||||
private int block_size = 0;
|
||||
private final int block_size;
|
||||
private byte[] iv = null;
|
||||
|
||||
private int[] moreSizes = null;
|
||||
private final int[] moreSizes;
|
||||
|
||||
BlockCipherParamsCore(int blksize, int... moreSizes) {
|
||||
block_size = blksize;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, 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
|
||||
|
@ -29,9 +29,7 @@ import java.security.*;
|
|||
import java.security.spec.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
import sun.security.util.*;
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.*;
|
||||
import javax.crypto.BadPaddingException;
|
||||
|
||||
/**
|
||||
|
@ -57,7 +55,7 @@ public final class BlowfishCipher extends CipherSpi {
|
|||
/*
|
||||
* internal CipherCore object which does the real work.
|
||||
*/
|
||||
private CipherCore core = null;
|
||||
private final CipherCore core;
|
||||
|
||||
/**
|
||||
* Creates an instance of Blowfish cipher with default ECB mode and
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, 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
|
||||
|
@ -44,7 +44,7 @@ import java.security.spec.InvalidParameterSpecException;
|
|||
|
||||
public final class BlowfishParameters extends AlgorithmParametersSpi {
|
||||
|
||||
private BlockCipherParamsCore core;
|
||||
private final BlockCipherParamsCore core;
|
||||
|
||||
public BlowfishParameters() {
|
||||
core = new BlockCipherParamsCore
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, 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
|
||||
|
@ -27,7 +27,6 @@ package com.sun.crypto.provider;
|
|||
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.ProviderException;
|
||||
import java.util.Objects;
|
||||
|
||||
import jdk.internal.vm.annotation.IntrinsicCandidate;
|
||||
import sun.security.util.ArrayUtil;
|
||||
|
@ -55,7 +54,7 @@ class CipherBlockChaining extends FeedbackCipher {
|
|||
/*
|
||||
* output buffer
|
||||
*/
|
||||
private byte[] k;
|
||||
private final byte[] k;
|
||||
|
||||
// variables for save/restore calls
|
||||
private byte[] rSave = null;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2023, 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
|
||||
|
@ -57,12 +57,12 @@ final class CipherCore {
|
|||
/*
|
||||
* internal buffer
|
||||
*/
|
||||
private byte[] buffer = null;
|
||||
private final byte[] buffer;
|
||||
|
||||
/*
|
||||
* block size of cipher in bytes
|
||||
*/
|
||||
private int blockSize = 0;
|
||||
private final int blockSize;
|
||||
|
||||
/*
|
||||
* unit size (number of input bytes that can be processed at a time)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, 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
|
||||
|
@ -57,7 +57,7 @@ final class CipherFeedback extends FeedbackCipher {
|
|||
* number of bytes for each stream unit, defaults to the blocksize
|
||||
* of the embedded cipher
|
||||
*/
|
||||
private int numBytes;
|
||||
private final int numBytes;
|
||||
|
||||
// variables for save/restore calls
|
||||
private byte[] registerSave = null;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, 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
|
||||
|
@ -29,7 +29,6 @@ import java.security.*;
|
|||
import java.security.spec.*;
|
||||
import java.util.Arrays;
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.*;
|
||||
import javax.crypto.BadPaddingException;
|
||||
|
||||
/**
|
||||
|
@ -52,7 +51,7 @@ public final class DESCipher extends CipherSpi {
|
|||
/*
|
||||
* internal CipherCore object which does the real work.
|
||||
*/
|
||||
private CipherCore core = null;
|
||||
private final CipherCore core;
|
||||
|
||||
/**
|
||||
* Creates an instance of DES cipher with default ECB mode and
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, 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
|
||||
|
@ -44,7 +44,7 @@ import java.security.spec.InvalidParameterSpecException;
|
|||
|
||||
public final class DESParameters extends AlgorithmParametersSpi {
|
||||
|
||||
private BlockCipherParamsCore core;
|
||||
private final BlockCipherParamsCore core;
|
||||
|
||||
public DESParameters() {
|
||||
core = new BlockCipherParamsCore(DESConstants.DES_BLOCK_SIZE);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, 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
|
||||
|
@ -29,7 +29,6 @@ import java.security.*;
|
|||
import java.security.spec.*;
|
||||
import java.util.Arrays;
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.*;
|
||||
|
||||
/**
|
||||
* This class implements the DESede algorithm (DES-EDE, tripleDES) in
|
||||
|
@ -50,7 +49,7 @@ public sealed class DESedeCipher extends CipherSpi
|
|||
/*
|
||||
* internal CipherCore object which does the real work.
|
||||
*/
|
||||
private CipherCore core = null;
|
||||
private final CipherCore core;
|
||||
|
||||
/**
|
||||
* Creates an instance of DESede cipher with default ECB mode and
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, 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
|
||||
|
@ -48,7 +48,8 @@ final class DESedeCrypt extends DESCrypt implements DESConstants {
|
|||
private byte[] key1 = null;
|
||||
private byte[] key2 = null;
|
||||
private byte[] key3 = null;
|
||||
private byte[] buf1, buf2;
|
||||
private final byte[] buf1;
|
||||
private final byte[] buf2;
|
||||
|
||||
/*
|
||||
* constructor
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, 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
|
||||
|
@ -43,7 +43,7 @@ import java.security.spec.InvalidParameterSpecException;
|
|||
*/
|
||||
public final class DESedeParameters extends AlgorithmParametersSpi {
|
||||
|
||||
private BlockCipherParamsCore core;
|
||||
private final BlockCipherParamsCore core;
|
||||
|
||||
public DESedeParameters() {
|
||||
core = new BlockCipherParamsCore(DESConstants.DES_BLOCK_SIZE);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2023, 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
|
||||
|
@ -57,7 +57,7 @@ public final class DESedeWrapCipher extends CipherSpi {
|
|||
/*
|
||||
* internal cipher object which does the real work.
|
||||
*/
|
||||
private FeedbackCipher cipher;
|
||||
private final FeedbackCipher cipher;
|
||||
|
||||
/*
|
||||
* iv for (re-)initializing the internal cipher object.
|
||||
|
|
|
@ -53,7 +53,7 @@ final class DHPrivateKey implements PrivateKey,
|
|||
private static final BigInteger PKCS8_VERSION = BigInteger.ZERO;
|
||||
|
||||
// the private key
|
||||
private BigInteger x;
|
||||
private final BigInteger x;
|
||||
|
||||
// the key bytes, without the algorithm information
|
||||
private byte[] key;
|
||||
|
@ -68,7 +68,7 @@ final class DHPrivateKey implements PrivateKey,
|
|||
private final BigInteger g;
|
||||
|
||||
// the private-value length (optional)
|
||||
private int l;
|
||||
private final int l;
|
||||
|
||||
/**
|
||||
* Make a DH private key out of a private value <code>x</code>, a prime
|
||||
|
@ -161,6 +161,8 @@ final class DHPrivateKey implements PrivateKey,
|
|||
// Private-value length is OPTIONAL
|
||||
if (params.data.available() != 0) {
|
||||
this.l = params.data.getInteger();
|
||||
} else {
|
||||
this.l = 0;
|
||||
}
|
||||
if (params.data.available() != 0) {
|
||||
throw new InvalidKeyException("Extra parameter data");
|
||||
|
@ -170,7 +172,9 @@ final class DHPrivateKey implements PrivateKey,
|
|||
// privateKey
|
||||
//
|
||||
this.key = val.data.getOctetString();
|
||||
parseKeyBits();
|
||||
|
||||
DerInputStream in = new DerInputStream(this.key);
|
||||
this.x = in.getBigInteger();
|
||||
|
||||
this.encodedKey = encodedKey.clone();
|
||||
} catch (IOException | NumberFormatException e) {
|
||||
|
@ -271,16 +275,6 @@ final class DHPrivateKey implements PrivateKey,
|
|||
}
|
||||
}
|
||||
|
||||
private void parseKeyBits() throws InvalidKeyException {
|
||||
try {
|
||||
DerInputStream in = new DerInputStream(this.key);
|
||||
this.x = in.getBigInteger();
|
||||
} catch (IOException e) {
|
||||
throw new InvalidKeyException(
|
||||
"Error parsing key encoding: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a hash code value for the object.
|
||||
* Objects that are equal will also have the same hashcode.
|
||||
|
|
|
@ -49,7 +49,7 @@ javax.crypto.interfaces.DHPublicKey, Serializable {
|
|||
private static final long serialVersionUID = 7647557958927458271L;
|
||||
|
||||
// the public key
|
||||
private BigInteger y;
|
||||
private final BigInteger y;
|
||||
|
||||
// the key bytes, without the algorithm information
|
||||
private byte[] key;
|
||||
|
@ -64,10 +64,10 @@ javax.crypto.interfaces.DHPublicKey, Serializable {
|
|||
private final BigInteger g;
|
||||
|
||||
// the private-value length (optional)
|
||||
private int l;
|
||||
private final int l;
|
||||
|
||||
// Note: this OID is used by DHPrivateKey as well.
|
||||
static ObjectIdentifier DH_OID =
|
||||
static final ObjectIdentifier DH_OID =
|
||||
ObjectIdentifier.of(KnownOIDs.DiffieHellman);
|
||||
|
||||
/**
|
||||
|
@ -153,6 +153,8 @@ javax.crypto.interfaces.DHPublicKey, Serializable {
|
|||
// Private-value length is OPTIONAL
|
||||
if (params.data.available() != 0) {
|
||||
this.l = params.data.getInteger();
|
||||
} else {
|
||||
this.l = 0;
|
||||
}
|
||||
if (params.data.available() != 0) {
|
||||
throw new InvalidKeyException("Extra parameter data");
|
||||
|
@ -162,7 +164,10 @@ javax.crypto.interfaces.DHPublicKey, Serializable {
|
|||
* Parse the key
|
||||
*/
|
||||
this.key = derKeyVal.data.getBitString();
|
||||
parseKeyBits();
|
||||
|
||||
DerInputStream in = new DerInputStream(this.key);
|
||||
this.y = in.getBigInteger();
|
||||
|
||||
if (derKeyVal.data.available() != 0) {
|
||||
throw new InvalidKeyException("Excess key data");
|
||||
}
|
||||
|
@ -263,16 +268,6 @@ javax.crypto.interfaces.DHPublicKey, Serializable {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
private void parseKeyBits() throws InvalidKeyException {
|
||||
try {
|
||||
DerInputStream in = new DerInputStream(this.key);
|
||||
this.y = in.getBigInteger();
|
||||
} catch (IOException e) {
|
||||
throw new InvalidKeyException(
|
||||
"Error parsing key encoding: " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a hash code value for the object.
|
||||
* Objects that are equal will also have the same hashcode.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, 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
|
||||
|
@ -44,10 +44,10 @@ import sun.security.util.*;
|
|||
final class EncryptedPrivateKeyInfo {
|
||||
|
||||
// the "encryptionAlgorithm" field
|
||||
private AlgorithmId algid;
|
||||
private final AlgorithmId algid;
|
||||
|
||||
// the "encryptedData" field
|
||||
private byte[] encryptedData;
|
||||
private final byte[] encryptedData;
|
||||
|
||||
// the ASN.1 encoded contents of this class
|
||||
private byte[] encoded;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2023, 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
|
||||
|
@ -124,7 +124,7 @@ final class GHASH implements Cloneable, GCM {
|
|||
|
||||
// hashtable subkeyHtbl holds 2*9 powers of subkeyH computed using
|
||||
// carry-less multiplication
|
||||
private long[] subkeyHtbl;
|
||||
private final long[] subkeyHtbl;
|
||||
|
||||
// buffer for storing hash
|
||||
private final long[] state;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2023, 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
|
||||
|
@ -74,8 +74,8 @@ import jdk.internal.vm.annotation.IntrinsicCandidate;
|
|||
* @since 1.8
|
||||
*/
|
||||
abstract class GaloisCounterMode extends CipherSpi {
|
||||
static int DEFAULT_IV_LEN = 12; // in bytes
|
||||
static int DEFAULT_TAG_LEN = 16; // in bytes
|
||||
private static final int DEFAULT_IV_LEN = 12; // in bytes
|
||||
private static final int DEFAULT_TAG_LEN = 16; // in bytes
|
||||
// In NIST SP 800-38D, GCM input size is limited to be no longer
|
||||
// than (2^36 - 32) bytes. Otherwise, the counter will wrap
|
||||
// around and lead to a leak of plaintext.
|
||||
|
@ -98,7 +98,7 @@ abstract class GaloisCounterMode extends CipherSpi {
|
|||
|
||||
private boolean initialized = false;
|
||||
|
||||
SymmetricCipher blockCipher;
|
||||
final SymmetricCipher blockCipher;
|
||||
// Engine instance for encryption or decryption
|
||||
private GCMEngine engine;
|
||||
private boolean encryption = true;
|
||||
|
@ -106,7 +106,7 @@ abstract class GaloisCounterMode extends CipherSpi {
|
|||
// Default value is 128bits, this is in bytes.
|
||||
int tagLenBytes = DEFAULT_TAG_LEN;
|
||||
// Key size if the value is passed, in bytes.
|
||||
int keySize;
|
||||
private final int keySize;
|
||||
// Prevent reuse of iv or key
|
||||
boolean reInit = false;
|
||||
byte[] lastKey = EMPTY_BUF;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, 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
|
||||
|
@ -38,7 +38,7 @@ import javax.crypto.ShortBufferException;
|
|||
*/
|
||||
final class ISO10126Padding implements Padding {
|
||||
|
||||
private int blockSize;
|
||||
private final int blockSize;
|
||||
|
||||
ISO10126Padding(int blockSize) {
|
||||
this.blockSize = blockSize;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, 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
|
||||
|
@ -99,7 +99,7 @@ public final class JceKeyStore extends KeyStoreSpi {
|
|||
* Private keys and certificates are stored in a hashtable.
|
||||
* Hash entries are keyed by alias names.
|
||||
*/
|
||||
private Hashtable<String, Object> entries = new Hashtable<String, Object>();
|
||||
private final Hashtable<String, Object> entries = new Hashtable<>();
|
||||
|
||||
/**
|
||||
* Returns the key associated with the given alias, using the given
|
||||
|
|
|
@ -78,7 +78,7 @@ final class KeyProtector {
|
|||
|
||||
// the password used for protecting/recovering keys passed through this
|
||||
// key protector
|
||||
private char[] password;
|
||||
private final char[] password;
|
||||
|
||||
/**
|
||||
* {@systemProperty jdk.jceks.iterationCount} property indicating the
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, 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
|
||||
|
@ -56,9 +56,9 @@ public final class OAEPParameters extends AlgorithmParametersSpi {
|
|||
private String mdName;
|
||||
private MGF1ParameterSpec mgfSpec;
|
||||
private byte[] p;
|
||||
private static ObjectIdentifier OID_MGF1 =
|
||||
private static final ObjectIdentifier OID_MGF1 =
|
||||
ObjectIdentifier.of(KnownOIDs.MGF1);
|
||||
private static ObjectIdentifier OID_PSpecified =
|
||||
private static final ObjectIdentifier OID_PSpecified =
|
||||
ObjectIdentifier.of(KnownOIDs.PSpecified);
|
||||
|
||||
public OAEPParameters() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, 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
|
||||
|
@ -45,18 +45,18 @@ final class OutputFeedback extends FeedbackCipher {
|
|||
/*
|
||||
* output buffer
|
||||
*/
|
||||
private byte[] k = null;
|
||||
private final byte[] k;
|
||||
|
||||
/*
|
||||
* register buffer
|
||||
*/
|
||||
private byte[] register = null;
|
||||
private final byte[] register;
|
||||
|
||||
/*
|
||||
* number of bytes for each stream unit, defaults to the blocksize
|
||||
* of the embedded cipher
|
||||
*/
|
||||
private int numBytes;
|
||||
private final int numBytes;
|
||||
|
||||
// variables for save/restore calls
|
||||
private byte[] registerSave = null;
|
||||
|
|
|
@ -46,7 +46,7 @@ import java.util.Set;
|
|||
*/
|
||||
abstract class PBEKeyFactory extends SecretKeyFactorySpi {
|
||||
|
||||
private String type;
|
||||
private final String type;
|
||||
private static final HashSet<String> validTypes;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2023, 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
|
||||
|
@ -43,10 +43,9 @@ import javax.crypto.spec.*;
|
|||
final class PBES1Core {
|
||||
|
||||
// the encapsulated DES cipher
|
||||
private CipherCore cipher;
|
||||
private MessageDigest md;
|
||||
private int blkSize;
|
||||
private String algo = null;
|
||||
private final CipherCore cipher;
|
||||
private final MessageDigest md;
|
||||
private final String algo;
|
||||
private byte[] salt = null;
|
||||
private int iCount = 10;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2023, 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
|
||||
|
@ -92,15 +92,15 @@ import sun.security.util.*;
|
|||
*/
|
||||
abstract class PBES2Parameters extends AlgorithmParametersSpi {
|
||||
|
||||
private static ObjectIdentifier pkcs5PBKDF2_OID =
|
||||
private static final ObjectIdentifier pkcs5PBKDF2_OID =
|
||||
ObjectIdentifier.of(KnownOIDs.PBKDF2WithHmacSHA1);
|
||||
private static ObjectIdentifier pkcs5PBES2_OID =
|
||||
private static final ObjectIdentifier pkcs5PBES2_OID =
|
||||
ObjectIdentifier.of(KnownOIDs.PBES2);
|
||||
private static ObjectIdentifier aes128CBC_OID =
|
||||
private static final ObjectIdentifier aes128CBC_OID =
|
||||
ObjectIdentifier.of(KnownOIDs.AES_128$CBC$NoPadding);
|
||||
private static ObjectIdentifier aes192CBC_OID =
|
||||
private static final ObjectIdentifier aes192CBC_OID =
|
||||
ObjectIdentifier.of(KnownOIDs.AES_192$CBC$NoPadding);
|
||||
private static ObjectIdentifier aes256CBC_OID =
|
||||
private static final ObjectIdentifier aes256CBC_OID =
|
||||
ObjectIdentifier.of(KnownOIDs.AES_256$CBC$NoPadding);
|
||||
|
||||
// the PBES2 algorithm name
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, 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
|
||||
|
@ -43,7 +43,7 @@ import javax.crypto.*;
|
|||
public final class PBEWithMD5AndDESCipher extends CipherSpi {
|
||||
|
||||
// the encapsulated DES cipher
|
||||
private PBES1Core core;
|
||||
private final PBES1Core core;
|
||||
|
||||
/**
|
||||
* Creates an instance of this cipher, and initializes its mode (CBC) and
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, 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
|
||||
|
@ -53,7 +53,7 @@ import javax.crypto.*;
|
|||
*/
|
||||
public final class PBEWithMD5AndTripleDESCipher extends CipherSpi {
|
||||
|
||||
private PBES1Core core;
|
||||
private final PBES1Core core;
|
||||
|
||||
/**
|
||||
* Creates an instance of this cipher, and initializes its mode (CBC) and
|
||||
|
|
|
@ -63,7 +63,7 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
|
|||
private final char[] passwd;
|
||||
private final byte[] salt;
|
||||
private final int iterCount;
|
||||
private byte[] key;
|
||||
private final byte[] key;
|
||||
|
||||
// The following fields are not Serializable. See writeReplace method.
|
||||
private final transient Mac prf;
|
||||
|
@ -93,6 +93,7 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
|
|||
// Convert the password from char[] to byte[]
|
||||
byte[] passwdBytes = getPasswordBytes(this.passwd);
|
||||
|
||||
byte[] key = null;
|
||||
try {
|
||||
this.salt = keySpec.getSalt();
|
||||
if (salt == null) {
|
||||
|
@ -111,7 +112,7 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
|
|||
throw new InvalidKeySpecException("Key length is negative");
|
||||
}
|
||||
this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
|
||||
this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
|
||||
key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
// not gonna happen; re-throw just in case
|
||||
throw new InvalidKeySpecException(nsae);
|
||||
|
@ -122,7 +123,7 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
|
|||
}
|
||||
}
|
||||
// Use the cleaner to zero the key when no longer referenced
|
||||
final byte[] k = this.key;
|
||||
final byte[] k = this.key = key;
|
||||
final char[] p = this.passwd;
|
||||
cleaner = CleanerFactory.cleaner().register(this,
|
||||
() -> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, 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
|
||||
|
@ -38,7 +38,7 @@ import java.util.Arrays;
|
|||
*/
|
||||
final class PKCS5Padding implements Padding {
|
||||
|
||||
private int blockSize;
|
||||
private final int blockSize;
|
||||
|
||||
PKCS5Padding(int blockSize) {
|
||||
this.blockSize = blockSize;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2023, 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
|
||||
|
@ -53,10 +53,10 @@ final class PrivateKeyInfo {
|
|||
private static final BigInteger VERSION = BigInteger.ZERO;
|
||||
|
||||
// the private-key algorithm
|
||||
private AlgorithmId algid;
|
||||
private final AlgorithmId algid;
|
||||
|
||||
// the private-key value
|
||||
private byte[] privkey;
|
||||
private final byte[] privkey;
|
||||
|
||||
/**
|
||||
* Constructs a PKCS#8 PrivateKeyInfo from its ASN.1 encoding.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue