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

Commit 00c2018e authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

Merge tag 'android-5.0.1_r1' into HEAD

Android 5.0.1 release 1

Change-Id: Id44d5168fc8a77c4a30a86729c7fd7194e97bc1b
parents c1bec36c 93edcc13
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -22,12 +22,14 @@ import android.os.Parcelable;
import com.android.internal.util.ArrayUtils;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.security.PublicKey;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Arrays;

/**
@@ -252,4 +254,53 @@ public class Signature implements Parcelable {
        return (a.length == b.length) && ArrayUtils.containsAll(a, b)
                && ArrayUtils.containsAll(b, a);
    }

    /**
     * Test if given {@link Signature} sets are effectively equal. In rare
     * cases, certificates can have slightly malformed encoding which causes
     * exact-byte checks to fail.
     * <p>
     * To identify effective equality, we bounce the certificates through an
     * decode/encode pass before doing the exact-byte check. To reduce attack
     * surface area, we only allow a byte size delta of a few bytes.
     *
     * @throws CertificateException if the before/after length differs
     *             substantially, usually a signal of something fishy going on.
     * @hide
     */
    public static boolean areEffectiveMatch(Signature[] a, Signature[] b)
            throws CertificateException {
        final CertificateFactory cf = CertificateFactory.getInstance("X.509");

        final Signature[] aPrime = new Signature[a.length];
        for (int i = 0; i < a.length; i++) {
            aPrime[i] = bounce(cf, a[i]);
        }
        final Signature[] bPrime = new Signature[b.length];
        for (int i = 0; i < b.length; i++) {
            bPrime[i] = bounce(cf, b[i]);
        }

        return areExactMatch(aPrime, bPrime);
    }

    /**
     * Bounce the given {@link Signature} through a decode/encode cycle.
     *
     * @throws CertificateException if the before/after length differs
     *             substantially, usually a signal of something fishy going on.
     * @hide
     */
    public static Signature bounce(CertificateFactory cf, Signature s) throws CertificateException {
        final InputStream is = new ByteArrayInputStream(s.mSignature);
        final X509Certificate cert = (X509Certificate) cf.generateCertificate(is);
        final Signature sPrime = new Signature(cert.getEncoded());

        if (Math.abs(sPrime.mSignature.length - s.mSignature.length) > 2) {
            throw new CertificateException("Bounced cert length looks fishy; before "
                    + s.mSignature.length + ", after " + sPrime.mSignature.length);
        }

        return sPrime;
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -31,4 +31,9 @@
        <item>"*611:+19085594899,BAE0000000000000"</item>
        <item>"*86:+1MDN,BAE0000000000000"</item>
    </string-array>

    <string-array translatable="false" name="config_sms_convert_destination_number_support">
        <item>true;BAE0000000000000</item>
        <item>false</item>
    </string-array>
</resources>
+4 −0
Original line number Diff line number Diff line
@@ -44,4 +44,8 @@
         a permamnent error -->
    <bool name="config_protocol_errors_perm_failure">false</bool>

    <string-array translatable="false" name="config_sms_convert_destination_number_support">
        <item>true</item>
    </string-array>

</resources>
+4 −0
Original line number Diff line number Diff line
@@ -57,4 +57,8 @@
         a permamnent error -->
    <bool name="config_protocol_errors_perm_failure">false</bool>

    <string-array translatable="false" name="config_sms_convert_destination_number_support">
        <item>true</item>
    </string-array>

</resources>
+17 −0
Original line number Diff line number Diff line
@@ -1942,6 +1942,7 @@
    <bool name="config_switch_phone_on_voice_reg_state_change">true</bool>

    <bool name="config_sms_force_7bit_encoding">false</bool>

    <!-- Configuartion to support 7bit Ascii encoding and decoding
         for long messages. -->
    <bool name="config_ascii_7bit_support_for_long_message">false</bool>
@@ -2117,4 +2118,20 @@
    <!-- Support for disabling to fetch APN from OMH card
         for some cdma carriers -->
    <bool name="config_fetch_apn_from_omh_card">true</bool>

    <!-- This config is used to check if the carrier requires converting destination
         number before sending out a SMS.
         Formats for this configuration as below:
         [true or false][;optional gid]
         The logic to pick up the configuration:
         (1) If the "config_sms_convert_destination_number_support" array has no gid
             special item, the last one will be picked
         (2) If the "config_sms_convert_destination_number_support" array has gid special
             item and it matches the current sim's gid, it will be picked.
         (3) If the "config_sms_convert_destination_number_support" array has gid special
             item but it doesn't match the current sim's gid, the last one without gid
             will be picked -->
    <string-array translatable="false" name="config_sms_convert_destination_number_support">
        <item>false</item>
    </string-array>
</resources>
Loading