forked from wolfSSL/wolfssl
fixes for clang -Os on clang >= 12.0.0; fixes for bugs in blake2s.
This commit is contained in:
@@ -7354,7 +7354,7 @@ then
|
||||
AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_HUGE_CFLAGS"
|
||||
fi
|
||||
else
|
||||
if test "$ENABLED_SP" = "yes" && test "$ENABLED_SP_SMALL" = "no"
|
||||
if (test "$ENABLED_SP" = "yes" || test "$ENABLED_SP_MATH_ALL" = "yes") && test "$ENABLED_SP_SMALL" = "no"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_FAST_CFLAGS"
|
||||
if test "$ENABLED_FASTHUGEMATH" = "yes"
|
||||
|
@@ -120,10 +120,13 @@ int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
|
||||
}
|
||||
|
||||
|
||||
|
||||
int blake2b_init( blake2b_state *S, const byte outlen )
|
||||
{
|
||||
#ifdef WOLFSSL_BLAKE2B_INIT_EACH_FIELD
|
||||
blake2b_param P[1];
|
||||
#else
|
||||
volatile blake2b_param P[1];
|
||||
#endif
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return BAD_FUNC_ARG;
|
||||
|
||||
@@ -140,12 +143,12 @@ int blake2b_init( blake2b_state *S, const byte outlen )
|
||||
XMEMSET( P->salt, 0, sizeof( P->salt ) );
|
||||
XMEMSET( P->personal, 0, sizeof( P->personal ) );
|
||||
#else
|
||||
XMEMSET( P, 0, sizeof( *P ) );
|
||||
XMEMSET( (blake2b_param *)P, 0, sizeof( *P ) );
|
||||
P->digest_length = outlen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
#endif
|
||||
return blake2b_init_param( S, P );
|
||||
return blake2b_init_param( S, (blake2b_param *)P );
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +156,11 @@ int blake2b_init_key( blake2b_state *S, const byte outlen, const void *key,
|
||||
const byte keylen )
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef WOLFSSL_BLAKE2B_INIT_EACH_FIELD
|
||||
blake2b_param P[1];
|
||||
#else
|
||||
volatile blake2b_param P[1];
|
||||
#endif
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return BAD_FUNC_ARG;
|
||||
|
||||
@@ -172,14 +179,14 @@ int blake2b_init_key( blake2b_state *S, const byte outlen, const void *key,
|
||||
XMEMSET( P->salt, 0, sizeof( P->salt ) );
|
||||
XMEMSET( P->personal, 0, sizeof( P->personal ) );
|
||||
#else
|
||||
XMEMSET( P, 0, sizeof( *P ) );
|
||||
XMEMSET( (blake2b_param *)P, 0, sizeof( *P ) );
|
||||
P->digest_length = outlen;
|
||||
P->key_length = keylen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
#endif
|
||||
|
||||
ret = blake2b_init_param( S, P );
|
||||
ret = blake2b_init_param( S, (blake2b_param *)P );
|
||||
if ( ret < 0 ) return ret;
|
||||
|
||||
{
|
||||
|
@@ -119,7 +119,11 @@ int blake2s_init_param( blake2s_state *S, const blake2s_param *P )
|
||||
|
||||
int blake2s_init( blake2s_state *S, const byte outlen )
|
||||
{
|
||||
#ifdef WOLFSSL_BLAKE2S_INIT_EACH_FIELD
|
||||
blake2s_param P[1];
|
||||
#else
|
||||
volatile blake2s_param P[1];
|
||||
#endif
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return BAD_FUNC_ARG;
|
||||
|
||||
@@ -132,16 +136,15 @@ int blake2s_init( blake2s_state *S, const byte outlen )
|
||||
store32( &P->node_offset, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
XMEMSET( P->reserved, 0, sizeof( P->reserved ) );
|
||||
XMEMSET( P->salt, 0, sizeof( P->salt ) );
|
||||
XMEMSET( P->personal, 0, sizeof( P->personal ) );
|
||||
#else
|
||||
XMEMSET( P, 0, sizeof( *P ) );
|
||||
XMEMSET( (blake2s_param *)P, 0, sizeof( *P ) );
|
||||
P->digest_length = outlen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
#endif
|
||||
return blake2s_init_param( S, P );
|
||||
return blake2s_init_param( S, (blake2s_param *)P );
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +152,11 @@ int blake2s_init_key( blake2s_state *S, const byte outlen, const void *key,
|
||||
const byte keylen )
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef WOLFSSL_BLAKE2S_INIT_EACH_FIELD
|
||||
blake2s_param P[1];
|
||||
#else
|
||||
volatile blake2s_param P[1];
|
||||
#endif
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return BAD_FUNC_ARG;
|
||||
|
||||
@@ -164,18 +171,17 @@ int blake2s_init_key( blake2s_state *S, const byte outlen, const void *key,
|
||||
store64( &P->node_offset, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
XMEMSET( P->reserved, 0, sizeof( P->reserved ) );
|
||||
XMEMSET( P->salt, 0, sizeof( P->salt ) );
|
||||
XMEMSET( P->personal, 0, sizeof( P->personal ) );
|
||||
#else
|
||||
XMEMSET( P, 0, sizeof( *P ) );
|
||||
XMEMSET( (blake2s_param *)P, 0, sizeof( *P ) );
|
||||
P->digest_length = outlen;
|
||||
P->key_length = keylen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
#endif
|
||||
|
||||
ret = blake2s_init_param( S, P );
|
||||
ret = blake2s_init_param( S, (blake2s_param *)P );
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
@@ -93,6 +93,12 @@ This library provides single precision (SP) integer math functions.
|
||||
* WOLFSSL_SP_FAST_MODEXP Allow fast mod_exp with small C code
|
||||
*/
|
||||
|
||||
/* WOLFSSL_SP_SMALL is incompatibile with clang-12+ -Os. */
|
||||
#if defined(__clang__) && defined(__clang_major__) && \
|
||||
(__clang_major__ >= 12) && defined(WOLFSSL_SP_SMALL)
|
||||
#undef WOLFSSL_SP_SMALL
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/sp_int.h>
|
||||
|
||||
/* DECL_SP_INT: Declare one variable of type 'sp_int'. */
|
||||
|
@@ -73,7 +73,7 @@
|
||||
byte node_depth; /* 15 */
|
||||
byte inner_length; /* 16 */
|
||||
/* byte reserved[0]; */
|
||||
byte salt[BLAKE2B_SALTBYTES]; /* 24 */
|
||||
byte salt[BLAKE2S_SALTBYTES]; /* 24 */
|
||||
byte personal[BLAKE2S_PERSONALBYTES]; /* 32 */
|
||||
} blake2s_param;
|
||||
|
||||
|
Reference in New Issue
Block a user