Improve readability

Improve readability of the code:
1. move common code to `ssl_internal.h` as `static inline`.
2. Add comments.
3. Use local variables for extension size.
4. Change function signature, by adding buffer size and output length.
5. Take server srtp profile out of the loop.

Signed-off-by: Johan Pascal <johan.pascal@belledonne-communications.com>
diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h
index 1f8d176..6bcb5ec 100644
--- a/include/mbedtls/ssl.h
+++ b/include/mbedtls/ssl.h
@@ -3257,15 +3257,16 @@
  *
  * \param ssl              SSL context tobe used.
  * \param key              Buffer to hold the generated key material.
- * \param key_len          [in/out] key buffer size. outputs the actual number
- *                         of bytes written.
+ * \param key_buffer_len   Key buffer size.
+ * \param olen             the actual number of bytes written to key.
  *
  * \return                 0 on success, #MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL if
  *                         the key buffer is too small to hold the generated key.
  */
 int mbedtls_ssl_get_dtls_srtp_key_material( const mbedtls_ssl_context *ssl,
                                             unsigned char *key,
-                                            size_t *key_len );
+                                            size_t key_buffer_len,
+                                            size_t *olen );
 
 /**
  * \brief                  Utility function to get information on DTLS-SRTP profile.