Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b41e7e8f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix the isHashed value to true for all certificate keys."

parents 185efbaf e5a165f3
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -332,9 +332,12 @@ public abstract class AtomicFormula extends IntegrityFormula {
         * Constructs a new {@link StringAtomicFormula} together with handling the necessary
         * hashing for the given key.
         *
         * <p> The value will be hashed with SHA256 and the hex digest will be computed; for
         * all cases except when the key is PACKAGE_NAME or INSTALLER_NAME and the value
         * is less than 33 characters.
         * <p> The value will be automatically hashed with SHA256 and the hex digest will be
         * computed when the key is PACKAGE_NAME or INSTALLER_NAME and the value is more than 32
         * characters.
         *
         * <p> The APP_CERTIFICATES and INSTALLER_CERTIFICATES are always delivered in hashed
         * form. So the isHashedValue is set to true by default.
         *
         * @throws IllegalArgumentException if {@code key} cannot be used with string value.
         */
@@ -348,7 +351,10 @@ public abstract class AtomicFormula extends IntegrityFormula {
                    String.format(
                            "Key %s cannot be used with StringAtomicFormula", keyToString(key)));
            mValue = hashValue(key, value);
            mIsHashedValue = !mValue.equals(value);
            mIsHashedValue =
                    key == APP_CERTIFICATE || key == INSTALLER_CERTIFICATE
                            ? true
                            : !mValue.equals(value);
        }

        StringAtomicFormula(Parcel in) {
+2 −2
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ public class AtomicFormulaTest {

        assertThat(stringAtomicFormula.getKey()).isEqualTo(AtomicFormula.APP_CERTIFICATE);
        assertThat(stringAtomicFormula.getValue()).matches(appCert);
        assertThat(stringAtomicFormula.getIsHashedValue()).isFalse();
        assertThat(stringAtomicFormula.getIsHashedValue()).isTrue();
    }

    @Test
@@ -110,7 +110,7 @@ public class AtomicFormulaTest {
        assertThat(stringAtomicFormula.getKey()).isEqualTo(
                AtomicFormula.INSTALLER_CERTIFICATE);
        assertThat(stringAtomicFormula.getValue()).matches(installerCert);
        assertThat(stringAtomicFormula.getIsHashedValue()).isFalse();
        assertThat(stringAtomicFormula.getIsHashedValue()).isTrue();
    }

    @Test
+2 −2
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public class IntegrityFormulaTest {

        assertThat(stringAtomicFormula.getKey()).isEqualTo(AtomicFormula.APP_CERTIFICATE);
        assertThat(stringAtomicFormula.getValue()).matches(appCertificate);
        assertThat(stringAtomicFormula.getIsHashedValue()).isFalse();
        assertThat(stringAtomicFormula.getIsHashedValue()).isTrue();
    }

    @Test
@@ -82,7 +82,7 @@ public class IntegrityFormulaTest {

        assertThat(stringAtomicFormula.getKey()).isEqualTo(AtomicFormula.INSTALLER_CERTIFICATE);
        assertThat(stringAtomicFormula.getValue()).matches(installerCertificate);
        assertThat(stringAtomicFormula.getIsHashedValue()).isFalse();
        assertThat(stringAtomicFormula.getIsHashedValue()).isTrue();
    }

    @Test