Convert BN_MONT_CTX to new-style locking.

This introduces a per-RSA/DSA/DH lock. This is good for lock contention,
although pthread locks are depressingly bloated.

Change-Id: I07c4d1606fc35135fc141ebe6ba904a28c8f8a0c
Reviewed-on: https://boringssl-review.googlesource.com/4324
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/include/openssl/dsa.h b/include/openssl/dsa.h
index 69dd56b..47270f8 100644
--- a/include/openssl/dsa.h
+++ b/include/openssl/dsa.h
@@ -64,6 +64,7 @@
 
 #include <openssl/engine.h>
 #include <openssl/ex_data.h>
+#include <openssl/thread.h>
 
 #if defined(__cplusplus)
 extern "C" {
@@ -351,6 +352,7 @@
 
   int flags;
   /* Normally used to cache montgomery values */
+  CRYPTO_MUTEX method_mont_p_lock;
   BN_MONT_CTX *method_mont_p;
   int references;
   CRYPTO_EX_DATA ex_data;