@@ -391,16 +391,15 @@ int wc_ed448_sign_msg_ex(const byte* in, word32 inLen, byte* out,
391391#else
392392 wc_Shake sha [1 ];
393393 ret = ed448_hash_init (key , sha );
394- if (ret < 0 )
395- return ret ;
396394#endif
397395 /* apply clamp */
398396 az [0 ] &= 0xfc ;
399397 az [55 ] |= 0x80 ;
400398 az [56 ] = 0x00 ;
401399
402- ret = ed448_hash_update (key , sha , ed448Ctx , ED448CTX_SIZE );
403-
400+ if (ret == 0 ) {
401+ ret = ed448_hash_update (key , sha , ed448Ctx , ED448CTX_SIZE );
402+ }
404403 if (ret == 0 ) {
405404 ret = ed448_hash_update (key , sha , & type , sizeof (type ));
406405 }
@@ -429,15 +428,14 @@ int wc_ed448_sign_msg_ex(const byte* in, word32 inLen, byte* out,
429428#else
430429 wc_Shake sha [1 ];
431430 ret = ed448_hash_init (key , sha );
432- if (ret < 0 )
433- return ret ;
434431#endif
435- sc448_reduce ( nonce );
436-
432+ if ( ret == 0 )
433+ sc448_reduce ( nonce );
437434 /* step 2: computing R = rB where rB is the scalar multiplication of
438435 r and B */
439- ret = ge448_scalarmult_base (& R ,nonce );
440-
436+ if (ret == 0 ) {
437+ ret = ge448_scalarmult_base (& R ,nonce );
438+ }
441439 /* step 3: hash R + public key + message getting H(R,A,M) then
442440 creating S = (r + H(R,A,M)a) mod l */
443441 if (ret == 0 ) {
@@ -487,6 +485,8 @@ int wc_ed448_sign_msg_ex(const byte* in, word32 inLen, byte* out,
487485 }
488486#endif
489487
488+ ForceZero (az , sizeof (az ));
489+ ForceZero (nonce , sizeof (nonce ));
490490 return ret ;
491491}
492492
0 commit comments