Introduce HMAC_CTX_copy_ex and deprecate HMAC_CTX_copy.

HMAC_CTX_copy's documentation is off. It actually follows the old copy
functions which call FOO_init on dest first. Notably this means that they leak
memory if dest is currently in use.

Add HMAC_CTX_copy_ex as an analog of EVP_MD_CTX_copy and deprecate
HMAC_CTX_copy. (EVP_CIPHER_CTX_copy, in contrast, was correct from the start.)

Change-Id: I48566c858663d3f659bd356200cf862e196576c9
Reviewed-on: https://boringssl-review.googlesource.com/2694
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/include/openssl/hmac.h b/include/openssl/hmac.h
index 34c4497..6c34cdc 100644
--- a/include/openssl/hmac.h
+++ b/include/openssl/hmac.h
@@ -119,10 +119,10 @@
  * |ctx|. On entry, |ctx| must have been setup with |HMAC_Init_ex|. */
 OPENSSL_EXPORT size_t HMAC_size(const HMAC_CTX *ctx);
 
-/* HMAC_CTX_copy sets |dest| equal to |src|. On entry, |dest| must have been
+/* HMAC_CTX_copy_ex sets |dest| equal to |src|. On entry, |dest| must have been
  * initialised by calling |HMAC_CTX_init|. It returns one on success and zero
  * on error. */
-OPENSSL_EXPORT int HMAC_CTX_copy(HMAC_CTX *dest, const HMAC_CTX *src);
+OPENSSL_EXPORT int HMAC_CTX_copy_ex(HMAC_CTX *dest, const HMAC_CTX *src);
 
 /* HMAC_CTX_set_flags ORs |flags| into the flags of the underlying digests of
  * |ctx|, which must have been setup by a call to |HMAC_Init_ex|. See
@@ -137,6 +137,11 @@
 OPENSSL_EXPORT int HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len,
                              const EVP_MD *md);
 
+/* HMAC_CTX_copy calls |HMAC_CTX_init| on |dest| and then sets it equal to
+ * |src|. On entry, |dest| must /not/ be initialised for an operation with
+ * |HMAC_Init_ex|. It returns one on success and zero on error. */
+OPENSSL_EXPORT int HMAC_CTX_copy(HMAC_CTX *dest, const HMAC_CTX *src);
+
 
 /* Private functions */