• 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        "//libcore:__subpackages__",
93        "//packages/modules/ArtPrebuilt",
94    ],
95    apex_available: [
96        "com.android.art",
97        "com.android.art.debug",
98    ],
99    min_sdk_version: "31",
100    defaults: ["bouncycastle-defaults"],
101    installable: true,
102
103    srcs: [":bouncycastle_java_files"],
104
105    libs: ["unsupportedappusage"],
106
107    optimize: {
108        enabled: true,
109        shrink: true,
110        optimize: true,
111        obfuscate: false,
112        proguard_compatibility: false,
113        ignore_warnings: false,
114        proguard_flags_files: ["proguard.flags"],
115    },
116
117    sdk_version: "none",
118    system_modules: "art-module-intra-core-api-stubs-system-modules",
119}
120
121java_library_static {
122    name: "bouncycastle-test-lib",
123    visibility: [
124        "//packages/modules/ArtPrebuilt",
125        "//external/bouncycastle/mts",
126    ],
127    srcs: [
128        "repackaged/bcprov/src/test/java/**/*.java",
129    ],
130    libs: ["bouncycastle"],
131    static_libs: [
132        "junit",
133        "platform-test-annotations",
134    ],
135    sdk_version: "none",
136    system_modules: "art-module-intra-core-api-stubs-system-modules",
137}
138
139// A bouncycastle library repackaged in com.android.internal.org.bouncycastle
140// for use in the Android platform where it is important not to conflict with
141// the original org.bouncycastle package or the one in the ART module.
142java_library {
143    name: "bouncycastle-repackaged-unbundled",
144    visibility: [
145        "//cts/tests/libcore/wycheproof-bc",
146        "//external/sl4a/Common",
147        "//external/wycheproof",
148        "//frameworks/base",
149        "//frameworks/base/packages/Connectivity/tests/unit",
150        "//frameworks/base/tests/net",
151        "//packages/modules/Connectivity/tests/unit",
152    ],
153    defaults: ["bouncycastle-defaults"],
154    installable: true,
155    sdk_version: "core_current",
156    srcs: [
157        "repackaged_platform/bcpkix/src/main/java/**/*.java",
158        "repackaged_platform/bcprov/src/main/java/**/*.java",
159    ],
160}
161
162unbundled_visibility = [
163    "//art/build/sdk",
164    "//build/make/tools/signapk",
165    "//build/make/tools/signtos",
166    "//cts/hostsidetests/devicepolicy/app/DeviceOwner",
167    "//cts/tests/libcore/okhttp",
168    "//cts/tests/security",
169    "//cts/tests/tests/keystore",
170    "//external/android-key-attestation",
171    "//external/conscrypt",
172    "//external/okhttp",
173    "//external/robolectric-shadows",
174    "//external/robolectric-shadows/robolectric",
175    "//external/robolectric-shadows/shadows/supportv4",
176    "//external/robolectric-shadows/shadows/httpclient",
177    "//external/robolectric",
178    "//external/robolectric/robolectric",
179    "//external/robolectric/shadows/supportv4",
180    "//external/robolectric/shadows/httpclient",
181    "//external/wycheproof",
182    "//frameworks/opt/net/wifi/service",
183    "//frameworks/opt/net/wifi/tests/wifitests",
184    "//packages/apps/CertInstaller",
185    "//packages/apps/KeyChain",
186    "//packages/apps/RemoteProvisioner/tests/unittests",
187    "//packages/modules/Connectivity/tests/cts/net",
188    "//packages/modules/RemoteKeyProvisioning/app/tests/unit",
189    "//packages/modules/Virtualization/service_vm/test_apk",
190    "//packages/modules/Wifi/service",
191    "//packages/modules/Wifi/service/tests/wifitests",
192    "//libcore",
193    "//system/extras/verity",
194    "//system/security/identity/util",
195    "//tools/apksig",
196    "//tools/security/remote_provisioning/attestation_testing",
197    "//vendor:__subpackages__",
198]
199
200// A bouncycastle library in the original org.bouncycastle package for use
201// outside of the platform. e.g. for host or in unbundled apps.
202java_library {
203    name: "bouncycastle-unbundled",
204    visibility: unbundled_visibility,
205    defaults: ["bouncycastle-defaults"],
206    host_supported: true,
207
208    srcs: ["bcprov/src/main/java/**/*.java"],
209    exclude_srcs: [
210        "bcprov/src/main/java/org/bouncycastle/asn1/ocsp/**/*.java",
211    ],
212
213    sdk_version: "core_current",
214    min_sdk_version: "30",
215    java_version: "1.7",
216    apex_available: ["com.android.wifi"],
217}
218
219// Bouncycastle PKIX classes in the original org.bouncycastle package for use
220// outside of the platform. e.g. for host or in unbundled apps / CTS tests.
221java_library {
222    name: "bouncycastle-bcpkix-unbundled",
223    visibility: unbundled_visibility,
224    defaults: ["bouncycastle-defaults"],
225    host_supported: true,
226
227    srcs: ["bcpkix/src/main/java/**/*.java"],
228    exclude_srcs: ["bcpkix/src/main/java/org/bouncycastle/cert/ocsp/**/*.java"],
229    libs: ["bouncycastle-unbundled"],
230
231    sdk_version: "core_current",
232    // b/267608166: Allow to be used by components targeting Java 11.
233    java_version: "11",
234}
235
236// Bouncycastle OCSP classes in the original org.bouncycastle package for use
237// outside of the platform. e.g. for host or in unbundled apps / CTS tests.
238java_library_static {
239    name: "bouncycastle-ocsp-unbundled",
240    visibility: unbundled_visibility,
241    defaults: ["bouncycastle-defaults"],
242    host_supported: true,
243
244    srcs: [
245        "bcpkix/src/main/java/org/bouncycastle/cert/ocsp/**/*.java",
246        "bcprov/src/main/java/org/bouncycastle/asn1/ocsp/**/*.java",
247    ],
248    libs: [
249        "bouncycastle-unbundled",
250        "bouncycastle-bcpkix-unbundled",
251    ],
252
253    sdk_version: "core_current",
254}
255
256// For compatibility with old bouncycastle-host name.
257//
258// When converting .mk files to .bp files do not change the visibility of this
259// module, instead replace usages of this with bouncycastle-unbundled.
260java_library_host {
261    name: "bouncycastle-host",
262    static_libs: ["bouncycastle-unbundled"],
263}
264
265java_test_host {
266    name: "bouncycastle-host-tests",
267    srcs: [
268        "bcprov/src/test/java/**/*.java",
269    ],
270    static_libs: [
271        "bouncycastle-unbundled",
272        "junit",
273        "platform-test-annotations",
274    ],
275    test_options: {
276        unit_test: true,
277    },
278    test_suites: ["general-tests"],
279}
280
281// Bouncycastle subset for use by frameworks/opt/net/ike project.
282//
283// Avoids including the whole of bouncycastle_unbundled in ike.
284//
285// Specifically, SHA1Digest and MD4Digest (and their dependencies) must be used by IKEv2 to support
286// legacy authentication methods.
287java_library {
288    name: "bouncycastle_ike_digests",
289    visibility: [
290        "//art/build/sdk",
291        "//packages/modules/IPsec",
292    ],
293    apex_available: [
294        "com.android.ipsec",
295        "test_com.android.ipsec",
296    ],
297    srcs: [
298        "bcprov/src/main/java/org/bouncycastle/crypto/Digest.java",
299        "bcprov/src/main/java/org/bouncycastle/crypto/ExtendedDigest.java",
300        "bcprov/src/main/java/org/bouncycastle/crypto/digests/EncodableDigest.java",
301        "bcprov/src/main/java/org/bouncycastle/crypto/digests/GeneralDigest.java",
302        "bcprov/src/main/java/org/bouncycastle/crypto/digests/MD4Digest.java",
303        "bcprov/src/main/java/org/bouncycastle/crypto/digests/SHA1Digest.java",
304        "bcprov/src/main/java/org/bouncycastle/util/Memoable.java",
305        "bcprov/src/main/java/org/bouncycastle/util/Pack.java",
306    ],
307    sdk_version: "core_current",
308}
309
310// Bouncycastle for use by packages/modules/ExtServices project.
311//
312// Excludes directories not needed for ASN1*.java and X509* sources.
313//
314java_library {
315    name: "bouncycastle-extservices-asn",
316    visibility: [
317        "//packages/modules/ExtServices",
318    ],
319    apex_available: [
320        "com.android.extservices",
321        "test_com.android.extservices",
322    ],
323    srcs: [
324        "bcprov/src/main/java/org/bouncycastle/**/*.java",
325    ],
326    exclude_srcs: [
327        "bcprov/src/main/java/org/bouncycastle/asn1/ocsp/**/*.java",
328        "bcprov/src/main/java/org/bouncycastle/iana/**/*.java",
329    ],
330    sdk_version: "core_current",
331    lint: {
332        warning_checks: ["SuspiciousIndentation"],
333    },
334}
335
336// Bouncycastle for use by packages/modules/Uwb project.
337//
338//Excludes directories not needed.
339java_library {
340    name: "bouncycastle-uwb",
341    defaults: ["bouncycastle-errorprone-defaults"],
342    visibility: [
343        "//packages/modules/Uwb/service",
344    ],
345    apex_available: [
346        "com.android.uwb",
347    ],
348    srcs: [
349        "bcprov/src/main/java/org/bouncycastle/**/*.java",
350        "bcpkix/src/main/java/org/bouncycastle/cert/**/*.java",
351        "bcpkix/src/main/java/org/bouncycastle/cms/**/*.java",
352        "bcpkix/src/main/java/org/bouncycastle/operator/**/*.java",
353    ],
354
355    exclude_srcs: [
356        "bcprov/src/main/java/org/bouncycastle/iana/**/*.java",
357        "bcprov/src/main/java/org/bouncycastle/its/**/*.java",
358    ],
359    sdk_version: "core_current",
360    lint: {
361        warning_checks: ["SuspiciousIndentation"],
362    },
363}
364