http: protect against response splitting attacks

This patch is a back-port of 3c293ba.
Closes #4696
blog: v0.9.9
blog: v0.9.9 is unstable, not stable
import openssl 1.0.0k code

All patches made to previously used 1.0.0f are overwritten
and should be reapplied if needed.
deps: remove openssl apps and tests

Shrinks the tarball by a few hundred kilobytes and fixes a broken symlinks
issue on Windows.

Fixes #3813.
build: configure openssl

* compile with -DOPENSSL_NO_SOCK and -DOPENSSL_NO_DGRAM, we don't need it
* compile with -DOPENSSL_NO_GOST and -DOPENSSL_NO_HW_PADLOCK, works around the
  brain dead linker on solaris and maybe others
* compile with -DTERMIOS, OS X doesn't have <termio.h>
* compile with -D__EXTENSIONS__ on solaris, makes siginfo_t available
* compile without -ansi on linux, it hides a number of POSIX declarations
  (sigaction, NI_MAXHOST, etc.)
(cherry picked from commit 97f6bb5c69da4df9a1b5c8b94ab24dabfe9051f0)

Conflicts:

	common.gypi
	deps/openssl/openssl.gyp
deps: fix -DOPENSSL_NO_SOCK on sunos

The OPENSSL_NO_SOCK macro in OpenSSL missed a couple of networking functions
that called other functions that OPENSSL_NO_SOCK *had* filtered out. None of
the functions (filtered or not) were actually used but it was enough to trip
up the Solaris linker.
(cherry picked from commit 2660ffadb5b8b5c532dabdc936f29f1443293c20)
deps: back-port openssl patch

Check for potentially exploitable overflows in asn1_d2i_read_bio
BUF_mem_grow and BUF_mem_grow_clean. Refuse attempts to shrink buffer
in CRYPTO_realloc_clean.

Taken from OpenSSL CVS. Addresses CVE-2012-2110.
(cherry picked from commit c76ca1034f1ade3eea9292d084df14e4fca70301)
crypto: fix uninitialized memory access in openssl

ASN1_STRING_to_UTF8() passes an ASN1_STRING to ASN1_STRING_set() but forgot to
initialize the `length` field.

Fixes the following valgrind error:

  $ valgrind -q --track-origins=yes --num-callers=19 \
      out/Debug/node test/simple/test-tls-client-abort.js
  ==2690== Conditional jump or move depends on uninitialised value(s)
  ==2690==    at 0x784B69: ASN1_STRING_set (asn1_lib.c:382)
  ==2690==    by 0x809564: ASN1_mbstring_ncopy (a_mbstr.c:204)
  ==2690==    by 0x8090F0: ASN1_mbstring_copy (a_mbstr.c:86)
  ==2690==    by 0x782F1F: ASN1_STRING_to_UTF8 (a_strex.c:570)
  ==2690==    by 0x78F090: asn1_string_canon (x_name.c:409)
  ==2690==    by 0x78EF17: x509_name_canon (x_name.c:354)
  ==2690==    by 0x78EA7D: x509_name_ex_d2i (x_name.c:210)
  ==2690==    by 0x788058: ASN1_item_ex_d2i (tasn_dec.c:239)
  ==2690==    by 0x7890D4: asn1_template_noexp_d2i (tasn_dec.c:746)
  ==2690==    by 0x788CB6: asn1_template_ex_d2i (tasn_dec.c:607)
  ==2690==    by 0x78877A: ASN1_item_ex_d2i (tasn_dec.c:448)
  ==2690==    by 0x7890D4: asn1_template_noexp_d2i (tasn_dec.c:746)
  ==2690==    by 0x788CB6: asn1_template_ex_d2i (tasn_dec.c:607)
  ==2690==    by 0x78877A: ASN1_item_ex_d2i (tasn_dec.c:448)
  ==2690==    by 0x787C93: ASN1_item_d2i (tasn_dec.c:136)
  ==2690==    by 0x78F5E4: d2i_X509 (x_x509.c:141)
  ==2690==    by 0x7C9B91: PEM_ASN1_read_bio (pem_oth.c:81)
  ==2690==    by 0x7CA506: PEM_read_bio_X509 (pem_x509.c:67)
  ==2690==    by 0x703C9A: node::crypto::SecureContext::AddRootCerts(v8::Arguments const&) (node_crypto.cc:497)
  ==2690==  Uninitialised value was created by a stack allocation
  ==2690==    at 0x782E89: ASN1_STRING_to_UTF8 (a_strex.c:560)
(cherry picked from commit ad707ba223daa577a6716f7e787695194eb1d836)
build: use the openssl android configuration for "arm" builds

(cherry picked from commit ae966930717ba18e354ee462bbe3d0c4a13fea95)

Conflicts:

	deps/openssl/openssl.gyp
build: tweak the openssl android configuration to build

Removed NO_CAST, NO_MD2 and NO_STORE because otherwise there were build errors.

Added NO_CAMELLIA, NO_MDC2, and NO_CMS because otherwise there were linker errors.
(cherry picked from commit f5f8fafc820337ce6863f3c2a7059055bf845f3e)
openssl: add optimized bignum x64 asm code for windows

(cherry picked from commit 2b6c9a855e7a45dd2f628e1122e5638ab415a941)
openssl: fix perlasm issue

When perlasm generates MASM code it sets the assembler target to 468.
In this mode MASM refuses to assemble the CPUID instruction. Bumping
the target to 586 solves this problem.
(cherry picked from commit fb8c1e6de52c9272435be9fb1ae4cdf89634fe42)
openssl: disable HT sidechannel attack mitigation

It used to be off before. It's extremely unlikely that such an attack
would be a viable attack against node. And it makes AES much slower.
(cherry picked from commit b7e77ab91c1a3feedf9c63dc14f40b8294632c03)
cherry-pick openssl patches

Cherry-picked from:
0f9d201183396c423bcfc6027ac2ce883e28cec5
3694b6914a68e655c51a3d3ba8f538231bf07d1e
d2fb507556498b9450b6397ac17e821edcab9a68
e0e9f0c15ac9fba896dd135ced1afa2601687dfe

Conflicts:

	deps/openssl/openssl.gyp
openssl: fix compilation issues on SmartOS x64

the SunOS linker is more strict than usual, so we have to be more
correct.
temp: add references to original commits