Skip to content

Commit

Permalink
Merge master jdk-17.0.11+9 into openj9-staging
Browse files Browse the repository at this point in the history
Signed-off-by: J9 Build <j9build@ca.ibm.com>
  • Loading branch information
j9build committed Apr 17, 2024
2 parents 96769c3 + b08622e commit 96fca37
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 51 deletions.
2 changes: 1 addition & 1 deletion make/conf/version-numbers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ DEFAULT_VERSION_CLASSFILE_MINOR=0
DEFAULT_VERSION_DOCS_API_SINCE=11
DEFAULT_ACCEPTABLE_BOOT_VERSIONS="16 17"
DEFAULT_JDK_SOURCE_TARGET_VERSION=17
DEFAULT_PROMOTED_VERSION_PRE=ea
DEFAULT_PROMOTED_VERSION_PRE=
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,6 @@ public AlgorithmParameterSpec getParams() {
return keyParams;
}

// return a string representation of this key for debugging
@Override
public String toString() {
return "SunRsaSign " + type.keyAlgo + " private CRT key, "
+ n.bitLength() + " bits" + "\n params: " + keyParams
+ "\n modulus: " + n + "\n private exponent: " + d;
}

// utility method for parsing DER encoding of RSA private keys in PKCS#1
// format as defined in RFC 8017 Appendix A.1.2, i.e. SEQ of version, n,
// e, d, p, q, pe, qe, and coeff, and return the parsed components.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,6 @@ public AlgorithmParameterSpec getParams() {
return keyParams;
}

// return a string representation of this key for debugging
@Override
public String toString() {
return "Sun " + type.keyAlgo + " private key, " + n.bitLength()
+ " bits" + "\n params: " + keyParams + "\n modulus: " + n
+ "\n private exponent: " + d;
}

/**
* Restores the state of this object from the stream.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,10 @@ public boolean equals(Object obj) {
return false;
}
if (secure && destination != null) {
if (destination.getHostName() != null) {
if (!destination.getHostName().equalsIgnoreCase(
other.destination.getHostName())) {
return false;
}
} else {
if (other.destination.getHostName() != null)
return false;
String hostString = destination.getHostString();
if (hostString == null || !hostString.equalsIgnoreCase(
other.destination.getHostString())) {
return false;
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ protected void finalize() throws Throwable {

protected final String algorithm;

protected CKey(String algorithm, NativeHandles handles, int keyLength) {
private final boolean isPublic;

protected CKey(String algorithm, NativeHandles handles, int keyLength,
boolean isPublic) {
this.algorithm = algorithm;
this.handles = handles;
this.keyLength = keyLength;
this.isPublic = isPublic;
}

// Native method to cleanup the key handle.
Expand All @@ -101,6 +105,18 @@ public String getAlgorithm() {
return algorithm;
}

public String toString() {
String typeStr;
if (handles.hCryptKey != 0) {
typeStr = getKeyType(handles.hCryptKey) + ", container=" +
getContainerName(handles.hCryptProv);
} else {
typeStr = "CNG";
}
return algorithm + " " + (isPublic ? "PublicKey" : "PrivateKey") +
" [size=" + keyLength + " bits, type=" + typeStr + "]";
}

protected native static String getContainerName(long hCryptProv);

protected native static String getKeyType(long hCryptKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CPrivateKey extends CKey implements PrivateKey {
private static final long serialVersionUID = 8113152807912338063L;

private CPrivateKey(String alg, NativeHandles handles, int keyLength) {
super(alg, handles, keyLength);
super(alg, handles, keyLength, false);
}

// Called by native code inside security.cpp
Expand All @@ -65,16 +65,6 @@ public byte[] getEncoded() {
return null;
}

public String toString() {
if (handles.hCryptKey != 0) {
return algorithm + "PrivateKey [size=" + keyLength + " bits, type=" +
getKeyType(handles.hCryptKey) + ", container=" +
getContainerName(handles.hCryptProv) + "]";
} else {
return algorithm + "PrivateKey [size=" + keyLength + " bits, type=CNG]";
}
}

// This class is not serializable
@java.io.Serial
private void writeObject(java.io.ObjectOutputStream out)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ public ECParameterSpec getParams() {
}

public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(algorithm).append("PublicKey [size=").append(keyLength)
.append("]\n ECPoint: ").append(getW())
StringBuffer sb = new StringBuffer(super.toString());
sb.append("\n ECPoint: ").append(getW())
.append("\n params: ").append(getParams());
return sb.toString();
}
Expand All @@ -134,16 +133,8 @@ public static class CRSAPublicKey extends CPublicKey implements RSAPublicKey {
}

public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(algorithm).append("PublicKey [size=").append(keyLength)
.append(" bits, type=");
if (handles.hCryptKey != 0) {
sb.append(getKeyType(handles.hCryptKey))
.append(", container=").append(getContainerName(handles.hCryptProv));
} else {
sb.append("CNG");
}
sb.append("]\n modulus: ").append(getModulus())
StringBuffer sb = new StringBuffer(super.toString());
sb.append("\n modulus: ").append(getModulus())
.append("\n public exponent: ").append(getPublicExponent());
return sb.toString();
}
Expand Down Expand Up @@ -214,7 +205,7 @@ public static CPublicKey of(

protected CPublicKey(
String alg, NativeHandles handles, int keyLength) {
super(alg, handles, keyLength);
super(alg, handles, keyLength, true);
}

@Override
Expand Down

0 comments on commit 96fca37

Please sign in to comment.