• 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        ],
55    },
56}
57
58// These cannot build in the PDK, because the PDK requires all libraries
59// compile against SDK versions.
60java_defaults {
61    name: "bouncycastle-defaults",
62    defaults: [
63        "bouncycastle-errorprone-defaults",
64    ],
65    hostdex: true,
66    target: {
67        android: {
68            product_variables: {
69                pdk: {
70                    enabled: false,
71                },
72            },
73        },
74    },
75}
76
77// The src files for bouncycastle, used to generate core platform / intra-core
78// API stubs.
79filegroup {
80    name: "bouncycastle_java_files",
81    visibility: [
82        "//libcore",
83    ],
84    srcs: ["repackaged/bcprov/src/main/java/**/*.java"],
85}
86
87// A bouncycastle library repackaged in com.android.org.bouncycastle for use
88// in the ART module. Repackaging is needed to avoid conflict with the
89// original org.bouncycastle package.
90java_library {
91    name: "bouncycastle",
92    // Restrict visibility to only those targets that need to access it.
93    visibility: [
94        "//art/build/apex",
95        "//art/build/sdk",
96        "//external/wycheproof",
97        "//libcore",
98        "//packages/modules/ArtPrebuilt",
99    ],
100    apex_available: [
101        "com.android.art",
102        "com.android.art.debug",
103    ],
104    min_sdk_version: "31",
105    defaults: ["bouncycastle-defaults"],
106    installable: true,
107
108    srcs: [":bouncycastle_java_files"],
109
110    libs: ["unsupportedappusage"],
111
112    sdk_version: "none",
113    system_modules: "art-module-intra-core-api-stubs-system-modules",
114}
115
116// A bouncycastle library repackaged in com.android.internal.org.bouncycastle
117// for use in the Android platform where it is important not to conflict with
118// the original org.bouncycastle package or the one in the ART module.
119java_library {
120    name: "bouncycastle-repackaged-unbundled",
121    visibility: [
122        "//cts/tests/libcore/wycheproof-bc",
123        "//external/sl4a/Common",
124        "//external/wycheproof",
125        "//frameworks/base",
126        "//frameworks/base/packages/Connectivity/tests/unit",
127        "//frameworks/base/tests/net",
128        "//packages/modules/Connectivity/tests/unit",
129    ],
130    defaults: ["bouncycastle-defaults"],
131    installable: true,
132    sdk_version: "core_current",
133    srcs: ["repackaged_platform/bcprov/src/main/java/**/*.java"],
134}
135
136unbundled_visibility = [
137    "//art/build/sdk",
138    "//build/make/tools/signapk",
139    "//build/make/tools/signtos",
140    "//cts/hostsidetests/devicepolicy/app/DeviceOwner",
141    "//cts/tests/libcore/okhttp",
142    "//cts/tests/security",
143    "//cts/tests/tests/keystore",
144    "//external/conscrypt",
145    "//external/okhttp",
146    "//external/robolectric-shadows",
147    "//external/robolectric-shadows/robolectric",
148    "//external/robolectric-shadows/shadows/supportv4",
149    "//external/robolectric-shadows/shadows/httpclient",
150    "//external/robolectric",
151    "//external/robolectric/robolectric",
152    "//external/robolectric/shadows/supportv4",
153    "//external/robolectric/shadows/httpclient",
154    "//external/wycheproof",
155    "//frameworks/opt/net/wifi/service",
156    "//frameworks/opt/net/wifi/tests/wifitests",
157    "//packages/apps/CertInstaller",
158    "//packages/apps/KeyChain",
159    "//packages/apps/RemoteProvisioner/tests/unittests",
160    "//packages/modules/Connectivity/tests/cts/net",
161    "//packages/modules/Wifi/service",
162    "//packages/modules/Wifi/service/tests/wifitests",
163    "//libcore",
164    "//system/extras/verity",
165    "//system/security/identity/util",
166    "//tools/security/remote_provisioning/attestation_testing",
167    "//vendor:__subpackages__",
168]
169
170// A bouncycastle library in the original org.bouncycastle package for use
171// outside of the platform. e.g. for host or in unbundled apps.
172java_library {
173    name: "bouncycastle-unbundled",
174    visibility: unbundled_visibility,
175    defaults: ["bouncycastle-defaults"],
176    host_supported: true,
177
178    srcs: ["bcprov/src/main/java/**/*.java"],
179    exclude_srcs: [
180        "bcprov/src/main/java/org/bouncycastle/asn1/ocsp/**/*.java",
181    ],
182
183    sdk_version: "core_current",
184    min_sdk_version: "30",
185    java_version: "1.7",
186}
187
188// Bouncycastle PKIX classes in the original org.bouncycastle package for use
189// outside of the platform. e.g. for host or in unbundled apps / CTS tests.
190java_library {
191    name: "bouncycastle-bcpkix-unbundled",
192    visibility: unbundled_visibility,
193    defaults: ["bouncycastle-defaults"],
194    host_supported: true,
195
196    srcs: ["bcpkix/src/main/java/**/*.java"],
197    exclude_srcs: ["bcpkix/src/main/java/org/bouncycastle/cert/ocsp/**/*.java"],
198    libs: ["bouncycastle-unbundled"],
199
200    sdk_version: "core_current",
201}
202
203// Bouncycastle OCSP classes in the original org.bouncycastle package for use
204// outside of the platform. e.g. for host or in unbundled apps / CTS tests.
205java_library_static {
206    name: "bouncycastle-ocsp-unbundled",
207    visibility: unbundled_visibility,
208    defaults: ["bouncycastle-defaults"],
209    host_supported: true,
210
211    srcs: [
212        "bcpkix/src/main/java/org/bouncycastle/cert/ocsp/**/*.java",
213        "bcprov/src/main/java/org/bouncycastle/asn1/ocsp/**/*.java",
214    ],
215    libs: [
216        "bouncycastle-unbundled",
217        "bouncycastle-bcpkix-unbundled",
218    ],
219
220    sdk_version: "core_current",
221}
222
223// For compatibility with old bouncycastle-host name.
224//
225// When converting .mk files to .bp files do not change the visibility of this
226// module, instead replace usages of this with bouncycastle-unbundled.
227java_library_host {
228    name: "bouncycastle-host",
229    static_libs: ["bouncycastle-unbundled"],
230}
231
232// Bouncycastle subset for use by frameworks/opt/net/ike project.
233//
234// Avoids including the whole of bouncycastle_unbundled in ike.
235//
236// Specifically, SHA1Digest and MD4Digest (and their dependencies) must be used by IKEv2 to support
237// legacy authentication methods.
238java_library {
239    name: "bouncycastle_ike_digests",
240    visibility: [
241        "//art/build/sdk",
242        "//packages/modules/IPsec",
243    ],
244    apex_available: [
245        "com.android.ipsec",
246        "test_com.android.ipsec",
247    ],
248    srcs: [
249        "bcprov/src/main/java/org/bouncycastle/crypto/Digest.java",
250        "bcprov/src/main/java/org/bouncycastle/crypto/ExtendedDigest.java",
251        "bcprov/src/main/java/org/bouncycastle/crypto/digests/EncodableDigest.java",
252        "bcprov/src/main/java/org/bouncycastle/crypto/digests/GeneralDigest.java",
253        "bcprov/src/main/java/org/bouncycastle/crypto/digests/MD4Digest.java",
254        "bcprov/src/main/java/org/bouncycastle/crypto/digests/SHA1Digest.java",
255        "bcprov/src/main/java/org/bouncycastle/util/Memoable.java",
256        "bcprov/src/main/java/org/bouncycastle/util/Pack.java",
257    ],
258    sdk_version: "core_current",
259}
260
261// Bouncycastle for use by packages/modules/ExtServices project.
262//
263// Excludes directories not needed for ASN1*.java and X509* sources.
264//
265java_library {
266    name: "bouncycastle-extservices-asn",
267    visibility: [
268        "//packages/modules/ExtServices",
269    ],
270    apex_available: [
271        "com.android.extservices",
272        "test_com.android.extservices",
273    ],
274    srcs: [
275        "bcprov/src/main/java/org/bouncycastle/**/*.java",
276    ],
277    exclude_srcs: [
278        "bcprov/src/main/java/org/bouncycastle/asn1/ocsp/**/*.java",
279        "bcprov/src/main/java/org/bouncycastle/iana/**/*.java",
280    ],
281    sdk_version: "core_current",
282}
283