Merge AOSP master

Squashed commit of the following:

commit c1b05eb57fadc3796aff6079d5a65e3c809aa9de
Merge: 2b80108 063cfe1
Author: David 'Digit' Turner <digit@android.com>
Date:   Tue Mar 12 23:07:34 2013 +0000

    Merge "Move more build configuration to openssl.config"

commit 063cfe18eb26487c1e69f0b9f408b3849c81a84a
Author: David 'Digit' Turner <digit@android.com>
Date:   Tue Feb 19 17:08:14 2013 +0100

    Move more build configuration to openssl.config

    This patch makes openssl.config the only place where common
    and architecture-specific sources and compiler flags are listed.

    Its content is processed by import_openssl.sh to generate new
    build config files (Crypto-config.mk, Ssl-config.mk, Apps-config.mk)
    which are themselves included by simplified Crypto.mk, Ssl.mk, Apps.mk.

    + Add a new script (check-all-builds.sh) that can rebuild six
      different variants of openssl in one go. This is useful to quickly
      check that a change didn't break a specific build, e.g. when
      adding  new patch or upgrading the OpenSSL sources.

      See './check-all-builds.sh --help' for more info.

      Note: Clang-based builds are currently broken, so only GCC-based
            ones are activated at the moment.

    Change-Id: If08c204e4dc9b081ce676bc7984d039670e115b0

commit 2b80108735eb6cce8656cfdd638aa8985d7fec62
Merge: 03e9262 365d7e8
Author: David 'Digit' Turner <digit@android.com>
Date:   Tue Mar 5 21:21:30 2013 +0000

    Merge "Fix Clang build."

commit 365d7e8ba65197a3bad7349848dc13be13d6922a
Author: David 'Digit' Turner <digit@android.com>
Date:   Tue Mar 5 19:52:51 2013 +0100

    Fix Clang build.

    This contains a new Android-specific patch to fix the Chromium
    linux Clang builds.

    This updates patches/channelid.patch independently since this
    patch hasn't been submitted upstream yet.

    Change-Id: I9d9a2ca3ad8446a54db5a023571fde1bc0d276c5

commit 03e9262c803c2afb7ac14a85cc4e0a111d24def9
Merge: 3b70ce8 9fbf99a
Author: David 'Digit' Turner <digit@android.com>
Date:   Tue Mar 5 19:21:54 2013 +0000

    Merge "Auto-generate configuration flags."

commit 9fbf99a3a3ee41ed303a97b0b00808236d187bc0
Author: David 'Digit' Turner <digit@android.com>
Date:   Tue Feb 19 10:38:34 2013 +0100

    Auto-generate configuration flags.

    This modifies import_openssl.sh to parse the configured Makefile
    and extract the appropriate compiler flags that were currently
    defined manually in android-config.mk

    - Modifies openssl.config to add missing configure options to
      ensure the final result is the same than before the patch.
      This also updates crypto/opensslconf.h.

    - The generated output is stored in build-config.mk which content
      directly comes from the OpenSSL Makefile.

    - android-config.mk is still used to define LOCAL_CFLAGS from
      the definitions in build-config.mk, as well as perform minimal
      extra filtering.

    - Remove the section in README.android about manually changing
      android-config.mk.

    Change-Id: I5275de69a817aa7c9880ea48e5d6a8ac1652a1e4

commit 3b70ce86949a9cb8bd8774bcca368228e33c23e9
Merge: fb21955 1762a55
Author: David 'Digit' Turner <digit@android.com>
Date:   Tue Feb 19 16:26:49 2013 +0000

    Merge "Convert ISO-8859-1 files to UTF-8."

commit fb219556776ec48e731beacc3bd7bbe78028b5b9
Merge: b592e08 76ab38e
Author: David 'Digit' Turner <digit@android.com>
Date:   Tue Feb 19 16:22:44 2013 +0000

    Merge "Add missing patch file to openssl.config"

commit 1762a559ef393f9c15300398433598989033385f
Author: David 'Digit' Turner <digit@android.com>
Date:   Tue Feb 19 09:25:30 2013 +0100

    Convert ISO-8859-1 files to UTF-8.

    This patch modifies import_openssl.sh to convert all untarred OpenSSL
    source files that are in ISO-8859-1 encoding into UTF-8.

    The main reason for this is that the Chromium review tool doesn't support
    anything else (i.e. "git cl upload" will barf with a mysterious Python
    exception if the uploaded diff files aren't UTF-8).

    This makes it easier to import the Android sources into the Chromium tree,
    and should have no impact on the build products.

    Change-Id: I43df753c41f5d9ed853a4252d7d05c5bbced98b4

commit 76ab38eccf60151b5042b62402f2cd2acd0237b7
Author: David 'Digit' Turner <digit@android.com>
Date:   Tue Feb 19 09:11:21 2013 +0100

    Add missing patch file to openssl.config

    Without this, one patch file was not applied properly.

    Change-Id: I53d3b5935c3cd633b3bade8055d1aa37c14810fc

commit b592e0854049cd931a0ffecd340f216dbef59ca8
Merge: d8b571b eefface
Author: Brian Carlstrom <bdc@google.com>
Date:   Mon Feb 11 18:26:30 2013 +0000

    Merge "openssl-1.0.1e upgrade"

commit eeffacea337ec6a275e4c496acd12ca67a244533
Author: Brian Carlstrom <bdc@google.com>
Date:   Mon Feb 11 09:54:43 2013 -0800

    openssl-1.0.1e upgrade

    Change-Id: I4520a7e044b1c6a1b9d09b365bc18b178826131e

commit d8b571b2dff2347770a7e8e5f9ea031d367dff52
Merge: d1bb51b d38060a
Author: Kenny Root <kroot@google.com>
Date:   Fri Feb 8 23:31:54 2013 +0000

    Merge "Fix failures when eng_dyn scans multiple directories"

commit d38060ab627bb1af09983903130c3e63cd1cab45
Author: Kenny Root <kroot@google.com>
Date:   Fri Feb 8 11:22:25 2013 -0800

    Fix failures when eng_dyn scans multiple directories

    If DIR_ADD is called with multiple directories, and the target file
    does not exist in the first directory scanned, the DSO object will still
    be considered "loaded" for the next call of DSO_load(...) and cause
    subsequent calls to DSO_load(...) fail with the reason code of "already
    loaded" even though the load failed.

    Additionally, with multiple directories used in eng_dyn, another problem
    manifests because the errors pushed onto the error stack will linger even
    if another library is loaded successfully on subsequent calls to
    DSO_load(...) in the directory scanning loop.

    Change-Id: I4ddd24f7b39bd88663e1783f30914870a907acfa

commit d1bb51b68d5191ca33ea2bde0835ac564993beab
Merge: 3ccf38e 04ef91b
Author: Brian Carlstrom <bdc@google.com>
Date:   Tue Feb 5 21:31:03 2013 +0000

    Merge "openssl-1.0.1d upgrade"

commit 04ef91b390dfcc6125913e2f2af502d23d7a5112
Author: Brian Carlstrom <bdc@google.com>
Date:   Tue Feb 5 09:20:38 2013 -0800

    openssl-1.0.1d upgrade

    Change-Id: Ie980c8834cf2c843858182d98d1f60c65a2a9b70

commit 3ccf38e0fb3064a4b19879d5e068fb7a124234c0
Merge: 4b0baa1 fa75fdb
Author: Brian Carlstrom <bdc@google.com>
Date:   Mon Feb 4 19:18:52 2013 +0000

    Merge "CVE-2013-0169: Make CBC decoding constant time"

commit fa75fdba32eae335f286afb1dc93ef1b5ec72615
Author: Brian Carlstrom <bdc@google.com>
Date:   Fri Feb 1 23:44:05 2013 -0800

    CVE-2013-0169: Make CBC decoding constant time

    (cherry-picked from 2c082d25fc3f0dd6e56c45407fe10638b904083c)

    Bug: 8017911
    Bug: 8095088
    Change-Id: I57556e120fd1f585d38739d0d6aaf02bcbe45fbd

commit 4b0baa1ed0dba48c5f450864e0369c601040f84d
Merge: 43c07da 7fe2109
Author: Brian Carlstrom <bdc@google.com>
Date:   Sat Feb 2 20:51:27 2013 +0000

    Merge "Remove stray ssl/Makefile"

commit 7fe2109a62fafd9950aa486c5a40f930d07efdba
Author: Brian Carlstrom <bdc@google.com>
Date:   Sat Feb 2 00:01:52 2013 -0800

    Remove stray ssl/Makefile

    Change-Id: Icf1836ceaa8f31c92f2154ca6186cfbb8714b825

commit 43c07da42a11e96a8d3c9e335bd3c6caebf0ac7e
Merge: de2ed6e 85dbb37
Author: David 'Digit' Turner <digit@android.com>
Date:   Fri Feb 1 12:03:00 2013 +0000

    Merge "Add another missing x86_64 assembly file generation step."

commit de2ed6ef28ffe2330bf27e007cb909ade450deb0
Merge: 2c88fd9 f6e8065
Author: David 'Digit' Turner <digit@android.com>
Date:   Wed Jan 30 13:35:23 2013 +0000

    Merge "Fix recursive lock in X509_PUBKEY_get"

commit 85dbb371d6ce544388360f64389b5007fe7f384b
Author: David 'Digit' Turner <digit@android.com>
Date:   Thu Jan 24 10:54:02 2013 +0100

    Add another missing x86_64 assembly file generation step.

    Change-Id: I357c33a297937c2e64cfa8c6e49795cd1e865544

commit f6e80656429bacaf943834480e96929001f5d443
Author: David 'Digit' Turner <digit@android.com>
Date:   Thu Jan 24 10:31:21 2013 +0100

    Fix recursive lock in X509_PUBKEY_get

    This was discovered recently by the Chromium "linux_redux" build,
    the bug was causing one of the unit tests to stall. Note that the
    patch is already applied in upstream OpenSSL.

    For more details, see http://crbug.com/171812

    Change-Id: I9ca8886fba6c89fc19fc71c0cc9b732c9fb82208

commit 2c88fd9ca5e894e6f18214caf76a0c01aef7bce8
Merge: 0a1f3fb f59fa74
Author: David 'Digit' Turner <digit@android.com>
Date:   Thu Jan 24 09:18:38 2013 +0000

    Merge "Add patches/clang.patch to fix two minor Clang compiler errors."

commit 0a1f3fb1f666cc0eed4ded942e811fdd1c58470b
Merge: 410afec 153b100
Author: David 'Digit' Turner <digit@android.com>
Date:   Wed Jan 23 15:28:32 2013 +0000

    Merge "Fix x86_64 assembly file generation."

commit f59fa7445dbf3eebabb2ff5875559d636f6834f0
Author: David 'Digit' Turner <digit@android.com>
Date:   Wed Jan 23 16:27:08 2013 +0100

    Add patches/clang.patch to fix two minor Clang compiler errors.

    This patch is currently applied on top of the Android ones for the
    Chromium version of the library. Applying it here helps reduce the
    difference between them.

    Change-Id: I089dc7e56f0de49906f1bc582e1f3278b4aee2e6

commit 153b100b9bdd15db2ad0c0963e299ed6841a794d
Author: David 'Digit' Turner <digit@android.com>
Date:   Wed Jan 23 16:19:10 2013 +0100

    Fix x86_64 assembly file generation.

    The "sha512-x86_64.pl" script actually needs the name of the output
    file as its second parameter to determine whether to generate SHA-256
    or SHA-512 routines.

    This patch does the following:

    - Fix import_openssl.sh to invoke the script properly
    - Add the generation of sha256-x86_64.S as well.

    Note that this patch is the result of running:

      ./import_openssl.sh import /path/to/openssl-1.0.1c.tar.gz

    Which means that no other source files were impacted by the change.

    Only needed for the Chromium x86_64 "linux_redux" build and the
    SPDY host proxy program (flip_in_mem_edsm_server).

    Change-Id: Ia40737f5952c7b156bd51844571e4f759910a6a1

commit 410afec19da6b0be40734be660ad6c4395ee827b
Merge: 3bcb2bf f04b7b0
Author: Brian Carlstrom <bdc@google.com>
Date:   Thu Jan 17 20:13:52 2013 +0000

    Merge "Remove small_records.patch in favor of SSL_MODE_RELEASE_BUFFERS"

commit f04b7b0cd950a9bf3c07edcbafb48afe63d4fed3
Author: Brian Carlstrom <bdc@google.com>
Date:   Wed Jan 16 15:23:33 2013 -0800

    Remove small_records.patch in favor of SSL_MODE_RELEASE_BUFFERS

    Restored handshake_cutthrough.patch to upstream having removed traces of the small_records.patch

    Change-Id: Iae8df5f24fe5fe566e81421e9db4c2f1ea5f1b53

commit 3bcb2bf170d9f351f52159b514cb588a3ce1c53a
Merge: d37ef78 45bcfbc
Author: Brian Carlstrom <bdc@google.com>
Date:   Wed Jan 16 23:22:06 2013 +0000

    Merge "Add support for the TLS Channel ID extension."

commit 45bcfbcc39acc2213abd00ebcc794dcc40be39f7
Author: Adam Langley <agl@chromium.org>
Date:   Wed Jan 16 13:43:53 2013 -0800

    Add support for the TLS Channel ID extension.

    See http://tools.ietf.org/html/draft-balfanz-tls-channelid-00.

    Change-Id: Id5b9799f96c0f7a1ef5ed8db9e40111a700d091f

commit d37ef7804404d42f9a09c283726adde5c8ba0d27
Merge: 3f1584c e001f05
Author: Brian Carlstrom <bdc@google.com>
Date:   Thu Dec 13 17:21:52 2012 -0800

    Merge "Only honor LOCAL_SDK_VERSION when building apps."

commit e001f05ac347927c48876fe40066ecce9003d24a
Author: Nick Kralevich <nnk@google.com>
Date:   Thu Dec 13 15:18:21 2012 -0800

    Only honor LOCAL_SDK_VERSION when building apps.

    When building for the system, we want openssl to have
    FORTIFY_SOURCE protections. LOCAL_SDK_VERSION suppresses
    these protections for compatibility reasons.

    (cherry-picked from eb9b8f9ae5c9cdc9f1e68cf8a3c89f21978a90f7)

    Change-Id: I8ad09b66623fc289d488c12c4268b796330c491c

commit 3f1584c10952bcc3a653c3528f9b1146edfcf326
Merge: 6eda41c 2077779
Author: David 'Digit' Turner <digit@android.com>
Date:   Tue Dec 11 02:33:31 2012 -0800

    Merge "Add x86_64 assembly files."

commit 6eda41c218014eb6d4a3a53a6248aa6d4a39f780
Merge: cb1a4ed 19d5d6f
Author: David 'Digit' Turner <digit@android.com>
Date:   Tue Dec 11 02:32:57 2012 -0800

    Merge "Add x86 cpuid assembly file."

commit 20777798f5184ef65e59bb5eb91ac9e839d7afeb
Author: David 'Digit' Turner <digit@android.com>
Date:   Mon Dec 10 12:46:08 2012 +0100

    Add x86_64 assembly files.

    This patch modifies import_openssl.sh to also generate assembly
    files for x86_64 (using the appropriate Perl scripts).

    These new sources are not used by the Android build, but by the
    Chromium "linux_redux" build which uses OpenSSL has its SSL engine.

    Change-Id: I3d1435de17f2de10633a71b9197b6cec328e93a7

commit 19d5d6fe6ced25a9888f107d5e3957d3a1800a82
Author: David 'Digit' Turner <digit@android.com>
Date:   Mon Dec 10 12:29:53 2012 +0100

    Add x86 cpuid assembly file.

    This patch does the following:

    - Adds the generation of crypto/x86cpuid.S in import_openssl.sh.

    - Modifies Crypto.mk to ensure that the corresponding functions
      are linked and used at runtime.

    Note that mem_clr.c is removed from the x86 build. Its sole purpose
    is to provide a generic implementation of OPENSSL_cleanse, which is
    provided by the x86cpuid.S source file now.

    Change-Id: I7cbf6b12220def11498e591dc64787ef76303c9e

commit cb1a4ed6718df32063e7877903a484f8e38877f7
Merge: ec5aff0 b86413f
Author: Brian Carlstrom <bdc@google.com>
Date:   Tue Nov 13 22:07:33 2012 -0800

    Merge "Use NDK libraries for x86 and MIPS build."

commit b86413f2ad564e04778a5087c48e7fb5f253f8d7
Author: Arunesh Mishra <arunesh@google.com>
Date:   Tue Nov 13 11:07:23 2012 -0800

    Use NDK libraries for x86 and MIPS build.

    (cherry-picked from 280230f73a9d6398da94bf8c1389086dcae92a89)

    Bug: 6953633
    Change-Id: I745588fb024040a42a1fcb3222db7e104d2114fe

commit ec5aff0c95e7b98896abf61aa5b59166bac72715
Merge: 34d5a28 13783d9
Author: Brian Carlstrom <bdc@google.com>
Date:   Mon Nov 5 16:53:18 2012 -0800

    am 13783d99: Merge "x86: Fix DT_TEXTREL in assembly code"

    * commit '13783d992d2da1ed649392b9a65370bfb94da2bf':
      x86: Fix DT_TEXTREL in assembly code

commit 13783d992d2da1ed649392b9a65370bfb94da2bf
Merge: 5cbf3d1 2c4d015
Author: Brian Carlstrom <bdc@google.com>
Date:   Mon Nov 5 16:29:01 2012 -0800

    Merge "x86: Fix DT_TEXTREL in assembly code"

commit 2c4d015c2c3dbe9cf62004171e265487dfa22469
Author: Daniel Leung <daniel.leung@linux.intel.com>
Date:   Mon Nov 5 14:56:34 2012 -0800

    x86: Fix DT_TEXTREL in assembly code

    Regenerate some assembly files to make them PIC friendly.

    The perl script needs to be passed "-fPIC" to properly generate PIC
    friendly code for x86.

    The import_openssl.sh has also been updated to include -fPIC when
    generating assembly files for x86.

    Change-Id: Ie174b5f74cf7fcdad1339892302b8762ee43ed7c
    Signed-off-by: Daniel Leung <daniel.leung@linux.intel.com>

commit 34d5a2853c2f369b7c49ba3c5c357f846710246e
Merge: ba352ab 5cbf3d1
Author: Brian Carlstrom <bdc@google.com>
Date:   Fri Oct 5 16:52:06 2012 -0700

    am 5cbf3d15: am 02675aaa: Merge "Rename assembly files with .S extensions."

    * commit '5cbf3d1549d15a4416070b5c457288860dcf8651':
      Rename assembly files with .S extensions.

commit 5cbf3d1549d15a4416070b5c457288860dcf8651
Merge: 13e2fdf 02675aa
Author: Brian Carlstrom <bdc@google.com>
Date:   Fri Oct 5 16:50:10 2012 -0700

    am 02675aaa: Merge "Rename assembly files with .S extensions."

    * commit '02675aaa12fa3bda00bb1b206edfc1001ccf5696':
      Rename assembly files with .S extensions.

commit 02675aaa12fa3bda00bb1b206edfc1001ccf5696
Merge: b73232f 9838b9f
Author: Brian Carlstrom <bdc@google.com>
Date:   Fri Oct 5 16:02:44 2012 -0700

    Merge "Rename assembly files with .S extensions."

commit 9838b9f4b038825b061a6b323842f9d23729eac0
Author: David 'Digit' Turner <digit@google.com>
Date:   Fri Oct 5 16:31:08 2012 +0200

    Rename assembly files with .S extensions.

    The openssl files were generated with an .s extension,
    which tells GCC that they normally don't need to be sent
    to the pre-processor (i.e. they are passed directly to the
    assembler).

    Unfortunately, all these files _do_ need to be preprocessed,
    which is why 'LOCAL_AS_CFLAGS := -x assembler-with-cpp' was
    required in Crypto.mk.

    As simpler way to solve the issue is simply to use an .S
    extension when generating the assembly files. GCC knows
    that these must be pre-processed first.

    So the patch does:

      - Rename all .s files to .S
      - Remove the use of -x assembler-with-cpp from Crypto.mk
      - Modify import_openssl.sh to directly generate .S files
        (tested)

    Context: This makes it easier to reuse the exact same sources
             for Chrome on Android. Its gyp build system doesn't
             have a feature comparable to LOCAL_AS_CFLAGS.

    Change-Id: I708d9fbcf8d42b5c39a7d30df2b03ed79a3e62f0

Change-Id: I74b20e91a65a6c2345c64be93977f4af78f919c2