• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2010 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
17package {
18    default_visibility: ["//visibility:private"],
19    default_applicable_licenses: ["external_bouncycastle_license"],
20}
21
22// Added automatically by a large-scale-change that took the approach of
23// 'apply every license found to every target'. While this makes sure we respect
24// every license restriction, it may not be entirely correct.
25//
26// e.g. GPL in an MIT project might only apply to the contrib/ directory.
27//
28// Please consider splitting the single license below into multiple licenses,
29// taking care not to lose any license_kind information, and overriding the
30// default license using the 'licenses: [...]' property on targets as needed.
31//
32// For unused files, consider creating a 'fileGroup' with "//visibility:private"
33// to attach the license to, and including a comment whether the files may be
34// used in the current project.
35// See: http://go/android-license-faq
36license {
37    name: "external_bouncycastle_license",
38    visibility: [":__subpackages__"],
39    license_kinds: [
40        "SPDX-license-identifier-Apache-2.0",
41        "SPDX-license-identifier-BSD",
42        "SPDX-license-identifier-MIT",
43    ],
44    license_text: [
45        "NOTICE",
46    ],
47}
48
49java_defaults {
50    name: "bouncycastle-errorprone-defaults",
51    errorprone: {
52        javacflags: [
53            "-Xep:MissingOverride:OFF", // Ignore missing @Override.
54            "-Xep:BoxedPrimitiveEquality:WARN",
55            "-Xep:DoubleBraceInitialization:WARN",
56            "-Xep:HashtableContains:WARN",
57        ],
58    },
59}
60
61java_defaults {
62    name: "bouncycastle-defaults",
63    defaults: [
64        "bouncycastle-errorprone-defaults",
65    ],
66    hostdex: true,
67
68    lint: {
69        warning_checks: ["SuspiciousIndentation"],
70    },
71}
72
73// The src files for bouncycastle, used to generate core platform / intra-core
74// API stubs.
75filegroup {
76    name: "bouncycastle_java_files",
77    visibility: [
78        "//libcore",
79    ],
80    srcs: ["repackaged/bcprov/src/main/java/**/*.java"],
81}
82
83// A bouncycastle library repackaged in com.android.org.bouncycastle for use
84// in the ART module. Repackaging is needed to avoid conflict with the
85// original org.bouncycastle package.
86java_library {
87    name: "bouncycastle",
88    // Restrict visibility to only those targets that need to access it.
89    visibility: [
90        "//art/build/apex",
91        "//art/build/sdk",
92        "//art/tools/ahat",
93        "//art/tools/fuzzer",
94        "//libcore:__subpackages__",
95        "//packages/modules/ArtPrebuilt",
96    ],
97    apex_available: [
98        "com.android.art",
99        "com.android.art.debug",
100    ],
101    min_sdk_version: "31",
102    defaults: ["bouncycastle-defaults"],
103    installable: true,
104
105    srcs: [":bouncycastle_java_files"],
106
107    libs: ["unsupportedappusage"],
108
109    optimize: {
110        enabled: true,
111        shrink: true,
112        optimize: false,
113        obfuscate: false,
114        proguard_compatibility: false,
115        ignore_warnings: false,
116        proguard_flags_files: ["proguard.flags"],
117    },
118
119    sdk_version: "none",
120    system_modules: "art-module-intra-core-api-stubs-system-modules",
121}
122
123java_library_static {
124    name: "bouncycastle-test-lib",
125    visibility: [
126        "//packages/modules/ArtPrebuilt",
127        "//external/bouncycastle/mts",
128    ],
129    srcs: [
130        "repackaged/bcprov/src/test/java/**/*.java",
131    ],
132    libs: ["bouncycastle"],
133    static_libs: [
134        "junit",
135        "platform-test-annotations",
136    ],
137    sdk_version: "none",
138    system_modules: "art-module-intra-core-api-stubs-system-modules",
139}
140
141// A bouncycastle library repackaged in com.android.internal.org.bouncycastle
142// for use in the Android platform where it is important not to conflict with
143// the original org.bouncycastle package or the one in the ART module.
144java_library {
145    name: "bouncycastle-repackaged-unbundled",
146    visibility: [
147        "//cts/tests/libcore/wycheproof-bc",
148        "//external/sl4a/Common",
149        "//external/wycheproof",
150        "//frameworks/base",
151        "//frameworks/base/packages/Connectivity/tests/unit",
152        "//frameworks/base/tests/net",
153        "//packages/modules/Connectivity/tests/unit",
154    ],
155    defaults: ["bouncycastle-defaults"],
156    installable: true,
157    sdk_version: "core_current",
158    srcs: [
159        "repackaged_platform/bcpkix/src/main/java/**/*.java",
160        "repackaged_platform/bcprov/src/main/java/**/*.java",
161    ],
162}
163
164unbundled_visibility = [
165    "//art/build/sdk",
166    "//build/make/tools/signapk",
167    "//build/make/tools/signtos",
168    "//cts/hostsidetests/devicepolicy/app/DeviceOwner",
169    "//cts/tests/libcore/okhttp",
170    "//cts/tests/security",
171    "//cts/tests/tests/keystore",
172    "//external/android-key-attestation",
173    "//external/conscrypt",
174    "//external/okhttp",
175    "//external/robolectric-shadows",
176    "//external/robolectric-shadows/robolectric",
177    "//external/robolectric-shadows/shadows/supportv4",
178    "//external/robolectric-shadows/shadows/httpclient",
179    "//external/robolectric",
180    "//external/robolectric/robolectric",
181    "//external/robolectric/shadows/supportv4",
182    "//external/robolectric/shadows/httpclient",
183    "//external/wycheproof",
184    "//frameworks/opt/net/wifi/service",
185    "//frameworks/opt/net/wifi/tests/wifitests",
186    "//packages/apps/CertInstaller",
187    "//packages/apps/KeyChain",
188    "//packages/apps/RemoteProvisioner/tests/unittests",
189    "//packages/modules/Connectivity/tests/cts/net",
190    "//packages/modules/RemoteKeyProvisioning/app/tests/unit",
191    "//packages/modules/Virtualization/tests/vm_attestation",
192    "//packages/modules/Wifi/service",
193    "//packages/modules/Wifi/service/tests/wifitests",
194    "//libcore",
195    "//system/extras/verity",
196    "//system/security/identity/util",
197    "//tools/apksig",
198    "//tools/security/remote_provisioning/attestation_testing",
199    "//vendor:__subpackages__",
200]
201
202// A bouncycastle library in the original org.bouncycastle package for use
203// outside of the platform. e.g. for host or in unbundled apps.
204java_library {
205    name: "bouncycastle-unbundled",
206    visibility: unbundled_visibility,
207    defaults: ["bouncycastle-defaults"],
208    host_supported: true,
209
210    srcs: ["bcprov/src/main/java/**/*.java"],
211    exclude_srcs: [
212        "bcprov/src/main/java/org/bouncycastle/asn1/ocsp/**/*.java",
213    ],
214
215    sdk_version: "core_current",
216    min_sdk_version: "30",
217    java_version: "1.7",
218    apex_available: ["com.android.wifi"],
219}
220
221// Bouncycastle PKIX classes in the original org.bouncycastle package for use
222// outside of the platform. e.g. for host or in unbundled apps / CTS tests.
223java_library {
224    name: "bouncycastle-bcpkix-unbundled",
225    visibility: unbundled_visibility,
226    defaults: ["bouncycastle-defaults"],
227    host_supported: true,
228
229    srcs: ["bcpkix/src/main/java/**/*.java"],
230    exclude_srcs: ["bcpkix/src/main/java/org/bouncycastle/cert/ocsp/**/*.java"],
231    libs: ["bouncycastle-unbundled"],
232
233    sdk_version: "core_current",
234    // b/267608166: Allow to be used by components targeting Java 11.
235    java_version: "11",
236}
237
238// Bouncycastle OCSP classes in the original org.bouncycastle package for use
239// outside of the platform. e.g. for host or in unbundled apps / CTS tests.
240java_library_static {
241    name: "bouncycastle-ocsp-unbundled",
242    visibility: unbundled_visibility,
243    defaults: ["bouncycastle-defaults"],
244    host_supported: true,
245
246    srcs: [
247        "bcpkix/src/main/java/org/bouncycastle/cert/ocsp/**/*.java",
248        "bcprov/src/main/java/org/bouncycastle/asn1/ocsp/**/*.java",
249    ],
250    libs: [
251        "bouncycastle-unbundled",
252        "bouncycastle-bcpkix-unbundled",
253    ],
254
255    sdk_version: "core_current",
256}
257
258// For compatibility with old bouncycastle-host name.
259//
260// When converting .mk files to .bp files do not change the visibility of this
261// module, instead replace usages of this with bouncycastle-unbundled.
262java_library_host {
263    name: "bouncycastle-host",
264    static_libs: ["bouncycastle-unbundled"],
265}
266
267java_test_host {
268    name: "bouncycastle-host-tests",
269    srcs: [
270        "bcprov/src/test/java/**/*.java",
271    ],
272    static_libs: [
273        "bouncycastle-unbundled",
274        "junit",
275        "platform-test-annotations",
276    ],
277    test_options: {
278        unit_test: true,
279    },
280    test_suites: ["general-tests"],
281}
282
283// Bouncycastle subset for use by frameworks/opt/net/ike project.
284//
285// Avoids including the whole of bouncycastle_unbundled in ike.
286//
287// Specifically, SHA1Digest and MD4Digest (and their dependencies) must be used by IKEv2 to support
288// legacy authentication methods.
289java_library {
290    name: "bouncycastle_ike_digests",
291    visibility: [
292        "//art/build/sdk",
293        "//packages/modules/IPsec",
294    ],
295    apex_available: [
296        "com.android.ipsec",
297        "test_com.android.ipsec",
298    ],
299    srcs: [
300        "bcprov/src/main/java/org/bouncycastle/crypto/Digest.java",
301        "bcprov/src/main/java/org/bouncycastle/crypto/ExtendedDigest.java",
302        "bcprov/src/main/java/org/bouncycastle/crypto/digests/EncodableDigest.java",
303        "bcprov/src/main/java/org/bouncycastle/crypto/digests/GeneralDigest.java",
304        "bcprov/src/main/java/org/bouncycastle/crypto/digests/MD4Digest.java",
305        "bcprov/src/main/java/org/bouncycastle/crypto/digests/SHA1Digest.java",
306        "bcprov/src/main/java/org/bouncycastle/util/Memoable.java",
307        "bcprov/src/main/java/org/bouncycastle/util/Pack.java",
308    ],
309    sdk_version: "core_current",
310}
311
312// Bouncycastle for use by packages/modules/ExtServices project.
313//
314// Excludes directories not needed for ASN1*.java and X509* sources.
315//
316java_library {
317    name: "bouncycastle-extservices-asn",
318    visibility: [
319        "//packages/modules/ExtServices",
320    ],
321    apex_available: [
322        "com.android.extservices",
323        "test_com.android.extservices",
324    ],
325    srcs: [
326        "bcprov/src/main/java/org/bouncycastle/**/*.java",
327    ],
328    exclude_srcs: [
329        "bcprov/src/main/java/org/bouncycastle/asn1/ocsp/**/*.java",
330        "bcprov/src/main/java/org/bouncycastle/iana/**/*.java",
331    ],
332    sdk_version: "core_current",
333    lint: {
334        warning_checks: ["SuspiciousIndentation"],
335    },
336}
337
338// Bouncycastle for use by packages/modules/Uwb project.
339//
340//Excludes directories not needed.
341java_library {
342    name: "bouncycastle-uwb",
343    defaults: ["bouncycastle-errorprone-defaults"],
344    visibility: [
345        "//packages/modules/Uwb/service",
346    ],
347    apex_available: [
348        "com.android.uwb",
349    ],
350    srcs: [
351        "bcprov/src/main/java/org/bouncycastle/**/*.java",
352        "bcpkix/src/main/java/org/bouncycastle/cert/**/*.java",
353        "bcpkix/src/main/java/org/bouncycastle/cms/**/*.java",
354        "bcpkix/src/main/java/org/bouncycastle/operator/**/*.java",
355    ],
356
357    exclude_srcs: [
358        "bcprov/src/main/java/org/bouncycastle/iana/**/*.java",
359        "bcprov/src/main/java/org/bouncycastle/its/**/*.java",
360    ],
361    sdk_version: "core_current",
362    lint: {
363        warning_checks: ["SuspiciousIndentation"],
364    },
365}
366