Conscrypt Documentation
repository·master·Indexed 23 days ago
https://github.com/google/conscryptA Java Security Provider that uses BoringSSL to provide high-performance cryptographic primitives and TLS support for Android and OpenJDK applications. It implements parts of the Java Cryptography Extension (JCE) and Java Secure Socket Extension (JSSE), supporting TLS versions 1.0 through 1.3.
What's inside Conscrypt
- Conscrypt is a Java Security Provider (JSP) that implements parts of the Java Cryptography Extension (JCE) and Java Secure Socket Extension (JSSE). It uses BoringSSL to provide cryptographic primitives and Transport Layer Security (TLS) for Java applications on Android and OpenJDK. It is designed for high performance, borrowing design patterns from the Netty project.
How TLS 1.3 cipher suites are handled
masterIn Conscrypt, the supported cipher suites for TLS 1.3 are always enabled. If you attempt to disable them by omitting them from the array passed tosetEnabledCipherSuites(), the request will be ignored and the suites will remain active.Handle AEAD Cipher input buffering
masterConscrypt's AEAD ciphers do not support incremental processing. Calls to
update()will always returnnull, and input is only processed whendoFinal()is called.Requirement: You must buffer the entire input for each operation before calling
doFinal(). For large inputs, you may need to split the data into chunks. Refer to the BoringSSL documentation for safety considerations when chunking AEAD inputs.View Code Coverage Reports
masterTo generate and view code coverage numbers, run the tests followed by the
jacocoTestReportrule:./gradlew check jacocoTestReportThe HTML report will be generated at:
openjdk/build/reports/jacoco/test/html/index.htmlEnsure compatibility with OAEP ciphers
masterConscrypt's OAEP ciphers (e.g.,
RSA/ECB/OAEPWithSHA-256AndMGF1Padding) use the specified named digest for both the main digest and the MGF1 digest. This differs from OpenJDK, which uses SHA-1 for the MGF1 digest.To ensure maximum compatibility with other providers, use
RSA/ECB/OAEPPaddingand initialize it with anOAEPParameterSpecto explicitly define the digests.Install Conscrypt for OpenJDK (non-Android) via Maven
masterConscrypt OpenJDK artifacts are platform-dependent because they embed a native library. To manage this, use the
os-maven-pluginto automatically detect the correct classifier for your operating system and architecture.Supported platforms include:
linux-x86_64(Linux x86_64)linux-aarch_64(Linux aarch_64)osx-x86_64(Mac x86_64)osx-aarch_64(Mac aarch_64)windows-x86_64(Windows x86_64)
<build> <extensions> <extension> <groupId>kr.motd.maven</groupId> <artifactId>os-maven-plugin</artifactId> <version>1.4.1.Final</version> </extension> </extensions> </build> <dependency> <groupId>org.conscrypt</groupId> <artifactId>conscrypt-openjdk</artifactId> <version>2.6.0</version> <classifier>${os.detected.classifier}</classifier> </dependency>Build Conscrypt
masterTo build Conscrypt from the source repository, use the Gradle wrapper.
To perform a standard build, run:
./gradlew buildTo publish the resulting artifacts to your local Maven repository (allowing you to use them as dependencies in your own projects), run:
./gradlew publishToMavenLocalPrerequisites for building Conscrypt
masterBuilding Conscrypt requires the following environment configuration:
Java
- Runtime: You must have Java 11 installed to run Gradle.
- Compiler: Conscrypt is compiled using Java 8 via Gradle's toolchain support. If Java 8 is not present, Gradle may attempt to install it automatically depending on your OS.
Android SDK
- Install the latest Android SDK.
- Set the
ANDROID_HOMEenvironment variable to the root of your SDK installation.- Example:
export ANDROID_HOME=/usr/local/me/Android/Sdk
- Example:
BoringSSL
- You must first set up the BoringSSL prerequisites.
- Clone BoringSSL and set the
BORINGSSL_HOMEenvironment variable to the installation directory.
Use RSA OAEP Padding with maximum compatibility
masterConscrypt's OAEP ciphers (e.g.,
RSA/ECB/OAEPWithSHA-256AndMGF1Padding) use the named digest for both the main digest and the MGF1 digest. This differs from some OpenJDK providers that always use SHA-1 for the MGF1 digest.To ensure maximum compatibility with other providers, use
RSA/ECB/OAEPPaddingand initialize it with anOAEPParameterSpec.Format C++, Java, and C files in Conscrypt
masterWhen modifying
.java,.cc,.h,.cpp, or.cfiles within the Conscrypt directory (specifically underthird_party/java/conscrypt/main_src/), you must use the project's custom formatting script instead of standard global formatters.Requirements:
- The script only processes files that are currently opened for edit in your version control system (e.g., via
g4 editorhg edit). - You must run the formatter after making changes but before creating a CL, uploading, or submitting your work.
python3 third_party/java/conscrypt/main_src/fix_format.py- The script only processes files that are currently opened for edit in your version control system (e.g., via
Build BoringSSL
masterBefore building Conscrypt, you must build BoringSSL. Follow these steps based on your operating system.
1. Download and Setup
Clone the repository and set the
BORINGSSL_HOMEenvironment variable:git clone https://boringssl.googlesource.com/boringssl cd boringssl export BORINGSSL_HOME=$PWD2. Platform Specific Builds
Linux (64-bit)
mkdir build64 cd build64 cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_ASM_FLAGS=-Wa,--noexecstack \ -GNinja .. ninjamacOS Note: You must build separate libraries for x86 and ARM architectures.
x86_64 version:
mkdir build.x86 cd build.x86 cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_ASM_FLAGS=-Wa,--noexecstack \ -DCMAKE_OSX_ARCHITECTURES=x86_64 \ -GNinja .. ninjaarm64 version:
mkdir build.arm cd build.arm cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_ASM_FLAGS=-Wa,--noexecstack \ -DCMAKE_OSX_ARCHITECTURES=arm64 \ -GNinja .. ninjaWindows (64-bit) Requires Microsoft Visual Studio 2017 with Windows 8.1 and 10 SDKs. 32-bit mode is not supported.
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 mkdir build64 cd build64 cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ^ -DCMAKE_BUILD_TYPE=Release ^ -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^ -GNinja .. ninjaUse the Conscrypt OpenJDK Uber JAR
masterIf you want to simplify dependency management and avoid platform-specific classifiers, you can use the
conscrypt-openjdk-uberartifact. This Uber JAR contains the shared libraries for all published platforms. Note that the JAR size will be larger than the platform-specific version.##### Maven ```xml <dependency> <groupId>org.conscrypt</groupId> <artifactId>conscrypt-openjdk-uber</artifactId> <version>2.6.0</version> </dependency>Gradle
dependencies { compile 'org.conscrypt:conscrypt-openjdk-uber:2.6.0' }