Change the type of |EC_GROUP_get_degree| and friends to |unsigned|.

These functions ultimately return the result of |BN_num_bits|, and that
function's return type is |unsigned|. Thus, these functions' return
type should also be |unsigned|.

Change-Id: I2cef63e6f75425857bac71f7c5517ef22ab2296b
Reviewed-on: https://boringssl-review.googlesource.com/6170
Reviewed-by: Adam Langley <alangley@gmail.com>
diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c
index 07ce9f3..13bc0e8 100644
--- a/ssl/s3_clnt.c
+++ b/ssl/s3_clnt.c
@@ -1566,6 +1566,8 @@
   return 1;
 }
 
+OPENSSL_COMPILE_ASSERT(sizeof(size_t) >= sizeof(unsigned),
+                       SIZE_T_IS_SMALLER_THAN_UNSIGNED);
 
 int ssl3_send_client_key_exchange(SSL *s) {
   uint8_t *p;
@@ -1739,7 +1741,7 @@
     } else if (alg_k & SSL_kECDHE) {
       const EC_GROUP *srvr_group = NULL;
       EC_KEY *tkey;
-      int field_size = 0, ecdh_len;
+      int ecdh_len;
 
       if (s->s3->tmp.peer_ecdh_tmp == NULL) {
         OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
@@ -1772,8 +1774,8 @@
         goto err;
       }
 
-      field_size = EC_GROUP_get_degree(srvr_group);
-      if (field_size <= 0) {
+      unsigned field_size = EC_GROUP_get_degree(srvr_group);
+      if (field_size == 0) {
         OPENSSL_PUT_ERROR(SSL, ERR_R_ECDH_LIB);
         goto err;
       }
diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c
index c9b8172..fad2d0a 100644
--- a/ssl/s3_srvr.c
+++ b/ssl/s3_srvr.c
@@ -1854,7 +1854,7 @@
 
     premaster_secret_len = dh_len;
   } else if (alg_k & SSL_kECDHE) {
-    int field_size = 0, ecdh_len;
+    int ecdh_len;
     const EC_KEY *tkey;
     const EC_GROUP *group;
     const BIGNUM *priv_key;
@@ -1909,8 +1909,8 @@
     }
 
     /* Allocate a buffer for both the secret and the PSK. */
-    field_size = EC_GROUP_get_degree(group);
-    if (field_size <= 0) {
+    unsigned field_size = EC_GROUP_get_degree(group);
+    if (field_size == 0) {
       OPENSSL_PUT_ERROR(SSL, ERR_R_ECDH_LIB);
       goto err;
     }