More fixes for BoringSSL compilation.

EC_GROUP_set_point_conversion_form has been removed in BoringSSL because
it didn't do anything.

Also, BoringSSL uses size_t and keymaster builds with a signed/unsigned
mismatch as a fatal error. This means that the casts to int aren't
needed in BoringSSL and, in fact, cause an error.

Change-Id: I52b7d34a5c90f40cfcc84c60b746404f374b1e80
diff --git a/ecdsa_key.cpp b/ecdsa_key.cpp
index a9f4ba7..84d9649 100644
--- a/ecdsa_key.cpp
+++ b/ecdsa_key.cpp
@@ -49,8 +49,8 @@
         return NULL;
     }
 
-    EC_GROUP_set_point_conversion_form(group.get(), POINT_CONVERSION_UNCOMPRESSED);
 #if !defined(OPENSSL_IS_BORINGSSL)
+    EC_GROUP_set_point_conversion_form(group.get(), POINT_CONVERSION_UNCOMPRESSED);
     EC_GROUP_set_asn1_flag(group.get(), OPENSSL_EC_NAMED_CURVE);
 #endif
 
diff --git a/hmac_operation.cpp b/hmac_operation.cpp
index a179655..9050f99 100644
--- a/hmac_operation.cpp
+++ b/hmac_operation.cpp
@@ -19,6 +19,12 @@
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
 
+#if defined(OPENSSL_IS_BORINGSSL)
+typedef size_t openssl_size_t;
+#else
+typedef int openssl_size_t;
+#endif
+
 namespace keymaster {
 
 HmacOperation::HmacOperation(keymaster_purpose_t purpose, const Logger& logger,
@@ -47,7 +53,7 @@
         return;
     }
 
-    if ((int)tag_length_ > EVP_MD_size(md)) {
+    if ((openssl_size_t)tag_length_ > EVP_MD_size(md)) {
         error_ = KM_ERROR_UNSUPPORTED_MAC_LENGTH;
         return;
     }
diff --git a/rsa_key.cpp b/rsa_key.cpp
index c904c19..2e27883 100644
--- a/rsa_key.cpp
+++ b/rsa_key.cpp
@@ -19,6 +19,12 @@
 #include "rsa_operation.h"
 #include "unencrypted_key_blob.h"
 
+#if defined(OPENSSL_IS_BORINGSSL)
+typedef size_t openssl_size_t;
+#else
+typedef int openssl_size_t;
+#endif
+
 namespace keymaster {
 
 const uint32_t RSA_DEFAULT_KEY_SIZE = 2048;
@@ -95,7 +101,7 @@
     uint32_t key_size;
     if (authorizations.GetTagValue(TAG_KEY_SIZE, &key_size)) {
         // key_size specified, make sure it matches the key.
-        if (RSA_size(rsa_key.get()) != (int)key_size) {
+        if (RSA_size(rsa_key.get()) != (openssl_size_t)key_size) {
             *error = KM_ERROR_IMPORT_PARAMETER_MISMATCH;
             return NULL;
         }