Skip to content

Commit cc83971

Browse files
committed
Project import generated by Copybara.
PiperOrigin-RevId: 861685725
1 parent 7cbb302 commit cc83971

File tree

96 files changed

+8625
-7068
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+8625
-7068
lines changed

.clang-format

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
---
22
Language: Cpp
3-
BasedOnStyle: Google
3+
BasedOnStyle: Google
44
AccessModifierOffset: -4
55
AllowShortFunctionsOnASingleLine: Empty
66
ColumnLimit: 100
77
IndentWidth: 4
88
ContinuationIndentWidth: 8
99
TypenameMacros: ['STACK_OF']
10+
AlignEscapedNewlines: Left
11+
AlignAfterOpenBracket: Align
1012
---
1113
Language: Java
1214
BasedOnStyle: Google
1315
ColumnLimit: 100
1416
IndentWidth: 4
1517
ContinuationIndentWidth: 8
18+
AlignAfterOpenBracket: Align
1619
JavaImportGroups:
1720
- android
1821
- androidx

android/lint.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,10 @@
2828
<issue id="Assert">
2929
<ignore path="**/common/src/main/java/org/conscrypt/OpenSSLCipherChaCha20.java" />
3030
</issue>
31+
32+
<!-- Workaround for "Unexpected failure during lint analysis". -->
33+
<issue id="LintError">
34+
<ignore regexp=".*module-info\.class.*"/>
35+
</issue>
36+
3137
</lint>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2020 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+
/**
20+
* Stub class for logging statistics events.
21+
*/
22+
public class ConscryptStatsLog {
23+
public static final int TLS_HANDSHAKE_REPORTED = 0;
24+
25+
public static void write(int code, boolean arg1, int arg2, int arg3, int arg4) {}
26+
}

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

Lines changed: 116 additions & 141 deletions
Large diffs are not rendered by default.

common/src/jni/main/cpp/conscrypt/jniutil.cc

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include <conscrypt/jniutil.h>
18-
1917
#include <conscrypt/compat.h>
18+
#include <conscrypt/jniutil.h>
2019
#include <conscrypt/trace.h>
21-
#include <cstdlib>
2220
#include <errno.h>
2321

22+
#include <cstdlib>
23+
2424
namespace conscrypt {
2525
namespace jniutil {
2626

27-
JavaVM *gJavaVM;
27+
JavaVM* gJavaVM;
2828
jclass cryptoUpcallsClass;
2929
jclass openSslInputStreamClass;
3030
jclass nativeRefClass;
@@ -84,10 +84,10 @@ void init(JavaVM* vm, JNIEnv* env) {
8484
bufferClass = findClass(env, "java/nio/Buffer");
8585
fileDescriptorClass = findClass(env, "java/io/FileDescriptor");
8686

87-
cryptoUpcallsClass = getGlobalRefToClass(
88-
env, TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/CryptoUpcalls");
89-
nativeRefClass = getGlobalRefToClass(
90-
env, TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/NativeRef");
87+
cryptoUpcallsClass =
88+
getGlobalRefToClass(env, TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/CryptoUpcalls");
89+
nativeRefClass =
90+
getGlobalRefToClass(env, TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/NativeRef");
9191
nativeRefHpkeCtxClass = getGlobalRefToClass(
9292
env, TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/NativeRef$EVP_HPKE_CTX");
9393
openSslInputStreamClass = getGlobalRefToClass(
@@ -106,46 +106,43 @@ void init(JavaVM* vm, JNIEnv* env) {
106106
inputStream_readMethod = getMethodRef(env, inputStreamClass, "read", "([B)I");
107107
integer_valueOfMethod =
108108
env->GetStaticMethodID(integerClass, "valueOf", "(I)Ljava/lang/Integer;");
109-
openSslInputStream_readLineMethod =
110-
getMethodRef(env, openSslInputStreamClass, "gets", "([B)I");
109+
openSslInputStream_readLineMethod = getMethodRef(env, openSslInputStreamClass, "gets", "([B)I");
111110
outputStream_writeMethod = getMethodRef(env, outputStreamClass, "write", "([B)V");
112111
outputStream_flushMethod = getMethodRef(env, outputStreamClass, "flush", "()V");
113112
buffer_positionMethod = getMethodRef(env, bufferClass, "position", "()I");
114113
buffer_limitMethod = getMethodRef(env, bufferClass, "limit", "()I");
115114
buffer_isDirectMethod = getMethodRef(env, bufferClass, "isDirect", "()Z");
116-
sslHandshakeCallbacks_verifyCertificateChain =
117-
getMethodRef(env, sslHandshakeCallbacksClass, "verifyCertificateChain", "([[BLjava/lang/String;)V");
115+
sslHandshakeCallbacks_verifyCertificateChain = getMethodRef(
116+
env, sslHandshakeCallbacksClass, "verifyCertificateChain", "([[BLjava/lang/String;)V");
118117
sslHandshakeCallbacks_onSSLStateChange =
119-
getMethodRef(env, sslHandshakeCallbacksClass, "onSSLStateChange", "(II)V");
120-
sslHandshakeCallbacks_clientCertificateRequested =
121-
getMethodRef(env, sslHandshakeCallbacksClass, "clientCertificateRequested", "([B[I[[B)V");
118+
getMethodRef(env, sslHandshakeCallbacksClass, "onSSLStateChange", "(II)V");
119+
sslHandshakeCallbacks_clientCertificateRequested = getMethodRef(
120+
env, sslHandshakeCallbacksClass, "clientCertificateRequested", "([B[I[[B)V");
122121
sslHandshakeCallbacks_serverCertificateRequested =
123-
getMethodRef(env, sslHandshakeCallbacksClass, "serverCertificateRequested", "()V");
124-
sslHandshakeCallbacks_clientPSKKeyRequested =
125-
getMethodRef(env, sslHandshakeCallbacksClass, "clientPSKKeyRequested", "(Ljava/lang/String;[B[B)I");
122+
getMethodRef(env, sslHandshakeCallbacksClass, "serverCertificateRequested", "()V");
123+
sslHandshakeCallbacks_clientPSKKeyRequested = getMethodRef(
124+
env, sslHandshakeCallbacksClass, "clientPSKKeyRequested", "(Ljava/lang/String;[B[B)I");
126125
sslHandshakeCallbacks_serverPSKKeyRequested =
127-
getMethodRef(env, sslHandshakeCallbacksClass, "serverPSKKeyRequested", "(Ljava/lang/String;Ljava/lang/String;[B)I");
126+
getMethodRef(env, sslHandshakeCallbacksClass, "serverPSKKeyRequested",
127+
"(Ljava/lang/String;Ljava/lang/String;[B)I");
128128
sslHandshakeCallbacks_onNewSessionEstablished =
129-
getMethodRef(env, sslHandshakeCallbacksClass, "onNewSessionEstablished", "(J)V");
129+
getMethodRef(env, sslHandshakeCallbacksClass, "onNewSessionEstablished", "(J)V");
130130
sslHandshakeCallbacks_serverSessionRequested =
131-
getMethodRef(env, sslHandshakeCallbacksClass, "serverSessionRequested", "([B)J");
131+
getMethodRef(env, sslHandshakeCallbacksClass, "serverSessionRequested", "([B)J");
132132
sslHandshakeCallbacks_selectApplicationProtocol =
133-
getMethodRef(env, sslHandshakeCallbacksClass, "selectApplicationProtocol", "([B)I");
134-
cryptoUpcallsClass_rawSignMethod = env->GetStaticMethodID(cryptoUpcallsClass,
135-
"ecSignDigestWithPrivateKey",
136-
"(Ljava/security/PrivateKey;[B)[B");
133+
getMethodRef(env, sslHandshakeCallbacksClass, "selectApplicationProtocol", "([B)I");
134+
cryptoUpcallsClass_rawSignMethod = env->GetStaticMethodID(
135+
cryptoUpcallsClass, "ecSignDigestWithPrivateKey", "(Ljava/security/PrivateKey;[B)[B");
137136
if (cryptoUpcallsClass_rawSignMethod == nullptr) {
138137
env->FatalError("Could not find ecSignDigestWithPrivateKey");
139138
}
140-
cryptoUpcallsClass_rsaSignMethod = env->GetStaticMethodID(cryptoUpcallsClass,
141-
"rsaSignDigestWithPrivateKey",
142-
"(Ljava/security/PrivateKey;I[B)[B");
139+
cryptoUpcallsClass_rsaSignMethod = env->GetStaticMethodID(
140+
cryptoUpcallsClass, "rsaSignDigestWithPrivateKey", "(Ljava/security/PrivateKey;I[B)[B");
143141
if (cryptoUpcallsClass_rsaSignMethod == nullptr) {
144142
env->FatalError("Could not find rsaSignDigestWithPrivateKey");
145143
}
146-
cryptoUpcallsClass_rsaDecryptMethod = env->GetStaticMethodID(cryptoUpcallsClass,
147-
"rsaDecryptWithPrivateKey",
148-
"(Ljava/security/PrivateKey;I[B)[B");
144+
cryptoUpcallsClass_rsaDecryptMethod = env->GetStaticMethodID(
145+
cryptoUpcallsClass, "rsaDecryptWithPrivateKey", "(Ljava/security/PrivateKey;I[B)[B");
149146
if (cryptoUpcallsClass_rsaDecryptMethod == nullptr) {
150147
env->FatalError("Could not find rsaDecryptWithPrivateKey");
151148
}
@@ -257,14 +254,13 @@ int throwInvalidKeyException(JNIEnv* env, const char* message) {
257254

258255
int throwIllegalArgumentException(JNIEnv* env, const char* message) {
259256
JNI_TRACE("throwIllegalArgumentException %s", message);
260-
return conscrypt::jniutil::throwException(
261-
env, "java/lang/IllegalArgumentException", message);
257+
return conscrypt::jniutil::throwException(env, "java/lang/IllegalArgumentException", message);
262258
}
263259

264260
int throwIllegalBlockSizeException(JNIEnv* env, const char* message) {
265261
JNI_TRACE("throwIllegalBlockSizeException %s", message);
266-
return conscrypt::jniutil::throwException(
267-
env, "javax/crypto/IllegalBlockSizeException", message);
262+
return conscrypt::jniutil::throwException(env, "javax/crypto/IllegalBlockSizeException",
263+
message);
268264
}
269265

270266
int throwIllegalStateException(JNIEnv* env, const char* message) {
@@ -274,14 +270,13 @@ int throwIllegalStateException(JNIEnv* env, const char* message) {
274270

275271
int throwShortBufferException(JNIEnv* env, const char* message) {
276272
JNI_TRACE("throwShortBufferException %s", message);
277-
return conscrypt::jniutil::throwException(
278-
env, "javax/crypto/ShortBufferException", message);
273+
return conscrypt::jniutil::throwException(env, "javax/crypto/ShortBufferException", message);
279274
}
280275

281276
int throwNoSuchAlgorithmException(JNIEnv* env, const char* message) {
282277
JNI_TRACE("throwUnknownAlgorithmException %s", message);
283-
return conscrypt::jniutil::throwException(
284-
env, "java/security/NoSuchAlgorithmException", message);
278+
return conscrypt::jniutil::throwException(env, "java/security/NoSuchAlgorithmException",
279+
message);
285280
}
286281

287282
int throwIOException(JNIEnv* env, const char* message) {
@@ -291,8 +286,8 @@ int throwIOException(JNIEnv* env, const char* message) {
291286

292287
int throwCertificateException(JNIEnv* env, const char* message) {
293288
JNI_TRACE("throwCertificateException %s", message);
294-
return conscrypt::jniutil::throwException(
295-
env, "java/security/cert/CertificateException", message);
289+
return conscrypt::jniutil::throwException(env, "java/security/cert/CertificateException",
290+
message);
296291
}
297292

298293
int throwParsingException(JNIEnv* env, const char* message) {
@@ -333,9 +328,9 @@ int throwForCipherError(JNIEnv* env, int reason, const char* message,
333328
case CIPHER_R_WRONG_FINAL_BLOCK_LENGTH:
334329
return throwIllegalBlockSizeException(env, message);
335330
break;
336-
// TODO(davidben): Remove these ifdefs after
337-
// https://boringssl-review.googlesource.com/c/boringssl/+/35565 has
338-
// rolled out to relevant BoringSSL copies.
331+
// TODO(davidben): Remove these ifdefs after
332+
// https://boringssl-review.googlesource.com/c/boringssl/+/35565 has
333+
// rolled out to relevant BoringSSL copies.
339334
#if defined(CIPHER_R_BAD_KEY_LENGTH)
340335
case CIPHER_R_BAD_KEY_LENGTH:
341336
#endif
@@ -503,8 +498,7 @@ int throwSocketTimeoutException(JNIEnv* env, const char* message) {
503498

504499
int throwSSLHandshakeExceptionStr(JNIEnv* env, const char* message) {
505500
JNI_TRACE("throwSSLExceptionStr %s", message);
506-
return conscrypt::jniutil::throwException(
507-
env, "javax/net/ssl/SSLHandshakeException", message);
501+
return conscrypt::jniutil::throwException(env, "javax/net/ssl/SSLHandshakeException", message);
508502
}
509503

510504
int throwSSLExceptionStr(JNIEnv* env, const char* message) {
@@ -514,8 +508,7 @@ int throwSSLExceptionStr(JNIEnv* env, const char* message) {
514508

515509
int throwSSLProtocolExceptionStr(JNIEnv* env, const char* message) {
516510
JNI_TRACE("throwSSLProtocolExceptionStr %s", message);
517-
return conscrypt::jniutil::throwException(
518-
env, "javax/net/ssl/SSLProtocolException", message);
511+
return conscrypt::jniutil::throwException(env, "javax/net/ssl/SSLProtocolException", message);
519512
}
520513

521514
int throwSSLExceptionWithSslErrors(JNIEnv* env, SSL* ssl, int sslErrorCode, const char* message,

0 commit comments

Comments
 (0)