8170876: NPE in JCE engine classes with java.security.debug=provider
Reviewed-by: mullan
This commit is contained in:
parent
c5685c8143
commit
85d15e6128
@ -824,10 +824,14 @@ public class KeyStore {
|
|||||||
|
|
||||||
if (!skipDebug && pdebug != null) {
|
if (!skipDebug && pdebug != null) {
|
||||||
pdebug.println("KeyStore." + type.toUpperCase() + " type from: " +
|
pdebug.println("KeyStore." + type.toUpperCase() + " type from: " +
|
||||||
this.provider.getName());
|
getProviderName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getProviderName() {
|
||||||
|
return (provider == null) ? "(no provider)" : provider.getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a keystore object of the specified type.
|
* Returns a keystore object of the specified type.
|
||||||
*
|
*
|
||||||
|
@ -430,13 +430,17 @@ public abstract class MessageDigest extends MessageDigestSpi {
|
|||||||
return digest();
|
return digest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getProviderName() {
|
||||||
|
return (provider == null) ? "(no provider)" : provider.getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation of this message digest object.
|
* Returns a string representation of this message digest object.
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
PrintStream p = new PrintStream(baos);
|
PrintStream p = new PrintStream(baos);
|
||||||
p.print(algorithm+" Message Digest from "+provider.getName()+", ");
|
p.print(algorithm+" Message Digest from "+getProviderName()+", ");
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case INITIAL:
|
case INITIAL:
|
||||||
p.print("<initialized>");
|
p.print("<initialized>");
|
||||||
|
@ -310,10 +310,14 @@ public class SecureRandom extends java.util.Random {
|
|||||||
|
|
||||||
if (!skipDebug && pdebug != null) {
|
if (!skipDebug && pdebug != null) {
|
||||||
pdebug.println("SecureRandom." + algorithm +
|
pdebug.println("SecureRandom." + algorithm +
|
||||||
" algorithm from: " + this.provider.getName());
|
" algorithm from: " + getProviderName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getProviderName() {
|
||||||
|
return (provider == null) ? "(no provider)" : provider.getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@code SecureRandom} object that implements the specified
|
* Returns a {@code SecureRandom} object that implements the specified
|
||||||
* Random Number Generator (RNG) algorithm.
|
* Random Number Generator (RNG) algorithm.
|
||||||
|
@ -611,6 +611,10 @@ public class Cipher {
|
|||||||
return getInstance(transformation, p);
|
return getInstance(transformation, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getProviderName() {
|
||||||
|
return (provider == null) ? "(no provider)" : provider.getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@code Cipher} object that implements the specified
|
* Returns a {@code Cipher} object that implements the specified
|
||||||
* transformation.
|
* transformation.
|
||||||
@ -1278,7 +1282,7 @@ public class Cipher {
|
|||||||
if (!skipDebug && pdebug != null) {
|
if (!skipDebug && pdebug != null) {
|
||||||
pdebug.println("Cipher." + transformation + " " +
|
pdebug.println("Cipher." + transformation + " " +
|
||||||
getOpmodeString(opmode) + " algorithm from: " +
|
getOpmodeString(opmode) + " algorithm from: " +
|
||||||
this.provider.getName());
|
getProviderName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1421,7 +1425,7 @@ public class Cipher {
|
|||||||
if (!skipDebug && pdebug != null) {
|
if (!skipDebug && pdebug != null) {
|
||||||
pdebug.println("Cipher." + transformation + " " +
|
pdebug.println("Cipher." + transformation + " " +
|
||||||
getOpmodeString(opmode) + " algorithm from: " +
|
getOpmodeString(opmode) + " algorithm from: " +
|
||||||
this.provider.getName());
|
getProviderName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1564,7 +1568,7 @@ public class Cipher {
|
|||||||
if (!skipDebug && pdebug != null) {
|
if (!skipDebug && pdebug != null) {
|
||||||
pdebug.println("Cipher." + transformation + " " +
|
pdebug.println("Cipher." + transformation + " " +
|
||||||
getOpmodeString(opmode) + " algorithm from: " +
|
getOpmodeString(opmode) + " algorithm from: " +
|
||||||
this.provider.getName());
|
getProviderName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1754,7 +1758,7 @@ public class Cipher {
|
|||||||
if (!skipDebug && pdebug != null) {
|
if (!skipDebug && pdebug != null) {
|
||||||
pdebug.println("Cipher." + transformation + " " +
|
pdebug.println("Cipher." + transformation + " " +
|
||||||
getOpmodeString(opmode) + " algorithm from: " +
|
getOpmodeString(opmode) + " algorithm from: " +
|
||||||
this.provider.getName());
|
getProviderName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ public class KeyAgreement {
|
|||||||
|
|
||||||
if (!skipDebug && pdebug != null) {
|
if (!skipDebug && pdebug != null) {
|
||||||
pdebug.println("KeyAgreement." + algorithm + " algorithm from: " +
|
pdebug.println("KeyAgreement." + algorithm + " algorithm from: " +
|
||||||
this.provider.getName());
|
getProviderName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,6 +517,10 @@ public class KeyAgreement {
|
|||||||
init(key, params, JceSecurity.RANDOM);
|
init(key, params, JceSecurity.RANDOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getProviderName() {
|
||||||
|
return (provider == null) ? "(no provider)" : provider.getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this key agreement with the given key, set of
|
* Initializes this key agreement with the given key, set of
|
||||||
* algorithm parameters, and source of randomness.
|
* algorithm parameters, and source of randomness.
|
||||||
@ -545,7 +549,7 @@ public class KeyAgreement {
|
|||||||
|
|
||||||
if (!skipDebug && pdebug != null) {
|
if (!skipDebug && pdebug != null) {
|
||||||
pdebug.println("KeyAgreement." + algorithm + " algorithm from: " +
|
pdebug.println("KeyAgreement." + algorithm + " algorithm from: " +
|
||||||
this.provider.getName());
|
getProviderName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ public class KeyGenerator {
|
|||||||
|
|
||||||
if (!skipDebug && pdebug != null) {
|
if (!skipDebug && pdebug != null) {
|
||||||
pdebug.println("KeyGenerator." + algorithm + " algorithm from: " +
|
pdebug.println("KeyGenerator." + algorithm + " algorithm from: " +
|
||||||
this.provider.getName());
|
getProviderName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,10 +172,14 @@ public class KeyGenerator {
|
|||||||
|
|
||||||
if (!skipDebug && pdebug != null) {
|
if (!skipDebug && pdebug != null) {
|
||||||
pdebug.println("KeyGenerator." + algorithm + " algorithm from: " +
|
pdebug.println("KeyGenerator." + algorithm + " algorithm from: " +
|
||||||
this.provider.getName());
|
getProviderName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getProviderName() {
|
||||||
|
return (provider == null) ? "(no provider)" : provider.getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the algorithm name of this {@code KeyGenerator} object.
|
* Returns the algorithm name of this {@code KeyGenerator} object.
|
||||||
*
|
*
|
||||||
|
@ -415,6 +415,10 @@ public class Mac implements Cloneable {
|
|||||||
return spi.engineGetMacLength();
|
return spi.engineGetMacLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getProviderName() {
|
||||||
|
return (provider == null) ? "(no provider)" : provider.getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this {@code Mac} object with the given key.
|
* Initializes this {@code Mac} object with the given key.
|
||||||
*
|
*
|
||||||
@ -437,7 +441,7 @@ public class Mac implements Cloneable {
|
|||||||
|
|
||||||
if (!skipDebug && pdebug != null) {
|
if (!skipDebug && pdebug != null) {
|
||||||
pdebug.println("Mac." + algorithm + " algorithm from: " +
|
pdebug.println("Mac." + algorithm + " algorithm from: " +
|
||||||
this.provider.getName());
|
getProviderName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,7 +468,7 @@ public class Mac implements Cloneable {
|
|||||||
|
|
||||||
if (!skipDebug && pdebug != null) {
|
if (!skipDebug && pdebug != null) {
|
||||||
pdebug.println("Mac." + algorithm + " algorithm from: " +
|
pdebug.println("Mac." + algorithm + " algorithm from: " +
|
||||||
this.provider.getName());
|
getProviderName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8165751
|
* @bug 8165751
|
||||||
* @summary Verify that that a subclass of Signature that does not contain a
|
* @summary Verify that that a subclass of Signature that does not contain a
|
||||||
* provider can be used verify.
|
* provider can be used to verify.
|
||||||
* @run main/othervm -Djava.security.debug=provider NoProvider
|
* @run main/othervm -Djava.security.debug=provider NoProvider
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,10 +23,12 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4937853
|
* @bug 4937853 8170876
|
||||||
* @summary Make sure normal calls of NullCipher does not throw NPE.
|
* @summary Make sure normal calls of NullCipher does not throw NPE.
|
||||||
* @author Valerie Peng
|
* @author Valerie Peng
|
||||||
* @key randomness
|
* @key randomness
|
||||||
|
* @run main TestNPE
|
||||||
|
* @run main/othervm -Djava.security.debug=provider TestNPE
|
||||||
*/
|
*/
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.security.AlgorithmParameters;
|
import java.security.AlgorithmParameters;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user