1/*
2 * Copyright (C) 2021 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
17// By default this device uses hardware-wrapped keys for storage encryption,
18// which is intended to offer increased security over the traditional method
19// (software keys).  However, hardware-wrapped keys aren't compatible with
20// FIPS-140 certification of the encryption hardware, and hence we have to
21// disable the use of them in FIPS mode.  This requires having two fstab files:
22// one for the default mode, and one for FIPS mode selectable via
23// androidboot.fstab_suffix on the kernel command line.  These fstabs should be
24// identical with the exception of the encryption settings, so to keep them in
25// sync the rules below generate them from a template file.
26
27soong_namespace {
28    imports: [
29        "device/google/gs101",
30        "device/google/gs101/conf",
31    ],
32}
33
34package {
35    // See: http://go/android-license-faq
36    // A large-scale-change added 'default_applicable_licenses' to import
37    // all of the 'license_kinds' from "device_google_gs101_license"
38    // to get the below license kinds:
39    //   SPDX-license-identifier-Apache-2.0
40    default_applicable_licenses: ["device_google_gs101_license"],
41}
42
43genrule {
44    name: "gen_fstab.gs101",
45    srcs: [
46        "fstab.gs101.in*",
47        ":gs101_srcs",
48        ],
49    out: ["fstab.gs101"],
50    cmd: "sed -e s/@fileencryption@/::inlinecrypt_optimized+wrappedkey_v0/" +
51        " -e s/@metadata_encryption@/:wrappedkey_v0/" +
52        " -e /modem/d " +
53        " -e /efs/d $(in) > $(out)",
54}
55
56genrule {
57    name: "gen_fstab.gs101-fips",
58    srcs: [
59        "fstab.gs101.in*",
60        ":gs101_srcs",
61        ],
62    out: ["fstab.gs101-fips"],
63    cmd: "sed -e s/@fileencryption@/aes-256-xts/" +
64        " -e s/@metadata_encryption@/aes-256-xts/" +
65        " -e /modem/d " +
66        " -e /efs/d $(in) > $(out)",
67}
68
69prebuilt_etc {
70    name: "fstab.gs101",
71    src: ":gen_fstab.gs101",
72    vendor: true,
73    vendor_ramdisk_available: true,
74}
75
76prebuilt_etc {
77    name: "fstab.gs101-fips",
78    src: ":gen_fstab.gs101-fips",
79    vendor: true,
80    vendor_ramdisk_available: true,
81}