@@ -3257,10 +3257,10 @@ impl StreamCipher for Aes128Ctr {
32573257 // wolfCrypt AES-CTR supports in-place operation (out == in).
32583258 let in_ptr = buf. get_in ( ) . as_ptr ( ) ;
32593259 let out_ptr = buf. get_out ( ) . as_mut_ptr ( ) ;
3260- // SAFETY: CTR in-place is valid; raw ptrs used to avoid aliasing rules.
3261- let in_slice = unsafe { core :: slice :: from_raw_parts ( in_ptr , len ) } ;
3262- let out_slice = unsafe { core :: slice :: from_raw_parts_mut ( out_ptr, len) } ;
3263- self . inner . encrypt ( in_slice , out_slice ) . expect ( "wc_AesCtrEncrypt failed" ) ;
3260+ // SAFETY: CTR in-place is valid; C function called directly to avoid
3261+ // creating aliasing slices.
3262+ let rc = unsafe { sys :: wc_AesCtrEncrypt ( & mut self . inner . ws_aes , out_ptr, in_ptr , len as u32 ) } ;
3263+ assert_eq ! ( rc , 0 , "wc_AesCtrEncrypt failed" ) ;
32643264 }
32653265
32663266 fn unchecked_write_keystream ( & mut self , buf : & mut [ u8 ] ) {
@@ -3305,10 +3305,10 @@ impl StreamCipher for Aes192Ctr {
33053305 if len == 0 { return ; }
33063306 let in_ptr = buf. get_in ( ) . as_ptr ( ) ;
33073307 let out_ptr = buf. get_out ( ) . as_mut_ptr ( ) ;
3308- // SAFETY: CTR in-place is valid; raw ptrs used to avoid aliasing rules.
3309- let in_slice = unsafe { core :: slice :: from_raw_parts ( in_ptr , len ) } ;
3310- let out_slice = unsafe { core :: slice :: from_raw_parts_mut ( out_ptr, len) } ;
3311- self . inner . encrypt ( in_slice , out_slice ) . expect ( "wc_AesCtrEncrypt failed" ) ;
3308+ // SAFETY: CTR in-place is valid; C function called directly to avoid
3309+ // creating aliasing slices.
3310+ let rc = unsafe { sys :: wc_AesCtrEncrypt ( & mut self . inner . ws_aes , out_ptr, in_ptr , len as u32 ) } ;
3311+ assert_eq ! ( rc , 0 , "wc_AesCtrEncrypt failed" ) ;
33123312 }
33133313
33143314 fn unchecked_write_keystream ( & mut self , buf : & mut [ u8 ] ) {
@@ -3353,10 +3353,10 @@ impl StreamCipher for Aes256Ctr {
33533353 if len == 0 { return ; }
33543354 let in_ptr = buf. get_in ( ) . as_ptr ( ) ;
33553355 let out_ptr = buf. get_out ( ) . as_mut_ptr ( ) ;
3356- // SAFETY: CTR in-place is valid; raw ptrs used to avoid aliasing rules.
3357- let in_slice = unsafe { core :: slice :: from_raw_parts ( in_ptr , len ) } ;
3358- let out_slice = unsafe { core :: slice :: from_raw_parts_mut ( out_ptr, len) } ;
3359- self . inner . encrypt ( in_slice , out_slice ) . expect ( "wc_AesCtrEncrypt failed" ) ;
3356+ // SAFETY: CTR in-place is valid; C function called directly to avoid
3357+ // creating aliasing slices.
3358+ let rc = unsafe { sys :: wc_AesCtrEncrypt ( & mut self . inner . ws_aes , out_ptr, in_ptr , len as u32 ) } ;
3359+ assert_eq ! ( rc , 0 , "wc_AesCtrEncrypt failed" ) ;
33603360 }
33613361
33623362 fn unchecked_write_keystream ( & mut self , buf : & mut [ u8 ] ) {
@@ -3410,10 +3410,10 @@ impl StreamCipher for Aes128Ofb {
34103410 // wolfCrypt AES-OFB supports in-place operation (out == in).
34113411 let in_ptr = buf. get_in ( ) . as_ptr ( ) ;
34123412 let out_ptr = buf. get_out ( ) . as_mut_ptr ( ) ;
3413- // SAFETY: OFB in-place is valid; raw ptrs used to avoid aliasing rules.
3414- let in_slice = unsafe { core :: slice :: from_raw_parts ( in_ptr , len ) } ;
3415- let out_slice = unsafe { core :: slice :: from_raw_parts_mut ( out_ptr, len) } ;
3416- self . inner . encrypt ( in_slice , out_slice ) . expect ( "wc_AesOfbEncrypt failed" ) ;
3413+ // SAFETY: OFB in-place is valid; C function called directly to avoid
3414+ // creating aliasing slices.
3415+ let rc = unsafe { sys :: wc_AesOfbEncrypt ( & mut self . inner . ws_aes , out_ptr, in_ptr , len as u32 ) } ;
3416+ assert_eq ! ( rc , 0 , "wc_AesOfbEncrypt failed" ) ;
34173417 }
34183418
34193419 fn unchecked_write_keystream ( & mut self , buf : & mut [ u8 ] ) {
@@ -3458,10 +3458,10 @@ impl StreamCipher for Aes192Ofb {
34583458 if len == 0 { return ; }
34593459 let in_ptr = buf. get_in ( ) . as_ptr ( ) ;
34603460 let out_ptr = buf. get_out ( ) . as_mut_ptr ( ) ;
3461- // SAFETY: OFB in-place is valid; raw ptrs used to avoid aliasing rules.
3462- let in_slice = unsafe { core :: slice :: from_raw_parts ( in_ptr , len ) } ;
3463- let out_slice = unsafe { core :: slice :: from_raw_parts_mut ( out_ptr, len) } ;
3464- self . inner . encrypt ( in_slice , out_slice ) . expect ( "wc_AesOfbEncrypt failed" ) ;
3461+ // SAFETY: OFB in-place is valid; C function called directly to avoid
3462+ // creating aliasing slices.
3463+ let rc = unsafe { sys :: wc_AesOfbEncrypt ( & mut self . inner . ws_aes , out_ptr, in_ptr , len as u32 ) } ;
3464+ assert_eq ! ( rc , 0 , "wc_AesOfbEncrypt failed" ) ;
34653465 }
34663466
34673467 fn unchecked_write_keystream ( & mut self , buf : & mut [ u8 ] ) {
@@ -3506,10 +3506,10 @@ impl StreamCipher for Aes256Ofb {
35063506 if len == 0 { return ; }
35073507 let in_ptr = buf. get_in ( ) . as_ptr ( ) ;
35083508 let out_ptr = buf. get_out ( ) . as_mut_ptr ( ) ;
3509- // SAFETY: OFB in-place is valid; raw ptrs used to avoid aliasing rules.
3510- let in_slice = unsafe { core :: slice :: from_raw_parts ( in_ptr , len ) } ;
3511- let out_slice = unsafe { core :: slice :: from_raw_parts_mut ( out_ptr, len) } ;
3512- self . inner . encrypt ( in_slice , out_slice ) . expect ( "wc_AesOfbEncrypt failed" ) ;
3509+ // SAFETY: OFB in-place is valid; C function called directly to avoid
3510+ // creating aliasing slices.
3511+ let rc = unsafe { sys :: wc_AesOfbEncrypt ( & mut self . inner . ws_aes , out_ptr, in_ptr , len as u32 ) } ;
3512+ assert_eq ! ( rc , 0 , "wc_AesOfbEncrypt failed" ) ;
35133513 }
35143514
35153515 fn unchecked_write_keystream ( & mut self , buf : & mut [ u8 ] ) {
0 commit comments