Skip to content

Commit 44ea4b6

Browse files
committed
Project import generated by Copybara.
PiperOrigin-RevId: 856236394
1 parent a2981b3 commit 44ea4b6

File tree

11 files changed

+197
-33
lines changed

11 files changed

+197
-33
lines changed
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2-
<application/>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="org.conscrypt">
4+
5+
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="30" />
6+
37
</manifest>

android/src/main/java/org/conscrypt/Platform.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import dalvik.system.BlockGuard;
2828
import dalvik.system.CloseGuard;
2929

30-
import org.conscrypt.NativeCrypto;
3130
import org.conscrypt.ct.CertificateTransparency;
3231
import org.conscrypt.metrics.CertificateTransparencyVerificationReason;
3332
import org.conscrypt.metrics.NoopStatsLog;
@@ -50,7 +49,6 @@
5049
import java.security.KeyStore;
5150
import java.security.KeyStoreException;
5251
import java.security.NoSuchAlgorithmException;
53-
import java.security.PrivateKey;
5452
import java.security.Security;
5553
import java.security.cert.CertificateException;
5654
import java.security.cert.X509Certificate;
@@ -76,6 +74,7 @@
7674
* Platform-specific methods for unbundled Android.
7775
*/
7876
@Internal
77+
@SuppressLint("DiscouragedPrivateApi")
7978
final public class Platform {
8079
private static final String TAG = "Conscrypt";
8180
private static boolean DEPRECATED_TLS_V1 = true;
@@ -787,6 +786,7 @@ public static SSLSession wrapSSLSession(ExternalSession sslSession) {
787786
return sslSession;
788787
}
789788

789+
@SuppressWarnings("SoonBlockedPrivateApi")
790790
public static String getOriginalHostNameFromInetAddress(InetAddress addr) {
791791
if (Build.VERSION.SDK_INT > 27) {
792792
try {

common/src/main/java/org/conscrypt/TrustManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,15 @@
7171
import javax.net.ssl.X509ExtendedTrustManager;
7272

7373
/**
74-
*
7574
* TrustManager implementation. The implementation is based on CertPathValidator
7675
* PKIX and CertificateFactory X509 implementations. This implementations should
7776
* be provided by some certification provider.
7877
*
7978
* @see javax.net.ssl.X509ExtendedTrustManager
8079
*/
8180
@Internal
81+
@SuppressWarnings("CustomX509TrustManager")
8282
public final class TrustManagerImpl extends X509ExtendedTrustManager {
83-
8483
private static final Logger logger = Logger.getLogger(TrustManagerImpl.class.getName());
8584

8685
/**
@@ -431,7 +430,8 @@ private byte[] getTlsSctDataFromSession(SSLSession session) {
431430

432431
byte[] data = null;
433432
try {
434-
Method m_getTlsSctData = session.getClass().getDeclaredMethod("getPeerSignedCertificateTimestamp");
433+
Method m_getTlsSctData =
434+
session.getClass().getDeclaredMethod("getPeerSignedCertificateTimestamp");
435435
m_getTlsSctData.setAccessible(true);
436436
Object rawData = m_getTlsSctData.invoke(session);
437437
if (rawData instanceof byte[]) {

common/src/test/java/org/conscrypt/HostnameVerifierTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,24 @@
2121
import static org.junit.Assert.assertFalse;
2222
import static org.junit.Assert.assertTrue;
2323

24+
import org.junit.Ignore;
25+
import org.junit.Test;
26+
import org.junit.runner.RunWith;
27+
import org.junit.runners.Parameterized;
28+
import org.junit.runners.Parameterized.Parameter;
29+
import org.junit.runners.Parameterized.Parameters;
30+
2431
import java.io.ByteArrayInputStream;
2532
import java.nio.charset.Charset;
2633
import java.security.cert.Certificate;
2734
import java.security.cert.CertificateFactory;
2835
import java.security.cert.X509Certificate;
2936
import java.util.Arrays;
3037
import java.util.Collection;
38+
3139
import javax.net.ssl.SSLPeerUnverifiedException;
3240
import javax.net.ssl.SSLSession;
3341
import javax.security.auth.x500.X500Principal;
34-
import org.junit.Ignore;
35-
import org.junit.Test;
36-
import org.junit.runner.RunWith;
37-
import org.junit.runners.Parameterized;
38-
import org.junit.runners.Parameterized.Parameter;
39-
import org.junit.runners.Parameterized.Parameters;
4042

4143
/**
4244
* Tests for our hostname verifier. Most of these tests are from AOSP, which
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/*
2+
* Copyright (C) 2023 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.conscrypt;
18+
19+
import static org.conscrypt.TestUtils.installConscryptAsDefaultProvider;
20+
21+
import org.conscrypt.ct.SerializationTest;
22+
import org.conscrypt.ct.VerifierTest;
23+
import org.conscrypt.java.security.AlgorithmParameterGeneratorTestDH;
24+
import org.conscrypt.java.security.AlgorithmParameterGeneratorTestDSA;
25+
import org.conscrypt.java.security.AlgorithmParametersPSSTest;
26+
import org.conscrypt.java.security.AlgorithmParametersTestAES;
27+
import org.conscrypt.java.security.AlgorithmParametersTestDES;
28+
import org.conscrypt.java.security.AlgorithmParametersTestDESede;
29+
import org.conscrypt.java.security.AlgorithmParametersTestDH;
30+
import org.conscrypt.java.security.AlgorithmParametersTestDSA;
31+
import org.conscrypt.java.security.AlgorithmParametersTestEC;
32+
import org.conscrypt.java.security.AlgorithmParametersTestGCM;
33+
import org.conscrypt.java.security.AlgorithmParametersTestOAEP;
34+
import org.conscrypt.java.security.KeyFactoryTestDH;
35+
import org.conscrypt.java.security.KeyFactoryTestDSA;
36+
import org.conscrypt.java.security.KeyFactoryTestEC;
37+
import org.conscrypt.java.security.KeyFactoryTestRSACrt;
38+
import org.conscrypt.java.security.KeyPairGeneratorTest;
39+
import org.conscrypt.java.security.KeyPairGeneratorTestDH;
40+
import org.conscrypt.java.security.KeyPairGeneratorTestDSA;
41+
import org.conscrypt.java.security.KeyPairGeneratorTestRSA;
42+
import org.conscrypt.java.security.KeyPairGeneratorTestXDH;
43+
import org.conscrypt.java.security.MessageDigestTest;
44+
import org.conscrypt.java.security.SignatureTest;
45+
import org.conscrypt.java.security.cert.CertificateFactoryTest;
46+
import org.conscrypt.java.security.cert.X509CRLTest;
47+
import org.conscrypt.java.security.cert.X509CertificateTest;
48+
import org.conscrypt.javax.crypto.AeadCipherTest;
49+
import org.conscrypt.javax.crypto.CipherBasicsTest;
50+
import org.conscrypt.javax.crypto.ECDHKeyAgreementTest;
51+
import org.conscrypt.javax.crypto.KeyGeneratorTest;
52+
import org.conscrypt.javax.crypto.ScryptTest;
53+
import org.conscrypt.javax.crypto.XDHKeyAgreementTest;
54+
import org.conscrypt.javax.crypto.XdhKeyFactoryTest;
55+
import org.conscrypt.javax.crypto.XdhKeyTest;
56+
import org.conscrypt.javax.net.ssl.KeyManagerFactoryTest;
57+
import org.conscrypt.javax.net.ssl.KeyStoreBuilderParametersTest;
58+
import org.conscrypt.javax.net.ssl.SNIHostNameTest;
59+
import org.conscrypt.javax.net.ssl.SSLParametersTest;
60+
import org.conscrypt.javax.net.ssl.X509KeyManagerTest;
61+
import org.conscrypt.metrics.CipherSuiteTest;
62+
import org.conscrypt.metrics.OptionalMethodTest;
63+
import org.conscrypt.metrics.ProtocolTest;
64+
import org.junit.BeforeClass;
65+
import org.junit.runner.RunWith;
66+
import org.junit.runners.Suite;
67+
68+
@RunWith(Suite.class)
69+
@Suite.SuiteClasses({
70+
// org.conscrypt tests
71+
AddressUtilsTest.class,
72+
ApplicationProtocolSelectorAdapterTest.class,
73+
ArrayUtilsTest.class,
74+
CertPinManagerTest.class,
75+
ChainStrengthAnalyzerTest.class,
76+
DuckTypedHpkeSpiTest.class,
77+
EdDsaTest.class,
78+
ExposedByteArrayOutputStreamTest.class,
79+
FileClientSessionCacheTest.class,
80+
HostnameVerifierTest.class,
81+
HpkeContextTest.class,
82+
HpkeContextRecipientTest.class,
83+
HpkeContextSenderTest.class,
84+
HpkeSuiteTest.class,
85+
HpkeTestVectorsTest.class,
86+
KeySpecUtilTest.class,
87+
MlDsaTest.class,
88+
NativeCryptoArgTest.class,
89+
NativeCryptoTest.class,
90+
NativeRefTest.class,
91+
NativeSslSessionTest.class,
92+
OpenSSLKeyTest.class,
93+
OpenSSLX509CertificateTest.class,
94+
SSLUtilsTest.class,
95+
SlhDsaTest.class,
96+
TestSessionBuilderTest.class,
97+
TrustManagerImplTest.class,
98+
X25519Test.class,
99+
XwingTest.class,
100+
// org.conscrypt.ct tests
101+
VerifierTest.class,
102+
SerializationTest.class,
103+
// java.security tests
104+
CertificateFactoryTest.class,
105+
X509CertificateTest.class,
106+
X509CRLTest.class,
107+
AlgorithmParameterGeneratorTestDH.class,
108+
AlgorithmParameterGeneratorTestDSA.class,
109+
AlgorithmParametersPSSTest.class,
110+
AlgorithmParametersTestAES.class,
111+
AlgorithmParametersTestDES.class,
112+
AlgorithmParametersTestDESede.class,
113+
AlgorithmParametersTestDH.class,
114+
AlgorithmParametersTestDSA.class,
115+
AlgorithmParametersTestEC.class,
116+
AlgorithmParametersTestGCM.class,
117+
AlgorithmParametersTestOAEP.class,
118+
BufferUtilsTest.class,
119+
CipherSuiteTest.class,
120+
KeyFactoryTestDH.class,
121+
KeyFactoryTestDSA.class,
122+
KeyFactoryTestEC.class,
123+
KeyFactoryTestRSACrt.class,
124+
KeyPairGeneratorTest.class,
125+
KeyPairGeneratorTestDH.class,
126+
KeyPairGeneratorTestDSA.class,
127+
KeyPairGeneratorTestRSA.class,
128+
KeyPairGeneratorTestXDH.class,
129+
MessageDigestTest.class,
130+
SignatureTest.class,
131+
// javax.crypto tests
132+
AeadCipherTest.class,
133+
CipherBasicsTest.class,
134+
MacTest.class,
135+
ECDHKeyAgreementTest.class,
136+
KeyGeneratorTest.class,
137+
XDHKeyAgreementTest.class,
138+
XdhKeyFactoryTest.class,
139+
XdhKeyTest.class,
140+
// javax.net.ssl tests
141+
KeyManagerFactoryTest.class,
142+
KeyStoreBuilderParametersTest.class,
143+
OptionalMethodTest.class,
144+
ProtocolTest.class,
145+
ScryptTest.class,
146+
SNIHostNameTest.class,
147+
SSLParametersTest.class,
148+
VeryBasicHttpServerTest.class,
149+
X509KeyManagerTest.class,
150+
})
151+
public class ConscryptAndroidSuite {
152+
@BeforeClass
153+
public static void setupStatic() {
154+
installConscryptAsDefaultProvider();
155+
}
156+
}

openjdk/src/test/java/org/conscrypt/ConscryptSocketTest.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@
2929
import static org.mockito.ArgumentMatchers.any;
3030
import static org.mockito.Mockito.when;
3131

32+
import org.junit.After;
33+
import org.junit.Before;
34+
import org.junit.Ignore;
35+
import org.junit.Test;
36+
import org.junit.runner.RunWith;
37+
import org.junit.runners.Parameterized;
38+
import org.junit.runners.Parameterized.Parameter;
39+
import org.junit.runners.Parameterized.Parameters;
40+
import org.mockito.ArgumentMatchers;
41+
import org.mockito.Mockito;
42+
3243
import java.io.IOException;
3344
import java.lang.reflect.Field;
3445
import java.net.InetAddress;
@@ -49,6 +60,7 @@
4960
import java.util.concurrent.Executors;
5061
import java.util.concurrent.Future;
5162
import java.util.concurrent.TimeUnit;
63+
5264
import javax.net.ssl.HandshakeCompletedEvent;
5365
import javax.net.ssl.HandshakeCompletedListener;
5466
import javax.net.ssl.KeyManager;
@@ -59,16 +71,6 @@
5971
import javax.net.ssl.SSLSocketFactory;
6072
import javax.net.ssl.TrustManager;
6173
import javax.net.ssl.TrustManagerFactory;
62-
import org.junit.After;
63-
import org.junit.Before;
64-
import org.junit.Ignore;
65-
import org.junit.Test;
66-
import org.junit.runner.RunWith;
67-
import org.junit.runners.Parameterized;
68-
import org.junit.runners.Parameterized.Parameter;
69-
import org.junit.runners.Parameterized.Parameters;
70-
import org.mockito.ArgumentMatchers;
71-
import org.mockito.Mockito;
7274

7375
@RunWith(Parameterized.class)
7476
public class ConscryptSocketTest {

openjdk/src/test/java/org/conscrypt/ConscryptTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import static org.junit.Assert.fail;
2424

2525
import org.conscrypt.java.security.StandardNames;
26-
// g3-add: import org.junit.Ignore;
26+
import org.junit.Ignore;
2727
import org.junit.Test;
2828
import org.junit.runner.RunWith;
2929
import org.junit.runners.JUnit4;

openjdk/src/test/java/org/conscrypt/OpenSSLX509CertificateTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
import static org.junit.Assert.fail;
2525
import static org.junit.Assume.assumeFalse;
2626

27+
import org.conscrypt.OpenSSLX509CertificateFactory.ParsingException;
28+
import org.junit.Assume;
29+
import org.junit.Ignore;
30+
import org.junit.Test;
31+
import org.junit.runner.RunWith;
32+
import org.junit.runners.JUnit4;
33+
2734
import java.io.ByteArrayInputStream;
2835
import java.io.ByteArrayOutputStream;
2936
import java.io.FileNotFoundException;
@@ -35,12 +42,6 @@
3542
import java.lang.reflect.Method;
3643
import java.lang.reflect.Modifier;
3744
import java.util.Arrays;
38-
import org.conscrypt.OpenSSLX509CertificateFactory.ParsingException;
39-
import org.junit.Assume;
40-
import org.junit.Ignore;
41-
import org.junit.Test;
42-
import org.junit.runner.RunWith;
43-
import org.junit.runners.JUnit4;
4445

4546
@RunWith(JUnit4.class)
4647
public class OpenSSLX509CertificateTest {

openjdk/src/test/java/org/conscrypt/ServerSessionContextTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int size(ServerSessionContext context) {
3939
int count = 0;
4040
Enumeration<byte[]> ids = context.getIds();
4141
while (ids.hasMoreElements()) {
42-
ids.nextElement();
42+
Object unused = ids.nextElement();
4343
count++;
4444
}
4545
return count;

platform/src/main/java/org/conscrypt/Platform.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ static void setSSLParameters(
217217
} catch (NoSuchMethodException | IllegalArgumentException e) {
218218
// Do nothing.
219219
}
220-
221220
List<SNIServerName> serverNames = params.getServerNames();
222221
if (serverNames != null) {
223222
for (SNIServerName serverName : serverNames) {
@@ -242,7 +241,6 @@ static void getSSLParameters(
242241
} catch (NoSuchMethodException | IllegalArgumentException e) {
243242
// Do nothing.
244243
}
245-
246244
if (impl.getUseSni() && AddressUtils.isValidSniHostname(engine.getHostname())) {
247245
params.setServerNames(Collections.<SNIServerName>singletonList(
248246
new SNIHostName(engine.getHostname())));

0 commit comments

Comments
 (0)