Use fewer bits for key_bitlen

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/include/mbedtls/cipher.h b/include/mbedtls/cipher.h
index 7e73e29..1a0f3ff 100644
--- a/include/mbedtls/cipher.h
+++ b/include/mbedtls/cipher.h
@@ -290,7 +290,7 @@
      * default length for variable sized ciphers.
      * Includes parity bits for ciphers like DES.
      */
-    uint16_t MBEDTLS_PRIVATE(key_bitlen);
+    uint8_t MBEDTLS_PRIVATE(key_bitlen) : 4;
 
     /** IV or nonce size, in Bytes.
      * For ciphers that accept variable IV sizes,
@@ -309,6 +309,9 @@
 
 } mbedtls_cipher_info_t;
 
+/* This is used to more compactly represent the key_bitlen field above. It is for internal use only. */
+#define MBEDTLS_KEY_BITLEN_SHIFT 6
+
 /**
  * Generic cipher context.
  */
@@ -479,7 +482,7 @@
     if (info == NULL) {
         return 0;
     } else {
-        return info->MBEDTLS_PRIVATE(key_bitlen);
+        return info->MBEDTLS_PRIVATE(key_bitlen) << MBEDTLS_KEY_BITLEN_SHIFT;
     }
 }
 
@@ -788,7 +791,7 @@
         return MBEDTLS_KEY_LENGTH_NONE;
     }
 
-    return (int) ctx->MBEDTLS_PRIVATE(cipher_info)->MBEDTLS_PRIVATE(key_bitlen);
+    return (int) ctx->MBEDTLS_PRIVATE(cipher_info)->MBEDTLS_PRIVATE(key_bitlen) << MBEDTLS_KEY_BITLEN_SHIFT;
 }
 
 /**