From 31da5cb6420f9df42c5b9813fab19e778863d2b8 Mon Sep 17 00:00:00 2001 From: David Hook Date: Sat, 3 Feb 2024 16:56:01 +1100 Subject: [PATCH] error prone cleanups. added mail and jmail back into the build. added prov:test11, prov:test17, prov:test21 to base test stanza. --- bc-build.properties | 2 +- build.gradle | 2 +- .../crypto/engines/Grain128Engine.java | 2 +- .../generators/Argon2BytesGenerator.java | 2 +- .../crypto/test/Blake2bDigestTest.java | 24 +++++----------- .../pqc/crypto/test/XMSSMTPrivateKeyTest.java | 6 ++-- jmail/build.gradle | 25 +++++++---------- mail/build.gradle | 27 ++++++++---------- .../jce/provider/test/CertTest.java | 17 ++++++----- .../provider/test/X509StreamParserTest.java | 28 +++++++++---------- .../jce/provider/test/nist/PKITSTest.java | 8 +++--- settings.gradle | 4 +-- .../jsse/provider/test/BCJSSEClientTest.java | 3 +- .../test/CipherSuitesEngineTestCase.java | 8 +++--- .../bouncycastle/tls/test/DTLSClientTest.java | 3 +- .../tls/test/PSKTls13ClientTest.java | 3 +- .../tls/test/PSKTlsClientTest.java | 2 +- .../tls/test/TlsClientRawKeysTest.java | 3 +- .../bouncycastle/tls/test/TlsClientTest.java | 3 +- 19 files changed, 77 insertions(+), 95 deletions(-) diff --git a/bc-build.properties b/bc-build.properties index b90eb3523d..5113ef6b97 100644 --- a/bc-build.properties +++ b/bc-build.properties @@ -3,7 +3,7 @@ # intended to hold user-specific settings that are *not* committed to # the repository. -release.suffix: 178b02 +release.suffix: 178b04 release.name: 1.77.99 release.version: 1.77.99 release.debug: true diff --git a/build.gradle b/build.gradle index d82a20248e..5c25fe35e2 100644 --- a/build.gradle +++ b/build.gradle @@ -250,4 +250,4 @@ subprojects { } -test.dependsOn([':core:test', ':prov:test', ':pkix:test', 'pg:test', ':tls:test']) +test.dependsOn([':core:test', ':prov:test', ':prov:test11', ':prov:test17', ':prov:test21', ':pkix:test', 'pg:test', ':tls:test', 'mls:test', 'mail:test', 'jmail:test']) diff --git a/core/src/main/java/org/bouncycastle/crypto/engines/Grain128Engine.java b/core/src/main/java/org/bouncycastle/crypto/engines/Grain128Engine.java index ddac7898ad..b4eb8b0a69 100644 --- a/core/src/main/java/org/bouncycastle/crypto/engines/Grain128Engine.java +++ b/core/src/main/java/org/bouncycastle/crypto/engines/Grain128Engine.java @@ -226,7 +226,7 @@ private void setKey(byte[] keyBytes, byte[] ivBytes) workingKey = keyBytes; workingIV = ivBytes; - /** + /* * Load NFSR and LFSR */ int j = 0; diff --git a/core/src/main/java/org/bouncycastle/crypto/generators/Argon2BytesGenerator.java b/core/src/main/java/org/bouncycastle/crypto/generators/Argon2BytesGenerator.java index c4e9eee295..eade40ff68 100755 --- a/core/src/main/java/org/bouncycastle/crypto/generators/Argon2BytesGenerator.java +++ b/core/src/main/java/org/bouncycastle/crypto/generators/Argon2BytesGenerator.java @@ -485,7 +485,7 @@ private static void quarterRound(long[] v, int x, int y, int z, int s) private void initialize(byte[] tmpBlockBytes, byte[] password, int outputLength) { - /** + /* * H0 = H64(p, τ, m, t, v, y, |P|, P, |S|, S, |L|, K, |X|, X) * -> 64 byte (ARGON2_PREHASH_DIGEST_LENGTH) */ diff --git a/core/src/test/java/org/bouncycastle/crypto/test/Blake2bDigestTest.java b/core/src/test/java/org/bouncycastle/crypto/test/Blake2bDigestTest.java index 8a7bc6428c..1e2cc74960 100644 --- a/core/src/test/java/org/bouncycastle/crypto/test/Blake2bDigestTest.java +++ b/core/src/test/java/org/bouncycastle/crypto/test/Blake2bDigestTest.java @@ -1,7 +1,5 @@ package org.bouncycastle.crypto.test; -import java.io.UnsupportedEncodingException; - import org.bouncycastle.crypto.Digest; import org.bouncycastle.crypto.digests.Blake2bDigest; import org.bouncycastle.util.Arrays; @@ -124,23 +122,15 @@ public void performTest() for (int i = 0; i < unkeyedTestVectors.length; i++) { - try - { - // blake2bunkeyed.update( - // unkeyedTestVectors[i][1].getBytes("UTF-8")); - // test update(byte b) - byte[] unkeyedInput = unkeyedTestVectors[i][1] - .getBytes("UTF-8"); - for (int j = 0; j < unkeyedInput.length; j++) - { - blake2bunkeyed.update(unkeyedInput[j]); - } - } - catch (UnsupportedEncodingException e) + // blake2bunkeyed.update( + // unkeyedTestVectors[i][1].getBytes("UTF-8")); + // test update(byte b) + byte[] unkeyedInput = Strings.toUTF8ByteArray(unkeyedTestVectors[i][1]); + for (int j = 0; j < unkeyedInput.length; j++) { - // TODO Auto-generated catch block - e.printStackTrace(); + blake2bunkeyed.update(unkeyedInput[j]); } + byte[] unkeyedHash = new byte[64]; blake2bunkeyed.doFinal(unkeyedHash, 0); blake2bunkeyed.reset(); diff --git a/core/src/test/java/org/bouncycastle/pqc/crypto/test/XMSSMTPrivateKeyTest.java b/core/src/test/java/org/bouncycastle/pqc/crypto/test/XMSSMTPrivateKeyTest.java index b9fe45f4be..c426801035 100644 --- a/core/src/test/java/org/bouncycastle/pqc/crypto/test/XMSSMTPrivateKeyTest.java +++ b/core/src/test/java/org/bouncycastle/pqc/crypto/test/XMSSMTPrivateKeyTest.java @@ -12,6 +12,7 @@ import org.bouncycastle.pqc.crypto.xmss.XMSSParameters; import org.bouncycastle.pqc.crypto.xmss.XMSSPrivateKeyParameters; import org.bouncycastle.util.Arrays; +import org.bouncycastle.util.Strings; import org.bouncycastle.util.encoders.Base64; /** @@ -27,11 +28,8 @@ public void testPrivateKeySerialisation() XMSSParameters params = new XMSSParameters(10, new SHA256Digest()); - byte[] output = Base64.decode(new String(stream).getBytes("UTF-8")); - - + byte[] output = Base64.decode(Strings.toUTF8ByteArray(stream)); //Simple Exploit - try { new XMSSPrivateKeyParameters.Builder(params).withPrivateKey(output).build(); diff --git a/jmail/build.gradle b/jmail/build.gradle index 0b1e816733..c24985e63a 100644 --- a/jmail/build.gradle +++ b/jmail/build.gradle @@ -8,37 +8,32 @@ sourceSets { } } - java9 { java { srcDirs = ['src/main/jdk1.9'] } } - } dependencies { -// implementation project(':prov') -// implementation project(':util') + implementation project(':prov') + implementation project(':util') implementation project(':pkix') implementation group: 'jakarta.mail', name: 'jakarta.mail-api', version: '2.0.1' implementation group: 'jakarta.activation', name: 'jakarta.activation-api', version: '2.0.0' -// implementation files("$bc_prov") -// implementation files("$bc_util") -// implementation files("$bc_pkix") - // implementation project(path: ':core') - - java9Implementation group: 'jakarta.mail', name: 'jakarta.mail-api', version: '2.0.1' - java9Implementation group: 'jakarta.activation', name: 'jakarta.activation-api', version: '2.0.0' -// java9Implementation files("$bc_prov") -// java9Implementation files("$bc_util") -// java9Implementation files("$bc_pkix") + implementation files("$bc_prov") + implementation files("$bc_util") + implementation files("$bc_pkix") + implementation project(path: ':core') + + java9Implementation files("$bc_prov") + java9Implementation files("$bc_util") + java9Implementation files("$bc_pkix") java9Implementation files(sourceSets.main.output.classesDirs) { builtBy compileJava } - } task copyTask(type: Copy) { diff --git a/mail/build.gradle b/mail/build.gradle index a01f5be7b2..5fc9146589 100644 --- a/mail/build.gradle +++ b/mail/build.gradle @@ -7,30 +7,25 @@ sourceSets { srcDirs = ['src/main/jdk1.9'] } } - - } dependencies { - // implementation project(':prov') - // implementation project(':util') + implementation project(':prov') + implementation project(':util') implementation project(':pkix') implementation group: 'javax.mail', name: 'mail', version: '1.4' -// implementation files("$bc_prov") -// implementation files("$bc_util") -// implementation files("$bc_pkix") -// implementation project(path: ':core') - - java9Implementation group: 'javax.mail', name: 'mail', version: '1.4' -// java9Implementation files("$bc_prov") -// java9Implementation files("$bc_util") -// java9Implementation files("$bc_pkix") + implementation files("$bc_prov") + implementation files("$bc_util") + implementation files("$bc_pkix") + implementation project(path: ':core') + + java9Implementation files(":prov") + java9Implementation files(":util") + java9Implementation files(":pkix") java9Implementation files(sourceSets.main.output.classesDirs) { builtBy compileJava } - - } compileJava { @@ -92,4 +87,4 @@ artifacts { test { forkEvery = 1; maxParallelForks = 8; -} \ No newline at end of file +} diff --git a/prov/src/test/java/org/bouncycastle/jce/provider/test/CertTest.java b/prov/src/test/java/org/bouncycastle/jce/provider/test/CertTest.java index 5ae780f7f5..227ac33ae2 100644 --- a/prov/src/test/java/org/bouncycastle/jce/provider/test/CertTest.java +++ b/prov/src/test/java/org/bouncycastle/jce/provider/test/CertTest.java @@ -6,7 +6,6 @@ import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.security.AlgorithmParameters; import java.security.KeyFactory; @@ -1387,27 +1386,27 @@ private void pemTest() { fail("PEM cert with extraneous header not read"); } - CRL crl = cf.generateCRL(new ByteArrayInputStream(PEMData.CRL_1.getBytes("US-ASCII"))); + CRL crl = cf.generateCRL(new ByteArrayInputStream(Strings.toByteArray(PEMData.CRL_1))); if (crl == null) { fail("PEM crl not read"); } - Collection col = cf.generateCertificates(new ByteArrayInputStream(PEMData.CERTIFICATE_2.getBytes("US-ASCII"))); + Collection col = cf.generateCertificates(new ByteArrayInputStream(Strings.toByteArray(PEMData.CERTIFICATE_2))); if (col.size() != 1 || !col.contains(cert)) { fail("PEM cert collection not right"); } - col = cf.generateCertificates(new ByteArrayInputStream((PEMData.CERTIFICATE_2 + "z\n").getBytes("US-ASCII"))); + col = cf.generateCertificates(new ByteArrayInputStream(Strings.toByteArray((PEMData.CERTIFICATE_2 + "z\n")))); if (col.size() != 1 || !col.contains(cert)) { fail("PEM cert collection with extra not right"); } - col = cf.generateCRLs(new ByteArrayInputStream(PEMData.CRL_2.getBytes("US-ASCII"))); + col = cf.generateCRLs(new ByteArrayInputStream(Strings.toByteArray(PEMData.CRL_2))); if (col.size() != 1 || !col.contains(crl)) { fail("PEM crl collection not right"); } - col = cf.generateCRLs(new ByteArrayInputStream((PEMData.CRL_2 + "z\n").getBytes("US-ASCII"))); + col = cf.generateCRLs(new ByteArrayInputStream(Strings.toByteArray((PEMData.CRL_2 + "z\n")))); if (col.size() != 1 || !col.contains(crl)) { fail("PEM crl collection with extra not right"); @@ -1429,9 +1428,9 @@ private void pemTest() } private static Certificate readPEMCert(CertificateFactory cf, String pemData) - throws CertificateException, UnsupportedEncodingException + throws CertificateException { - return cf.generateCertificate(new ByteArrayInputStream(pemData.getBytes("US-ASCII"))); + return cf.generateCertificate(new ByteArrayInputStream(Strings.toByteArray(pemData))); } private void pkcs7Test() @@ -1531,7 +1530,7 @@ private void pkcs7Test() fail("wrong number of Certs: " + certCol.size()); } - in = new ByteArrayInputStream(pemPKCS7.getBytes("US-ASCII")); + in = new ByteArrayInputStream(Strings.toByteArray(pemPKCS7)); certCol = cf.generateCertificates(in); in.reset(); diff --git a/prov/src/test/java/org/bouncycastle/jce/provider/test/X509StreamParserTest.java b/prov/src/test/java/org/bouncycastle/jce/provider/test/X509StreamParserTest.java index b0d1ba76e3..2bd99d40f4 100644 --- a/prov/src/test/java/org/bouncycastle/jce/provider/test/X509StreamParserTest.java +++ b/prov/src/test/java/org/bouncycastle/jce/provider/test/X509StreamParserTest.java @@ -1,25 +1,25 @@ package org.bouncycastle.jce.provider.test; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.security.Security; +import java.security.cert.X509CRL; +import java.security.cert.X509Certificate; +import java.util.Collection; + import org.bouncycastle.asn1.ASN1EncodableVector; import org.bouncycastle.asn1.ASN1InputStream; import org.bouncycastle.asn1.DERSet; import org.bouncycastle.asn1.DERTaggedObject; import org.bouncycastle.internal.asn1.cms.CMSObjectIdentifiers; - import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.bouncycastle.util.Strings; import org.bouncycastle.util.encoders.Base64; import org.bouncycastle.util.test.SimpleTest; import org.bouncycastle.x509.X509AttributeCertificate; import org.bouncycastle.x509.X509CertificatePair; import org.bouncycastle.x509.X509StreamParser; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.security.Security; -import java.security.cert.X509CRL; -import java.security.cert.X509Certificate; -import java.util.Collection; - public class X509StreamParserTest extends SimpleTest { @@ -139,7 +139,7 @@ public void performTest() // parser = X509StreamParser.getInstance("Certificate", "BC"); - parser.init(PEMData.CERTIFICATE_1.getBytes("US-ASCII")); + parser.init(Strings.toByteArray(PEMData.CERTIFICATE_1)); res = parser.readAll(); @@ -150,7 +150,7 @@ public void performTest() parser = X509StreamParser.getInstance("Certificate", "BC"); - parser.init(PEMData.CERTIFICATE_2.getBytes("US-ASCII")); + parser.init(Strings.toByteArray(PEMData.CERTIFICATE_2)); res = parser.readAll(); @@ -161,7 +161,7 @@ public void performTest() parser = X509StreamParser.getInstance("CRL", "BC"); - parser.init(PEMData.CRL_1.getBytes("US-ASCII")); + parser.init(Strings.toByteArray(PEMData.CRL_1)); res = parser.readAll(); @@ -172,7 +172,7 @@ public void performTest() parser = X509StreamParser.getInstance("CRL", "BC"); - parser.init(PEMData.CRL_2.getBytes("US-ASCII")); + parser.init(Strings.toByteArray(PEMData.CRL_2)); res = parser.readAll(); @@ -183,7 +183,7 @@ public void performTest() parser = X509StreamParser.getInstance("AttributeCertificate", "BC"); - parser.init(PEMData.ATTRIBUTE_CERTIFICATE_1.getBytes("US-ASCII")); + parser.init(Strings.toByteArray(PEMData.ATTRIBUTE_CERTIFICATE_1)); res = parser.readAll(); @@ -194,7 +194,7 @@ public void performTest() parser = X509StreamParser.getInstance("AttributeCertificate", "BC"); - parser.init(PEMData.ATTRIBUTE_CERTIFICATE_2.getBytes("US-ASCII")); + parser.init(Strings.toByteArray(PEMData.ATTRIBUTE_CERTIFICATE_2)); res = parser.readAll(); diff --git a/prov/src/test/java/org/bouncycastle/jce/provider/test/nist/PKITSTest.java b/prov/src/test/java/org/bouncycastle/jce/provider/test/nist/PKITSTest.java index a35ed38b73..327f1ed319 100644 --- a/prov/src/test/java/org/bouncycastle/jce/provider/test/nist/PKITSTest.java +++ b/prov/src/test/java/org/bouncycastle/jce/provider/test/nist/PKITSTest.java @@ -40,8 +40,8 @@ class PKITSTest { private Set trustAnchors = new HashSet(); - private ArrayList certs = new ArrayList(); - private ArrayList crls = new ArrayList(); + private List certs = new ArrayList(); + private List crls = new ArrayList(); private Set policies = new HashSet(); // @@ -293,12 +293,12 @@ public Set getTrustAnchors() return trustAnchors; } - public ArrayList getCerts() + public List getCerts() { return certs; } - public ArrayList getCrls() + public List getCrls() { return crls; } diff --git a/settings.gradle b/settings.gradle index 26f214a968..c54949b153 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,5 +6,5 @@ include "prov" include "tls" include "test" include "mls" -//include "mail" -//include "jmail" \ No newline at end of file +include "mail" +include "jmail" diff --git a/tls/src/test/java/org/bouncycastle/jsse/provider/test/BCJSSEClientTest.java b/tls/src/test/java/org/bouncycastle/jsse/provider/test/BCJSSEClientTest.java index 80603db792..e799f74ef9 100644 --- a/tls/src/test/java/org/bouncycastle/jsse/provider/test/BCJSSEClientTest.java +++ b/tls/src/test/java/org/bouncycastle/jsse/provider/test/BCJSSEClientTest.java @@ -32,6 +32,7 @@ import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; import org.bouncycastle.jsse.BCExtendedSSLSession; import org.bouncycastle.jsse.BCSSLSocket; +import org.bouncycastle.util.Strings; import org.bouncycastle.util.encoders.Hex; import org.bouncycastle.util.io.pem.PemObject; import org.bouncycastle.util.io.pem.PemReader; @@ -260,7 +261,7 @@ public void handshakeCompleted(HandshakeCompletedEvent event) private static void writeUTF8Line(OutputStream output, String line) throws IOException { - output.write((line + "\r\n").getBytes("UTF-8")); + output.write(Strings.toUTF8ByteArray(line + "\r\n")); System.out.println(">>> " + line); } diff --git a/tls/src/test/java/org/bouncycastle/jsse/provider/test/CipherSuitesEngineTestCase.java b/tls/src/test/java/org/bouncycastle/jsse/provider/test/CipherSuitesEngineTestCase.java index 3118d4f006..528d8d8141 100644 --- a/tls/src/test/java/org/bouncycastle/jsse/provider/test/CipherSuitesEngineTestCase.java +++ b/tls/src/test/java/org/bouncycastle/jsse/provider/test/CipherSuitesEngineTestCase.java @@ -12,9 +12,9 @@ import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManagerFactory; -import org.bouncycastle.util.Arrays; - import junit.framework.TestCase; +import org.bouncycastle.util.Arrays; +import org.bouncycastle.util.Strings; public class CipherSuitesEngineTestCase extends TestCase { @@ -100,8 +100,8 @@ private void runTestConnection() throws Throwable ByteBuffer clientToServer = ByteBuffer.allocate(clientNetBufSize); ByteBuffer serverToClient = ByteBuffer.allocate(serverNetBufSize); - ByteBuffer clientOut = ByteBuffer.wrap("Dear Prudence, won't you come out to play?".getBytes("UTF-8")); - ByteBuffer serverOut = ByteBuffer.wrap("Impudence! I won't come out to today.".getBytes("UTF-8")); + ByteBuffer clientOut = ByteBuffer.wrap(Strings.toUTF8ByteArray("Dear Prudence, won't you come out to play?")); + ByteBuffer serverOut = ByteBuffer.wrap(Strings.toUTF8ByteArray("Impudence! I won't come out to today.")); SSLEngineResult clientResult; SSLEngineResult serverResult; diff --git a/tls/src/test/java/org/bouncycastle/tls/test/DTLSClientTest.java b/tls/src/test/java/org/bouncycastle/tls/test/DTLSClientTest.java index 8739b5120b..c68c7d6011 100644 --- a/tls/src/test/java/org/bouncycastle/tls/test/DTLSClientTest.java +++ b/tls/src/test/java/org/bouncycastle/tls/test/DTLSClientTest.java @@ -11,6 +11,7 @@ import org.bouncycastle.tls.TlsClient; import org.bouncycastle.tls.TlsSession; import org.bouncycastle.tls.UDPTransport; +import org.bouncycastle.util.Strings; /** * A simple test designed to conduct a DTLS handshake with an external DTLS server. @@ -40,7 +41,7 @@ public static void main(String[] args) // Send and hopefully receive a packet back - byte[] request = "Hello World!\n".getBytes("UTF-8"); + byte[] request = Strings.toUTF8ByteArray("Hello World!\n"); dtls.send(request, 0, request.length); byte[] response = new byte[dtls.getReceiveLimit()]; diff --git a/tls/src/test/java/org/bouncycastle/tls/test/PSKTls13ClientTest.java b/tls/src/test/java/org/bouncycastle/tls/test/PSKTls13ClientTest.java index 79cdab434f..06f183193e 100644 --- a/tls/src/test/java/org/bouncycastle/tls/test/PSKTls13ClientTest.java +++ b/tls/src/test/java/org/bouncycastle/tls/test/PSKTls13ClientTest.java @@ -10,6 +10,7 @@ import org.bouncycastle.tls.TlsClient; import org.bouncycastle.tls.TlsClientProtocol; +import org.bouncycastle.util.Strings; public class PSKTls13ClientTest { @@ -27,7 +28,7 @@ public static void main(String[] args) throws Exception System.out.println("Elapsed: " + (time1 - time0) + "ms"); OutputStream output = protocol.getOutputStream(); - output.write("GET / HTTP/1.1\r\n\r\n".getBytes("UTF-8")); + output.write(Strings.toUTF8ByteArray("GET / HTTP/1.1\r\n\r\n")); output.flush(); InputStream input = protocol.getInputStream(); diff --git a/tls/src/test/java/org/bouncycastle/tls/test/PSKTlsClientTest.java b/tls/src/test/java/org/bouncycastle/tls/test/PSKTlsClientTest.java index 0187ef2d28..c8eb43ffab 100644 --- a/tls/src/test/java/org/bouncycastle/tls/test/PSKTlsClientTest.java +++ b/tls/src/test/java/org/bouncycastle/tls/test/PSKTlsClientTest.java @@ -59,7 +59,7 @@ public static void main(String[] args) throws Exception System.out.println("Elapsed 2: " + (time3 - time2) + "ms"); OutputStream output = protocol.getOutputStream(); - output.write("GET / HTTP/1.1\r\n\r\n".getBytes("UTF-8")); + output.write(Strings.toUTF8ByteArray("GET / HTTP/1.1\r\n\r\n")); output.flush(); InputStream input = protocol.getInputStream(); diff --git a/tls/src/test/java/org/bouncycastle/tls/test/TlsClientRawKeysTest.java b/tls/src/test/java/org/bouncycastle/tls/test/TlsClientRawKeysTest.java index f54d5028e3..7f932947da 100644 --- a/tls/src/test/java/org/bouncycastle/tls/test/TlsClientRawKeysTest.java +++ b/tls/src/test/java/org/bouncycastle/tls/test/TlsClientRawKeysTest.java @@ -14,6 +14,7 @@ import org.bouncycastle.tls.ProtocolVersion; import org.bouncycastle.tls.TlsClient; import org.bouncycastle.tls.TlsClientProtocol; +import org.bouncycastle.util.Strings; /** * A simple test designed to conduct a TLS handshake with an external TLS server. @@ -46,7 +47,7 @@ static void runTest(InetAddress address, int port, ProtocolVersion tlsVersion) t TlsClientProtocol protocol = openTlsConnection(address, port, client); OutputStream output = protocol.getOutputStream(); - output.write("GET / HTTP/1.1\r\n\r\n".getBytes("UTF-8")); + output.write(Strings.toUTF8ByteArray("GET / HTTP/1.1\r\n\r\n")); output.flush(); InputStream input = protocol.getInputStream(); diff --git a/tls/src/test/java/org/bouncycastle/tls/test/TlsClientTest.java b/tls/src/test/java/org/bouncycastle/tls/test/TlsClientTest.java index c4da9cf7e5..ebf09805bc 100644 --- a/tls/src/test/java/org/bouncycastle/tls/test/TlsClientTest.java +++ b/tls/src/test/java/org/bouncycastle/tls/test/TlsClientTest.java @@ -10,6 +10,7 @@ import org.bouncycastle.tls.TlsClient; import org.bouncycastle.tls.TlsClientProtocol; +import org.bouncycastle.util.Strings; /** * A simple test designed to conduct a TLS handshake with an external TLS server. @@ -42,7 +43,7 @@ public static void main(String[] args) System.out.println("Elapsed 2: " + (time3 - time2) + "ms"); OutputStream output = protocol.getOutputStream(); - output.write("GET / HTTP/1.1\r\n\r\n".getBytes("UTF-8")); + output.write(Strings.toUTF8ByteArray("GET / HTTP/1.1\r\n\r\n")); output.flush(); InputStream input = protocol.getInputStream();