Merge "Convert external/bouncycastle to Android.bp" am: ffde9798cb
am: af1b6933e8
Change-Id: I8529a4da1bdd88bb93844a7a980c65f47ddb25a1
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..cc4d4a6
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,163 @@
+//
+// Copyright (C) 2010 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// These cannot build in the PDK, because the PDK requires all libraries
+// compile against SDK versions.
+java_defaults {
+ name: "bouncycastle-defaults",
+ host_supported: true,
+ hostdex: true,
+ target: {
+ android: {
+ product_variables: {
+ pdk: {
+ enabled: false,
+ },
+ },
+ },
+ },
+}
+
+// non-jarjar version to build okhttp-tests
+java_library_static {
+ name: "bouncycastle-nojarjar",
+ defaults: ["bouncycastle-defaults"],
+
+ srcs: ["bcprov/src/main/java/**/*.java"],
+ exclude_srcs: [
+ "bcprov/src/main/java/org/bouncycastle/asn1/ocsp/**/*.java",
+ ],
+
+ target: {
+ android: {
+ // used for bouncycastle for target where we want to be sure to use OpenSSLDigest
+ exclude_srcs: [
+ "bcprov/src/main/java/org/bouncycastle/crypto/digests/AndroidDigestFactoryBouncyCastle.java",
+ ],
+ },
+ host: {
+ // used for bouncycastle for host where we can't use OpenSSLDigest
+ exclude_srcs: [
+ "bcprov/src/main/java/org/bouncycastle/crypto/digests/AndroidDigestFactoryOpenSSL.java",
+ "bcprov/src/main/java/org/bouncycastle/crypto/digests/OpenSSLDigest.java",
+ ],
+ },
+ },
+ libs: ["conscrypt"],
+ no_framework_libs: true,
+ java_version: "1.7",
+}
+
+java_library {
+ name: "bouncycastle",
+ defaults: ["bouncycastle-defaults"],
+
+ static_libs: ["bouncycastle-nojarjar"],
+ libs: ["conscrypt"],
+ no_framework_libs: true,
+ java_version: "1.7",
+
+ target: {
+ android: {
+ jarjar_rules: "jarjar-rules.txt",
+ },
+ },
+}
+
+// A guaranteed unstripped version of bouncycastle.
+// The build system may or may not strip the bouncycastle jar, but this one will
+// not be stripped. See b/24535627.
+java_library {
+ name: "bouncycastle-testdex",
+
+ static_libs: ["bouncycastle-nojarjar"],
+ libs: ["conscrypt"],
+ no_framework_libs: true,
+ jarjar_rules: "jarjar-rules.txt",
+ java_version: "1.7",
+}
+
+// unbundled bouncycastle jar
+java_library_static {
+ name: "bouncycastle-unbundled",
+
+ sdk_version: "9",
+ srcs: ["bcprov/src/main/java/**/*.java"],
+ exclude_srcs: [
+ "bcprov/src/main/java/org/bouncycastle/asn1/ocsp/**/*.java",
+ "bcprov/src/main/java/org/bouncycastle/crypto/digests/AndroidDigestFactoryOpenSSL.java",
+ "bcprov/src/main/java/org/bouncycastle/crypto/digests/OpenSSLDigest.java",
+ ],
+}
+
+// PKIX classes used for testing
+java_library_static {
+ name: "bouncycastle-bcpkix-nojarjar",
+ defaults: ["bouncycastle-defaults"],
+
+ srcs: ["bcpkix/src/main/java/**/*.java"],
+ exclude_srcs: ["bcpkix/src/main/java/org/bouncycastle/cert/ocsp/**/*.java"],
+ no_framework_libs: true,
+ libs: [
+ "bouncycastle-nojarjar",
+ "conscrypt",
+ ],
+}
+
+java_library_static {
+ name: "bouncycastle-bcpkix",
+ defaults: ["bouncycastle-defaults"],
+
+ static_libs: ["bouncycastle-bcpkix-nojarjar"],
+ libs: ["conscrypt"],
+ no_framework_libs: true,
+
+ target: {
+ android: {
+ jarjar_rules: "jarjar-rules.txt",
+ },
+ },
+}
+
+// OCSP classes used for testing
+java_library_static {
+ name: "bouncycastle-ocsp",
+ defaults: ["bouncycastle-defaults"],
+
+ srcs: [
+ "bcpkix/src/main/java/org/bouncycastle/cert/ocsp/**/*.java",
+ "bcprov/src/main/java/org/bouncycastle/asn1/ocsp/**/*.java",
+ ],
+ libs: [
+ "bouncycastle-nojarjar",
+ "bouncycastle-bcpkix-nojarjar",
+ "conscrypt",
+ ],
+ jarjar_rules: "jarjar-rules.txt",
+ java_version: "1.7",
+ no_framework_libs: true,
+}
+
+// For compatibilityy with old bouncycastle-host and bouncycastle-bcpkix-host names
+java_library_host {
+ name: "bouncycastle-host",
+ static_libs: ["bouncycastle"],
+}
+
+java_library_host {
+ name: "bouncycastle-bcpkix-host",
+ static_libs: ["bouncycastle-bcpkix"],
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index d8b6763..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,233 +0,0 @@
-#
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-
-# All the files needed for OCSP testing
-all_bc_ocsp_files := $(call all-java-files-under,bcpkix/src/main/java/org/bouncycastle/cert/ocsp) \
- $(call all-java-files-under,bcprov/src/main/java/org/bouncycastle/asn1/ocsp)
-
-# used for bouncycastle-hostdex where we want everything for testing
-all_bcprov_src_files := $(filter-out \
- $(all_bc_ocsp_files), \
- $(call all-java-files-under,bcprov/src/main/java))
-
-# used for bouncycastle for target where we want to be sure to use OpenSSLDigest
-android_bcprov_src_files := $(filter-out \
- bcprov/src/main/java/org/bouncycastle/crypto/digests/AndroidDigestFactoryBouncyCastle.java, \
- $(all_bcprov_src_files))
-
-# used for bouncycastle-host where we can't use OpenSSLDigest
-ri_bcprov_src_files := $(filter-out \
- bcprov/src/main/java/org/bouncycastle/crypto/digests/AndroidDigestFactoryOpenSSL.java \
- bcprov/src/main/java/org/bouncycastle/crypto/digests/OpenSSLDigest.java, \
- $(all_bcprov_src_files))
-
-# used for host tools, but OCSP is only for testing
-all_bcpkix_src_files := $(filter-out \
- $(all_bc_ocsp_files), \
- $(call all-java-files-under,bcpkix/src/main/java))
-
-# These cannot build in the PDK, because the PDK requires all libraries
-# compile against SDK versions. LOCAL_NO_STANDARD_LIBRARIES conflicts with
-# this requirement.
-ifneq ($(TARGET_BUILD_PDK),true)
-
- # non-jarjar version to build okhttp-tests
- include $(CLEAR_VARS)
- LOCAL_MODULE := bouncycastle-nojarjar
- LOCAL_MODULE_TAGS := optional
- LOCAL_SRC_FILES := $(android_bcprov_src_files)
- LOCAL_JAVA_LIBRARIES := core-oj core-libart conscrypt
- LOCAL_NO_STANDARD_LIBRARIES := true
- LOCAL_JAVA_LANGUAGE_VERSION := 1.7
- include $(BUILD_STATIC_JAVA_LIBRARY)
-
- include $(CLEAR_VARS)
- LOCAL_MODULE := bouncycastle
- LOCAL_MODULE_TAGS := optional
- LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle-nojarjar
- LOCAL_JAVA_LIBRARIES := core-oj core-libart conscrypt
- LOCAL_NO_STANDARD_LIBRARIES := true
- LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
- LOCAL_JAVA_LANGUAGE_VERSION := 1.7
- include $(BUILD_JAVA_LIBRARY)
-
- # A guaranteed unstripped version of bouncycastle.
- # The build system may or may not strip the bouncycastle jar, but this one will
- # not be stripped. See b/24535627.
- include $(CLEAR_VARS)
- LOCAL_MODULE := bouncycastle-testdex
- LOCAL_MODULE_TAGS := optional
- LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle-nojarjar
- LOCAL_JAVA_LIBRARIES := core-oj core-libart conscrypt
- LOCAL_NO_STANDARD_LIBRARIES := true
- LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
- LOCAL_JAVA_LANGUAGE_VERSION := 1.7
- include $(BUILD_JAVA_LIBRARY)
-
- # unbundled bouncycastle jar
- include $(CLEAR_VARS)
- LOCAL_MODULE := bouncycastle-unbundled
- LOCAL_MODULE_TAGS := optional
- LOCAL_SDK_VERSION := 9
- LOCAL_SRC_FILES := $(ri_bcprov_src_files)
- include $(BUILD_STATIC_JAVA_LIBRARY)
-
- # PKIX classes used for testing
- include $(CLEAR_VARS)
- LOCAL_MODULE := bouncycastle-bcpkix-nojarjar
- LOCAL_MODULE_TAGS := optional
- LOCAL_SRC_FILES := $(all_bcpkix_src_files)
- LOCAL_NO_STANDARD_LIBRARIES := true
- LOCAL_JAVA_LIBRARIES := bouncycastle-nojarjar core-oj core-libart conscrypt
- include $(BUILD_STATIC_JAVA_LIBRARY)
-
- include $(CLEAR_VARS)
- LOCAL_MODULE := bouncycastle-bcpkix
- LOCAL_MODULE_TAGS := optional
- LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle-bcpkix-nojarjar
- LOCAL_JAVA_LIBRARIES := core-oj core-libart conscrypt
- LOCAL_NO_STANDARD_LIBRARIES := true
- LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
- include $(BUILD_STATIC_JAVA_LIBRARY)
-
- # OCSP classes used for testing
- include $(CLEAR_VARS)
- LOCAL_MODULE := bouncycastle-ocsp
- LOCAL_MODULE_TAGS := optional
- LOCAL_SRC_FILES := $(all_bc_ocsp_files)
- LOCAL_JAVA_LIBRARIES := bouncycastle-nojarjar bouncycastle-bcpkix-nojarjar core-oj core-libart conscrypt
- LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
- LOCAL_JAVA_LANGUAGE_VERSION := 1.7
- LOCAL_NO_STANDARD_LIBRARIES := true
- include $(BUILD_STATIC_JAVA_LIBRARY)
-endif # TARGET_BUILD_PDK != true
-
-# This is used to generate a list of what is unused so it can be removed when bouncycastle is updated.
-# Based on "Finding dead code" example in ProGuard manual at http://proguard.sourceforge.net/
-.PHONY: bouncycastle-proguard-deadcode
-bouncycastle-proguard-deadcode: $(full_classes_compiled_jar) $(full_java_libs)
- $(PROGUARD) \
- -injars $(full_classes_compiled_jar) \
- -libraryjars "$(call normalize-path-list,$(addsuffix (!org/bouncycastle/**.class,!com/android/org/conscrypt/OpenSSLMessageDigest.class),$(full_java_libs)))" \
- -dontoptimize \
- -dontobfuscate \
- -dontpreverify \
- -ignorewarnings \
- -printusage \
- -keep class org.bouncycastle.jce.provider.BouncyCastleProvider "{ public protected *; }" \
- -keep class org.bouncycastle.jce.provider.symmetric.AESMappings "{ public protected *; }" \
- -keep class org.bouncycastle.asn1.ASN1TaggedObject "{ public protected *; }" \
- -keep class org.bouncycastle.asn1.x509.CertificateList "{ public protected *; }" \
- -keep class org.bouncycastle.crypto.AsymmetricBlockCipher "{ public protected *; }" \
- -keep class org.bouncycastle.x509.ExtendedPKIXBuilderParameters "{ public protected *; }" \
- `(find $(LOCAL_PATH) -name '*.java' | xargs grep '"org.bouncycastle' | egrep ' (put|add)' | sed -e 's/");//' -e 's/.*"//'; \
- find $(LOCAL_PATH) -name '*.java' | xargs grep ' addHMACAlgorithm' | sed 's/"org.bouncycastle/\norg.bouncycastle/g' | grep ^org.bouncycastle | sed 's/".*//'; \
- find . -name '*.java' | xargs grep 'import org.bouncycastle' | grep -v /bouncycastle/ | sed -e 's/.*:import //' -e 's/;//') \
- | sed -e 's/^/-keep class /' -e 's/$$/ { public protected \*; } /' | sort | uniq` \
- -keepclassmembers "class * { \
- static final % *; \
- static final java.lang.String *; \
- }" \
- -keepclassmembers "class * implements java.io.Serializable { \
- private static final java.io.ObjectStreamField[] serialPersistentFields; \
- private void writeObject(java.io.ObjectOutputStream); \
- private void readObject(java.io.ObjectInputStream); \
- java.lang.Object writeReplace(); \
- java.lang.Object readResolve(); \
- }" \
- -keepclassmembers "interface org.bouncycastle.crypto.paddings.BlockCipherPadding { \
- abstract public java.lang.String getPaddingName(); \
- }" \
- -keepclassmembers "class * implements org.bouncycastle.crypto.paddings.BlockCipherPadding { \
- public java.lang.String getPaddingName(); \
- }"
-
-# Conscrypt isn't built in the PDK or on non-linux OSes, so this cannot be built
-# because it has a dependency on conscrypt-hostdex.
-ifneq ($(TARGET_BUILD_PDK),true)
- ifeq ($(HOST_OS),linux)
- include $(CLEAR_VARS)
- LOCAL_MODULE := bouncycastle-hostdex-nojarjar
- LOCAL_MODULE_TAGS := optional
- LOCAL_SRC_FILES := $(all_bcprov_src_files)
- LOCAL_JAVA_LIBRARIES := conscrypt-hostdex
- include $(BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY)
-
- include $(CLEAR_VARS)
- LOCAL_MODULE := bouncycastle-hostdex
- LOCAL_MODULE_TAGS := optional
- LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle-hostdex-nojarjar
- LOCAL_JAVA_LIBRARIES := conscrypt-hostdex
- LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
- LOCAL_JAVA_LANGUAGE_VERSION := 1.7
- include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
-
- include $(CLEAR_VARS)
- LOCAL_MODULE := bouncycastle-bcpkix-hostdex-nojarjar
- LOCAL_MODULE_TAGS := optional
- LOCAL_SRC_FILES := $(all_bcpkix_src_files)
- LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle-hostdex-nojarjar
- include $(BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY)
-
- include $(CLEAR_VARS)
- LOCAL_MODULE := bouncycastle-bcpkix-hostdex
- LOCAL_MODULE_TAGS := optional
- LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle-bcpkix-hostdex-nojarjar
- LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle-hostdex-nojarjar
- LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
- include $(BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY)
-
- # OCSP classes used for testing
- include $(CLEAR_VARS)
- LOCAL_MODULE := bouncycastle-ocsp-hostdex
- LOCAL_MODULE_TAGS := optional
- LOCAL_SRC_FILES := $(all_bc_ocsp_files)
- LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle-hostdex-nojarjar bouncycastle-bcpkix-hostdex-nojarjar
- LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
- include $(BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY)
- endif # ($(HOST_OS),linux)
-endif
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := bouncycastle-host
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(ri_bcprov_src_files)
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := bouncycastle-bcpkix-host
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(all_bcpkix_src_files)
-LOCAL_JAVA_LIBRARIES := bouncycastle-host
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# OCSP classes used for testing
-include $(CLEAR_VARS)
-LOCAL_MODULE := bouncycastle-ocsp-host
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(all_bc_ocsp_files)
-LOCAL_JAVA_LIBRARIES := bouncycastle-host bouncycastle-bcpkix-host
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Unset these so they don't linger in the next makefile
-all_bcprov_src_files :=
-android_bcprov_src_files :=
-ri_bcprov_src_files :=
-all_bcpkix_src_files :=
-all_bc_ocsp_files :=