Add visibility rules.

This change marks public symbols as dynamically exported. This means
that it becomes viable to build a shared library of libcrypto and libssl
with -fvisibility=hidden.

On Windows, one not only needs to mark functions for export in a
component, but also for import when using them from a different
component. Because of this we have to build with
|BORINGSSL_IMPLEMENTATION| defined when building the code. Other
components, when including our headers, won't have that defined and then
the |OPENSSL_EXPORT| tag becomes an import tag instead. See the #defines
in base.h

In the asm code, symbols are now hidden by default and those that need
to be exported are wrapped by a C function.

In order to support Chromium, a couple of libssl functions were moved to
ssl.h from ssl_locl.h: ssl_get_new_session and ssl_update_cache.

Change-Id: Ib4b76e2f1983ee066e7806c24721e8626d08a261
Reviewed-on: https://boringssl-review.googlesource.com/1350
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/include/openssl/aes.h b/include/openssl/aes.h
index 8156964..11d83bb 100644
--- a/include/openssl/aes.h
+++ b/include/openssl/aes.h
@@ -80,22 +80,26 @@
  *
  * WARNING: unlike other OpenSSL functions, this returns zero on success and a
  * negative number on error. */
-int AES_set_encrypt_key(const uint8_t *key, unsigned bits, AES_KEY *aeskey);
+OPENSSL_EXPORT int AES_set_encrypt_key(const uint8_t *key, unsigned bits,
+                                       AES_KEY *aeskey);
 
 /* AES_set_decrypt_key configures |aeskey| to decrypt with the |bits|-bit key,
  * |key|.
  *
  * WARNING: unlike other OpenSSL functions, this returns zero on success and a
  * negative number on error. */
-int AES_set_decrypt_key(const uint8_t *key, unsigned bits, AES_KEY *aeskey);
+OPENSSL_EXPORT int AES_set_decrypt_key(const uint8_t *key, unsigned bits,
+                                       AES_KEY *aeskey);
 
 /* AES_encrypt encrypts a single block from |in| to |out| with |key|. The |in|
  * and |out| pointers may overlap. */
-void AES_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key);
+OPENSSL_EXPORT void AES_encrypt(const uint8_t *in, uint8_t *out,
+                                const AES_KEY *key);
 
 /* AES_decrypt decrypts a single block from |in| to |out| with |key|. The |in|
  * and |out| pointers may overlap. */
-void AES_decrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key);
+OPENSSL_EXPORT void AES_decrypt(const uint8_t *in, uint8_t *out,
+                                const AES_KEY *key);
 
 
 /* Block cipher modes. */
@@ -103,32 +107,36 @@
 /* AES_ctr128_encrypt encrypts (or decrypts, it's the same in CTR mode) |len|
  * bytes from |in| to |out|. The |num| parameter must be set to zero on the
  * first call and |ivec| will be incremented. */
-void AES_ctr128_encrypt(const uint8_t *in, uint8_t *out, size_t len,
-                        const AES_KEY *key, uint8_t ivec[AES_BLOCK_SIZE],
-                        uint8_t ecount_buf[AES_BLOCK_SIZE], unsigned int *num);
+OPENSSL_EXPORT void AES_ctr128_encrypt(const uint8_t *in, uint8_t *out,
+                                       size_t len, const AES_KEY *key,
+                                       uint8_t ivec[AES_BLOCK_SIZE],
+                                       uint8_t ecount_buf[AES_BLOCK_SIZE],
+                                       unsigned int *num);
 
 /* AES_ecb_encrypt encrypts (or decrypts, if |enc| == |AES_DECRYPT|) a single,
  * 16 byte block from |in| to |out|. */
-void AES_ecb_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key,
-                     const int enc);
+OPENSSL_EXPORT void AES_ecb_encrypt(const uint8_t *in, uint8_t *out,
+                                    const AES_KEY *key, const int enc);
 
 /* AES_cbc_encrypt encrypts (or decrypts, if |enc| == |AES_DECRYPT|) |len|
  * bytes from |in| to |out|. The length must be a multiple of the block size. */
-void AES_cbc_encrypt(const uint8_t *in, uint8_t *out, size_t len,
-                     const AES_KEY *key, uint8_t *ivec, const int enc);
+OPENSSL_EXPORT void AES_cbc_encrypt(const uint8_t *in, uint8_t *out, size_t len,
+                                    const AES_KEY *key, uint8_t *ivec,
+                                    const int enc);
 
 /* AES_ofb128_encrypt encrypts (or decrypts, it's the same in CTR mode) |len|
  * bytes from |in| to |out|. The |num| parameter must be set to zero on the
  * first call. */
-void AES_ofb128_encrypt(const uint8_t *in, uint8_t *out, size_t len,
-                        const AES_KEY *key, uint8_t *ivec, int *num);
+OPENSSL_EXPORT void AES_ofb128_encrypt(const uint8_t *in, uint8_t *out,
+                                       size_t len, const AES_KEY *key,
+                                       uint8_t *ivec, int *num);
 
 /* AES_cfb128_encrypt encrypts (or decrypts, if |enc| == |AES_DECRYPT|) |len|
  * bytes from |in| to |out|. The |num| parameter must be set to zero on the
  * first call. */
-void AES_cfb128_encrypt(const uint8_t *in, uint8_t *out, size_t len,
-                        const AES_KEY *key, uint8_t *ivec, int *num,
-                        int enc);
+OPENSSL_EXPORT void AES_cfb128_encrypt(const uint8_t *in, uint8_t *out,
+                                       size_t len, const AES_KEY *key,
+                                       uint8_t *ivec, int *num, int enc);
 
 
 #if defined(__cplusplus)