Add support for sending hex parameters
diff --git a/tests/scripts/mbedtls_test.py b/tests/scripts/mbedtls_test.py
index 19893ff..fa5b507 100644
--- a/tests/scripts/mbedtls_test.py
+++ b/tests/scripts/mbedtls_test.py
@@ -160,6 +160,28 @@
         """
         b += bytearray((4 - (len(b))) % 4)
 
+    @staticmethod
+    def hex_str_bytes(hex_str):
+        """
+        Converts Hex string representation to byte array
+
+        :param hex_str:
+        :return:
+        """
+        assert hex_str[0] == '"' and hex_str[len(hex_str) - 1] == '"', \
+            "HEX test parameter missing '\"': %s" % hex_str
+        hex_str = hex_str.strip('"')
+        assert len(hex_str) % 2 == 0, "HEX parameter len should be mod of 2: %s" % hex_str
+        b = bytearray()
+
+        for i in xrange(len(hex_str) / 2):
+            h = hex_str[i * 2] + hex_str[(i * 2) + 1]
+            try:
+                b += bytearray([int(h, 16)])
+            except ValueError:
+                raise ValueError("Invalid HEX value: %s" % hex_str)
+        return b
+
     def parameters_to_bytes(self, b, parameters):
         for typ, param in parameters:
             if typ == 'int' or typ == 'exp':
@@ -175,6 +197,13 @@
                 b += bytearray([((i >> x) & 0xff) for x in [24, 16, 8, 0]])
                 b += bytearray(list(param))
                 b += '\0'   # Null terminate
+            elif typ == 'hex':
+                hb = self.hex_str_bytes(param)
+                b += 'H'
+                self.align_32bit(b)
+                i = len(hb)
+                b += bytearray([((i >> x) & 0xff) for x in [24, 16, 8, 0]])
+                b += hb
         return b
 
     def run_next_test(self):
diff --git a/tests/suites/embedded_test.function b/tests/suites/embedded_test.function
index e885a0e..ba59089 100644
--- a/tests/suites/embedded_test.function
+++ b/tests/suites/embedded_test.function
@@ -156,6 +156,47 @@
 }
 
 /**
+ * \brief       Parses received byte array and finds number of hex parameters.
+ *
+ * \param count     Parameter count
+ * \param data      Received Byte array
+ * \param data_len  Byte array length
+ *
+ * \return      count of hex params
+ */
+uint32_t find_hex_count( uint8_t count, uint8_t * data, uint32_t data_len )
+{
+    uint32_t i = 0, sz = 0;
+    char c;
+    uint8_t * p = NULL;
+    uint32_t hex_count = 0;
+
+    p = data;
+
+    for( i = 0; i < count; i++ )
+    {
+        c = (char)*p;
+        INCR_ASSERT( p, data, data_len, 1 );
+
+        /* Align p to 4 bytes for int, expression, string len or hex length */
+        ALIGN_32BIT( p, data, data_len );
+
+        /* Network to host conversion */
+        sz = (int32_t)parse_uint32( p );
+
+        INCR_ASSERT( p, data, data_len, sizeof( int32_t ) );
+
+        if ( c == 'H' || c == 'S' )
+        {
+            INCR_ASSERT( p, data, data_len, sz );
+            hex_count += ( c == 'H' )?1:0;
+        }
+    }
+
+    return( hex_count );
+}
+
+/**
  * \brief       Parses received byte array for test parameters.
  *
  * \param count     Parameter count
@@ -170,15 +211,16 @@
 void ** parse_parameters( uint8_t count, uint8_t * data, uint32_t data_len,
                             int * error )
 {
-    uint32_t i = 0;
+    uint32_t i = 0, hex_count = 0;
     char c;
     void ** params = NULL;
     void ** cur = NULL;
     uint8_t * p = NULL;
 
-    params = (void **)malloc( sizeof( void *) * ( count + 1 ) );
+    hex_count = find_hex_count(count, data, data_len);
+
+    params = (void **)malloc( sizeof( void *) * ( count + hex_count ) );
     assert( params != NULL );
-    params[count] = NULL;
     cur = params;
 
     p = data;
@@ -211,16 +253,15 @@
                     INCR_ASSERT( p, data, data_len, sizeof( int32_t ) );
                 }
                 break;
-            case 'H':
-                {
-                    *cur++ = (void *)p;
-                } /* Intentional fall through */
+            case 'H': /* Intentional fall through */
             case 'S':
                 {
-                    uint32_t sz = *( (int32_t *)p );
+                    uint32_t * sz = (uint32_t *)p;
                     INCR_ASSERT( p, data, data_len, sizeof( int32_t ) );
                     *cur++ = (void *)p;
-                    INCR_ASSERT( p, data, data_len, sz );
+                    if ( c == 'H' )
+                        *cur++ = (void *)sz;
+                    INCR_ASSERT( p, data, data_len, ( *sz ) );
                 }
                 break;
             default:
@@ -324,7 +365,8 @@
             if ( ret != DEPENDENCY_SUPPORTED )
                 break;
 
-            INCR_ASSERT( p, data, data_len, count );
+            if ( count )
+                INCR_ASSERT( p, data, data_len, count );
 
             /* Read function id */
             function_id = *p;
@@ -334,9 +376,13 @@
             count = *p;
             INCR_ASSERT( p, data, data_len, sizeof( uint8_t ) );
 
-            params = parse_parameters( count, p, data_len - (p - data), &ret );
-            if ( ret )
-                break;
+            /* Parse parameters if present */
+            if ( count )
+            {
+                params = parse_parameters( count, p, data_len - ( p - data ), &ret );
+                if ( ret )
+                    break;
+            }
 
             ret = dispatch_test( function_id, params );
         }