diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 11ae86edfb2bce0ab8ff081f0509f98ffb135811..9f3f80d692a4e6d79c0c2fe9522cc7dbe86c4216 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -1698,7 +1698,9 @@ package android.os { method public static boolean is64BitAbi(String); method public static boolean isDebuggable(); field @Nullable public static final String BRAND_FOR_ATTESTATION; + field @Nullable public static final String DEVICE_FOR_ATTESTATION; field public static final boolean IS_EMULATOR; + field @Nullable public static final String MANUFACTURER_FOR_ATTESTATION; field @Nullable public static final String MODEL_FOR_ATTESTATION; field @Nullable public static final String PRODUCT_FOR_ATTESTATION; } diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index 832f23cdb3e28b1b98a4210e5d30c5a56b941c26..735a0689be5e9056dad5671b52c9e36c1142d525 100755 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -64,17 +64,27 @@ public class Build { /** * The product name for attestation. In non-default builds (like the AOSP build) the value of * the 'PRODUCT' system property may be different to the one provisioned to KeyMint, - * and Keymint attestation would still attest to the product name, it's running on. + * and Keymint attestation would still attest to the product name which was provisioned. * @hide */ @Nullable @TestApi - public static final String PRODUCT_FOR_ATTESTATION = - getString("ro.product.name_for_attestation"); + public static final String PRODUCT_FOR_ATTESTATION = getVendorDeviceIdProperty("name"); /** The name of the industrial design. */ public static final String DEVICE = getString("ro.product.device"); + /** + * The device name for attestation. In non-default builds (like the AOSP build) the value of + * the 'DEVICE' system property may be different to the one provisioned to KeyMint, + * and Keymint attestation would still attest to the device name which was provisioned. + * @hide + */ + @Nullable + @TestApi + public static final String DEVICE_FOR_ATTESTATION = + getVendorDeviceIdProperty("device"); + /** The name of the underlying board, like "goldfish". */ public static final String BOARD = getString("ro.product.board"); @@ -97,19 +107,29 @@ public class Build { /** The manufacturer of the product/hardware. */ public static final String MANUFACTURER = getString("ro.product.manufacturer"); + /** + * The manufacturer name for attestation. In non-default builds (like the AOSP build) the value + * of the 'MANUFACTURER' system property may be different to the one provisioned to KeyMint, + * and Keymint attestation would still attest to the manufacturer which was provisioned. + * @hide + */ + @Nullable + @TestApi + public static final String MANUFACTURER_FOR_ATTESTATION = + getVendorDeviceIdProperty("manufacturer"); + /** The consumer-visible brand with which the product/hardware will be associated, if any. */ public static final String BRAND = getString("ro.product.brand"); /** * The product brand for attestation. In non-default builds (like the AOSP build) the value of * the 'BRAND' system property may be different to the one provisioned to KeyMint, - * and Keymint attestation would still attest to the product brand, it's running on. + * and Keymint attestation would still attest to the product brand which was provisioned. * @hide */ @Nullable @TestApi - public static final String BRAND_FOR_ATTESTATION = - getString("ro.product.brand_for_attestation"); + public static final String BRAND_FOR_ATTESTATION = getVendorDeviceIdProperty("brand"); /** The end-user-visible name for the end product. */ public static final String MODEL = getString("ro.product.model"); @@ -117,13 +137,12 @@ public class Build { /** * The product model for attestation. In non-default builds (like the AOSP build) the value of * the 'MODEL' system property may be different to the one provisioned to KeyMint, - * and Keymint attestation would still attest to the product model, it's running on. + * and Keymint attestation would still attest to the product model which was provisioned. * @hide */ @Nullable @TestApi - public static final String MODEL_FOR_ATTESTATION = - getString("ro.product.model_for_attestation"); + public static final String MODEL_FOR_ATTESTATION = getVendorDeviceIdProperty("model"); /** The manufacturer of the device's primary system-on-chip. */ @NonNull @@ -1530,6 +1549,17 @@ public class Build { private static String getString(String property) { return SystemProperties.get(property, UNKNOWN); } + /** + * Return attestation specific proerties. + * @param property model, name, brand, device or manufacturer. + * @return property value or UNKNOWN + */ + private static String getVendorDeviceIdProperty(String property) { + String attestProp = getString( + TextUtils.formatSimple("ro.product.%s_for_attestation", property)); + return attestProp.equals(UNKNOWN) + ? getString(TextUtils.formatSimple("ro.product.vendor.%s", property)) : UNKNOWN; + } private static String[] getStringList(String property, String separator) { String value = SystemProperties.get(property); diff --git a/keystore/java/android/security/keystore2/AndroidKeyStoreKeyPairGeneratorSpi.java b/keystore/java/android/security/keystore2/AndroidKeyStoreKeyPairGeneratorSpi.java index c1f6c29ca86e6e1aa1cad54ab80c52b5c3eb484c..c3b0f9bc16d3ddadea5bca4355e99d746f506264 100644 --- a/keystore/java/android/security/keystore2/AndroidKeyStoreKeyPairGeneratorSpi.java +++ b/keystore/java/android/security/keystore2/AndroidKeyStoreKeyPairGeneratorSpi.java @@ -808,9 +808,12 @@ public abstract class AndroidKeyStoreKeyPairGeneratorSpi extends KeyPairGenerato KeymasterDefs.KM_TAG_ATTESTATION_ID_BRAND, platformReportedBrand.getBytes(StandardCharsets.UTF_8) )); + final String platformReportedDevice = + isPropertyEmptyOrUnknown(Build.DEVICE_FOR_ATTESTATION) + ? Build.DEVICE : Build.DEVICE_FOR_ATTESTATION; params.add(KeyStore2ParameterUtils.makeBytes( KeymasterDefs.KM_TAG_ATTESTATION_ID_DEVICE, - Build.DEVICE.getBytes(StandardCharsets.UTF_8) + platformReportedDevice.getBytes(StandardCharsets.UTF_8) )); final String platformReportedProduct = isPropertyEmptyOrUnknown(Build.PRODUCT_FOR_ATTESTATION) @@ -819,9 +822,12 @@ public abstract class AndroidKeyStoreKeyPairGeneratorSpi extends KeyPairGenerato KeymasterDefs.KM_TAG_ATTESTATION_ID_PRODUCT, platformReportedProduct.getBytes(StandardCharsets.UTF_8) )); + final String platformReportedManufacturer = + isPropertyEmptyOrUnknown(Build.MANUFACTURER_FOR_ATTESTATION) + ? Build.MANUFACTURER : Build.MANUFACTURER_FOR_ATTESTATION; params.add(KeyStore2ParameterUtils.makeBytes( KeymasterDefs.KM_TAG_ATTESTATION_ID_MANUFACTURER, - Build.MANUFACTURER.getBytes(StandardCharsets.UTF_8) + platformReportedManufacturer.getBytes(StandardCharsets.UTF_8) )); final String platformReportedModel = isPropertyEmptyOrUnknown(Build.MODEL_FOR_ATTESTATION)