8274393: Suppress more warnings on non-serializable non-transient instance fields in security libs

Reviewed-by: weijun
This commit is contained in:
Joe Darcy 2021-09-30 17:39:05 +00:00
parent 8215b2eb61
commit 7326481143
12 changed files with 41 additions and 3 deletions

View File

@ -64,6 +64,8 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
private int iterCount;
private byte[] key;
@SuppressWarnings("serial") // Type of field is not Serializable;
// see writeReplace method
private Mac prf;
private static byte[] getPasswordBytes(char[] passwd) {

View File

@ -37,6 +37,7 @@ public class MissingResourceFailureException extends XMLSignatureException {
private static final long serialVersionUID = 1L;
/** Field uninitializedReference */
@SuppressWarnings("serial") // Type of field is not Serializable
private Reference uninitializedReference;
/**

View File

@ -61,6 +61,7 @@ public class URIReferenceException extends Exception {
* The {@code URIReference} that was being dereferenced
* when the exception was thrown, or {@code null} if not specified.
*/
@SuppressWarnings("serial") // Type of field is not Serializable
private URIReference uriReference;
/**

View File

@ -90,6 +90,7 @@ abstract class P11Key implements Key, Length {
// flags indicating whether the key is a token object, sensitive, extractable
final boolean tokenObject, sensitive, extractable;
@SuppressWarnings("serial") // Type of field is not Serializable
private final NativeKeyHolder keyIDHolder;
private static final boolean DISABLE_NATIVE_KEYS_EXTRACTION;
@ -723,6 +724,7 @@ abstract class P11Key implements Key, Length {
private static final long serialVersionUID = 5989753793316396637L;
private BigInteger y;
@SuppressWarnings("serial") // Type of field is not Serializable
private DSAParams params;
private byte[] encoded;
P11DSAPublicKey(Session session, long keyID, String algorithm,
@ -786,6 +788,7 @@ abstract class P11Key implements Key, Length {
private static final long serialVersionUID = 3119629997181999389L;
private BigInteger x;
@SuppressWarnings("serial") // Type of field is not Serializable
private DSAParams params;
private byte[] encoded;
P11DSAPrivateKey(Session session, long keyID, String algorithm,
@ -840,6 +843,7 @@ abstract class P11Key implements Key, Length {
private static final long serialVersionUID = -1698576167364928838L;
private BigInteger x;
@SuppressWarnings("serial") // Type of field is not Serializable
private DHParameterSpec params;
private byte[] encoded;
P11DHPrivateKey(Session session, long keyID, String algorithm,
@ -922,6 +926,7 @@ abstract class P11Key implements Key, Length {
static final long serialVersionUID = -598383872153843657L;
private BigInteger y;
@SuppressWarnings("serial") // Type of field is not Serializable
private DHParameterSpec params;
private byte[] encoded;
P11DHPublicKey(Session session, long keyID, String algorithm,
@ -1009,6 +1014,7 @@ abstract class P11Key implements Key, Length {
private static final long serialVersionUID = -7786054399510515515L;
private BigInteger s;
@SuppressWarnings("serial") // Type of field is not Serializable
private ECParameterSpec params;
private byte[] encoded;
P11ECPrivateKey(Session session, long keyID, String algorithm,
@ -1064,7 +1070,9 @@ abstract class P11Key implements Key, Length {
implements ECPublicKey {
private static final long serialVersionUID = -6371481375154806089L;
@SuppressWarnings("serial") // Type of field is not Serializable
private ECPoint w;
@SuppressWarnings("serial") // Type of field is not Serializable
private ECParameterSpec params;
private byte[] encoded;
P11ECPublicKey(Session session, long keyID, String algorithm,

View File

@ -66,25 +66,32 @@ public final class SunPKCS11 extends AuthProvider {
static final Debug debug = Debug.getInstance("sunpkcs11");
// the PKCS11 object through which we make the native calls
@SuppressWarnings("serial") // Type of field is not Serializable;
// see writeReplace
final PKCS11 p11;
// configuration information
@SuppressWarnings("serial") // Type of field is not Serializable
final Config config;
// id of the PKCS#11 slot we are using
final long slotID;
@SuppressWarnings("serial") // Type of field is not Serializable
private CallbackHandler pHandler;
@SuppressWarnings("serial") // Type of field is not Serializable
private final Object LOCK_HANDLER = new Object();
final boolean removable;
@SuppressWarnings("serial") // Type of field is not Serializable
final Secmod.Module nssModule;
final boolean nssUseSecmodTrust;
private volatile Token token;
@SuppressWarnings("serial") // Type of field is not Serializable
private TokenPoller poller;
static NativeResourceCleaner cleaner;

View File

@ -58,16 +58,21 @@ class Token implements Serializable {
final SunPKCS11 provider;
@SuppressWarnings("serial") // Type of field is not Serializable
final PKCS11 p11;
@SuppressWarnings("serial") // Type of field is not Serializable
final Config config;
@SuppressWarnings("serial") // Type of field is not Serializable
final CK_TOKEN_INFO tokenInfo;
// session manager to pool sessions
@SuppressWarnings("serial") // Type of field is not Serializable
final SessionManager sessionManager;
// template manager to customize the attributes used when creating objects
@SuppressWarnings("serial") // Type of field is not Serializable
private final TemplateManager templateManager;
// flag indicating whether we need to explicitly cancel operations
@ -76,16 +81,20 @@ class Token implements Serializable {
final boolean explicitCancel;
// translation cache for secret keys
@SuppressWarnings("serial") // Type of field is not Serializable
final KeyCache secretCache;
// translation cache for asymmetric keys (public and private)
@SuppressWarnings("serial") // Type of field is not Serializable
final KeyCache privateCache;
// cached instances of the various key factories, initialized on demand
@SuppressWarnings("serial") // Type of field is not Serializable
private volatile P11KeyFactory rsaFactory, dsaFactory, dhFactory, ecFactory;
// table which maps mechanisms to the corresponding cached
// MechanismInfo objects
@SuppressWarnings("serial") // Type of field is not Serializable
private final Map<Long, CK_MECHANISM_INFO> mechInfoMap;
// single SecureRandomSpi instance we use per token
@ -94,6 +103,7 @@ class Token implements Serializable {
// single KeyStoreSpi instance we use per provider
// initialized on demand
@SuppressWarnings("serial") // Type of field is not Serializable
private volatile P11KeyStore keyStore;
// whether this token is a removable token

View File

@ -66,6 +66,7 @@ public final class ECPrivateKeyImpl extends PKCS8Key implements ECPrivateKey {
private BigInteger s; // private value
private byte[] arrayS; // private value as a little-endian array
@SuppressWarnings("serial") // Type of field is not Serializable
private ECParameterSpec params;
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 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
@ -46,7 +46,10 @@ public final class ECPublicKeyImpl extends X509Key implements ECPublicKey {
private static final long serialVersionUID = -2462037275160462289L;
@SuppressWarnings("serial") // Type of field is not
// Serializable;see writeReplace
private ECPoint w;
@SuppressWarnings("serial") // Type of field is not Serializable
private ECParameterSpec params;
/**

View File

@ -39,6 +39,7 @@ public final class XDHPrivateKeyImpl extends PKCS8Key implements XECPrivateKey {
private static final long serialVersionUID = 1L;
@SuppressWarnings("serial") // Type of field is not Serializable
private final AlgorithmParameterSpec paramSpec;
private byte[] k;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 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
@ -43,6 +43,7 @@ public final class XDHPublicKeyImpl extends X509Key implements XECPublicKey {
private static final long serialVersionUID = 1L;
private final BigInteger u;
@SuppressWarnings("serial") // Type of field is not Serializable
private final NamedParameterSpec paramSpec;
XDHPublicKeyImpl(XECParameters params, BigInteger u)

View File

@ -41,6 +41,7 @@ public final class EdDSAPrivateKeyImpl
private static final long serialVersionUID = 1L;
@SuppressWarnings("serial") // Type of field is not Serializable
private final NamedParameterSpec paramSpec;
private byte[] h;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 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
@ -41,7 +41,9 @@ public final class EdDSAPublicKeyImpl extends X509Key implements EdECPublicKey {
private static final long serialVersionUID = 1L;
@SuppressWarnings("serial") // Type of field is not Serializable
private final EdECPoint point;
@SuppressWarnings("serial") // Type of field is not Serializable
private final NamedParameterSpec paramSpec;
public EdDSAPublicKeyImpl(EdDSAParameters params, EdECPoint point)