@@ -718,7 +718,6 @@ type MLDSA44impl = MLDSA<
718718 MLDSA44_BETA ,
719719 MLDSA44_OMEGA ,
720720 MLDSA44_C_TILDE ,
721- // MLDSA44_POLY_VEC_H_PACKED_LEN,
722721 MLDSA44_POLY_Z_PACKED_LEN ,
723722 MLDSA44_POLY_W1_PACKED_LEN ,
724723 MLDSA44_W1_PACKED_LEN ,
@@ -914,10 +913,10 @@ impl Signature<MLDSA44PublicKey, MLDSA44PrivateKey> for MLDSA44 {
914913 fn sign_out ( sk : & MLDSA44PrivateKey , msg : & [ u8 ] , ctx : & [ u8 ] , output : & mut [ u8 ] ) -> Result < usize , SignatureError > {
915914 let mu = MuBuilder :: compute_mu ( msg, ctx, & sk. 0 . tr ) ?;
916915 if output. len ( ) < MLDSA44_SIG_LEN { return Err ( SignatureError :: LengthError ( "Output buffer insufficient size to hold signature" ) ) }
917- let mut output_sized = [ 0u8 ; MLDSA44_SIG_LEN ] ;
918- let bytes_written = Self :: sign_mu_out ( sk , & mu , & mut output_sized ) ? ;
919- output [ .. MLDSA44_SIG_LEN ] . copy_from_slice ( & output_sized ) ; // there's probably a rusty-way to get a mutable slice to the original `output`
920- // and avoid the copy, but this works for now.
916+ // let mut output_sized = [0u8; MLDSA44_SIG_LEN];
917+ let output_sized : & mut [ u8 ; MLDSA44_SIG_LEN ] = output . as_mut ( ) . try_into ( ) . unwrap ( ) ;
918+ let bytes_written = Self :: sign_mu_out ( sk , & mu , output_sized ) ? ;
919+
921920 Ok ( bytes_written)
922921 }
923922
@@ -1179,8 +1178,8 @@ impl Signature<MLDSA65PublicKey, MLDSA65PrivateKey> for MLDSA65 {
11791178 fn sign_out ( sk : & MLDSA65PrivateKey , msg : & [ u8 ] , ctx : & [ u8 ] , output : & mut [ u8 ] ) -> Result < usize , SignatureError > {
11801179 let mu = MuBuilder :: compute_mu ( msg, ctx, & sk. 0 . tr ) ?;
11811180 if output. len ( ) < MLDSA65_SIG_LEN { return Err ( SignatureError :: LengthError ( "Output buffer insufficient size to hold signature" ) ) }
1182- let mut output_sized: [ u8 ; MLDSA65_SIG_LEN ] = output[ ..MLDSA65_SIG_LEN ] . try_into ( ) . unwrap ( ) ;
1183- Self :: sign_mu_out ( sk, & mu, & mut output_sized)
1181+ let output_sized: & mut [ u8 ; MLDSA65_SIG_LEN ] = output[ ..MLDSA65_SIG_LEN ] . as_mut ( ) . try_into ( ) . unwrap ( ) ;
1182+ Self :: sign_mu_out ( sk, & mu, output_sized)
11841183 }
11851184
11861185 fn sign_init ( & mut self , sk : & MLDSA65PrivateKey ) -> Result < ( ) , SignatureError > {
@@ -1441,8 +1440,8 @@ impl Signature<MLDSA87PublicKey, MLDSA87PrivateKey> for MLDSA87 {
14411440 fn sign_out ( sk : & MLDSA87PrivateKey , msg : & [ u8 ] , ctx : & [ u8 ] , output : & mut [ u8 ] ) -> Result < usize , SignatureError > {
14421441 let mu = MuBuilder :: compute_mu ( msg, ctx, & sk. 0 . tr ) ?;
14431442 if output. len ( ) < MLDSA87_SIG_LEN { return Err ( SignatureError :: LengthError ( "Output buffer insufficient size to hold signature" ) ) }
1444- let mut output_sized: [ u8 ; MLDSA87_SIG_LEN ] = output[ ..MLDSA87_SIG_LEN ] . try_into ( ) . unwrap ( ) ;
1445- Self :: sign_mu_out ( sk, & mu, & mut output_sized)
1443+ let output_sized: & mut [ u8 ; MLDSA87_SIG_LEN ] = output[ ..MLDSA87_SIG_LEN ] . as_mut ( ) . try_into ( ) . unwrap ( ) ;
1444+ Self :: sign_mu_out ( sk, & mu, output_sized)
14461445 }
14471446
14481447 fn sign_init ( & mut self , sk : & MLDSA87PrivateKey ) -> Result < ( ) , SignatureError > {
0 commit comments