Use function for 16/24/32-bit BE conversion
Use functions for 16/24/32-bit big endian conversion to save ROM.
diff --git a/library/ssl_cookie.c b/library/ssl_cookie.c
index 6f0be8a..a06cc3c 100644
--- a/library/ssl_cookie.c
+++ b/library/ssl_cookie.c
@@ -172,12 +172,7 @@
#else
t = ctx->serial++;
#endif
-
- (*p)[0] = (unsigned char)( t >> 24 );
- (*p)[1] = (unsigned char)( t >> 16 );
- (*p)[2] = (unsigned char)( t >> 8 );
- (*p)[3] = (unsigned char)( t );
- *p += 4;
+ *p = mbedtls_platform_put_uint32_be( *p, t );
#if defined(MBEDTLS_THREADING_C)
if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
@@ -243,10 +238,7 @@
cur_time = ctx->serial;
#endif
- cookie_time = ( (unsigned long) cookie[0] << 24 ) |
- ( (unsigned long) cookie[1] << 16 ) |
- ( (unsigned long) cookie[2] << 8 ) |
- ( (unsigned long) cookie[3] );
+ cookie_time = mbedtls_platform_get_uint32_be( cookie );
if( ctx->timeout != 0 && cur_time - cookie_time > ctx->timeout )
return( -1 );