(mbedtls) Some C89_BUILD fixes - doesn't compile yet

This commit is contained in:
twinaphex 2020-07-01 04:19:45 +02:00
parent ae7353993a
commit a9d29758b6
3 changed files with 11 additions and 15 deletions

View File

@ -23,6 +23,8 @@
#ifndef MBEDTLS_SSL_INTERNAL_H #ifndef MBEDTLS_SSL_INTERNAL_H
#define MBEDTLS_SSL_INTERNAL_H #define MBEDTLS_SSL_INTERNAL_H
#include <retro_inline.h>
#include "ssl.h" #include "ssl.h"
#if defined(MBEDTLS_MD5_C) #if defined(MBEDTLS_MD5_C)
@ -45,11 +47,6 @@
#include "ecjpake.h" #include "ecjpake.h"
#endif #endif
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
!defined(inline) && !defined(__cplusplus)
#define inline __inline
#endif
/* Determine minimum supported version */ /* Determine minimum supported version */
#define MBEDTLS_SSL_MIN_MAJOR_VERSION MBEDTLS_SSL_MAJOR_VERSION_3 #define MBEDTLS_SSL_MIN_MAJOR_VERSION MBEDTLS_SSL_MAJOR_VERSION_3
@ -353,7 +350,7 @@ void mbedtls_ssl_sig_hash_set_const_hash( mbedtls_ssl_sig_hash_set_t *set,
mbedtls_md_type_t md_alg ); mbedtls_md_type_t md_alg );
/* Setup an empty signature-hash set */ /* Setup an empty signature-hash set */
static inline void mbedtls_ssl_sig_hash_set_init( mbedtls_ssl_sig_hash_set_t *set ) static INLINE void mbedtls_ssl_sig_hash_set_init( mbedtls_ssl_sig_hash_set_t *set )
{ {
mbedtls_ssl_sig_hash_set_const_hash( set, MBEDTLS_MD_NONE ); mbedtls_ssl_sig_hash_set_const_hash( set, MBEDTLS_MD_NONE );
} }
@ -506,7 +503,7 @@ int mbedtls_ssl_check_sig_hash( const mbedtls_ssl_context *ssl,
#endif #endif
#if defined(MBEDTLS_X509_CRT_PARSE_C) #if defined(MBEDTLS_X509_CRT_PARSE_C)
static inline mbedtls_pk_context *mbedtls_ssl_own_key( mbedtls_ssl_context *ssl ) static INLINE mbedtls_pk_context *mbedtls_ssl_own_key( mbedtls_ssl_context *ssl )
{ {
mbedtls_ssl_key_cert *key_cert; mbedtls_ssl_key_cert *key_cert;
@ -518,7 +515,7 @@ static inline mbedtls_pk_context *mbedtls_ssl_own_key( mbedtls_ssl_context *ssl
return( key_cert == NULL ? NULL : key_cert->key ); return( key_cert == NULL ? NULL : key_cert->key );
} }
static inline mbedtls_x509_crt *mbedtls_ssl_own_cert( mbedtls_ssl_context *ssl ) static INLINE mbedtls_x509_crt *mbedtls_ssl_own_cert( mbedtls_ssl_context *ssl )
{ {
mbedtls_ssl_key_cert *key_cert; mbedtls_ssl_key_cert *key_cert;
@ -550,7 +547,7 @@ void mbedtls_ssl_write_version( int major, int minor, int transport,
void mbedtls_ssl_read_version( int *major, int *minor, int transport, void mbedtls_ssl_read_version( int *major, int *minor, int transport,
const unsigned char ver[2] ); const unsigned char ver[2] );
static inline size_t mbedtls_ssl_hdr_len( const mbedtls_ssl_context *ssl ) static INLINE size_t mbedtls_ssl_hdr_len( const mbedtls_ssl_context *ssl )
{ {
#if defined(MBEDTLS_SSL_PROTO_DTLS) #if defined(MBEDTLS_SSL_PROTO_DTLS)
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
@ -561,7 +558,7 @@ static inline size_t mbedtls_ssl_hdr_len( const mbedtls_ssl_context *ssl )
return( 5 ); return( 5 );
} }
static inline size_t mbedtls_ssl_hs_hdr_len( const mbedtls_ssl_context *ssl ) static INLINE size_t mbedtls_ssl_hs_hdr_len( const mbedtls_ssl_context *ssl )
{ {
#if defined(MBEDTLS_SSL_PROTO_DTLS) #if defined(MBEDTLS_SSL_PROTO_DTLS)
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
@ -585,7 +582,7 @@ void mbedtls_ssl_dtls_replay_update( mbedtls_ssl_context *ssl );
#endif #endif
/* constant-time buffer comparison */ /* constant-time buffer comparison */
static inline int mbedtls_ssl_safer_memcmp( const void *a, const void *b, size_t n ) static INLINE int mbedtls_ssl_safer_memcmp( const void *a, const void *b, size_t n )
{ {
size_t i; size_t i;
const unsigned char *A = (const unsigned char *) a; const unsigned char *A = (const unsigned char *) a;

View File

@ -946,8 +946,7 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl )
*p++ = MBEDTLS_SSL_COMPRESS_NULL; *p++ = MBEDTLS_SSL_COMPRESS_NULL;
} }
// First write extensions, then the total length /* First write extensions, then the total length */
//
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
ssl_write_hostname_ext( ssl, p + 2 + ext_len, &olen ); ssl_write_hostname_ext( ssl, p + 2 + ext_len, &olen );
ext_len += olen; ext_len += olen;

View File

@ -50,7 +50,7 @@
#include "arc4_alt.h" #include "arc4_alt.h"
/* Length of the "epoch" field in the record header */ /* Length of the "epoch" field in the record header */
static inline size_t ssl_ep_len( const mbedtls_ssl_context *ssl ) static INLINE size_t ssl_ep_len( const mbedtls_ssl_context *ssl )
{ {
#if defined(MBEDTLS_SSL_PROTO_DTLS) #if defined(MBEDTLS_SSL_PROTO_DTLS)
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
@ -3040,7 +3040,7 @@ static void ssl_dtls_replay_reset( mbedtls_ssl_context *ssl )
ssl->in_window = 0; ssl->in_window = 0;
} }
static inline uint64_t ssl_load_six_bytes( unsigned char *buf ) static INLINE uint64_t ssl_load_six_bytes( unsigned char *buf )
{ {
return( ( (uint64_t) buf[0] << 40 ) | return( ( (uint64_t) buf[0] << 40 ) |
( (uint64_t) buf[1] << 32 ) | ( (uint64_t) buf[1] << 32 ) |