@@ -83,6 +83,15 @@ typedef status_t (*hal_cryp_aes_op_func_t)(CRYP_HandleTypeDef *hcryp, uint8_t *i
8383#define hal_ctr_decrypt_op hal_decrypt
8484#endif
8585
86+ /* L4 HAL driver uses uint8_t pointers for input/output data while the generic HAL driver uses
87+ * uint32_t pointers.
88+ */
89+ #if DT_HAS_COMPAT_STATUS_OKAY (st_stm32l4_aes )
90+ #define CAST_VEC (x ) (uint8_t *)(x)
91+ #else
92+ #define CAST_VEC (x ) (uint32_t *)(x)
93+ #endif
94+
8695static int copy_words_adjust_endianness (uint8_t * dst_buf , int dst_len , const uint8_t * src_buf ,
8796 int src_len )
8897{
@@ -207,7 +216,7 @@ static int crypto_stm32_cbc_encrypt(struct cipher_ctx *ctx,
207216
208217 (void )copy_words_adjust_endianness ((uint8_t * )vec , sizeof (vec ), iv , BLOCK_LEN_BYTES );
209218
210- session -> config .pInitVect = vec ;
219+ session -> config .pInitVect = CAST_VEC ( vec ) ;
211220
212221 if ((ctx -> flags & CAP_NO_IV_PREFIX ) == 0U ) {
213222 /* Prefix IV to ciphertext unless CAP_NO_IV_PREFIX is set. */
@@ -234,7 +243,7 @@ static int crypto_stm32_cbc_decrypt(struct cipher_ctx *ctx,
234243
235244 (void )copy_words_adjust_endianness ((uint8_t * )vec , sizeof (vec ), iv , BLOCK_LEN_BYTES );
236245
237- session -> config .pInitVect = vec ;
246+ session -> config .pInitVect = CAST_VEC ( vec ) ;
238247
239248 if ((ctx -> flags & CAP_NO_IV_PREFIX ) == 0U ) {
240249 in_offset = 16 ;
@@ -261,7 +270,7 @@ static int crypto_stm32_ctr_encrypt(struct cipher_ctx *ctx,
261270 return - EIO ;
262271 }
263272
264- session -> config .pInitVect = ctr ;
273+ session -> config .pInitVect = CAST_VEC ( ctr ) ;
265274
266275 ret = do_aes (ctx , hal_ctr_encrypt_op , pkt -> in_buf , pkt -> in_len , pkt -> out_buf );
267276 if (ret == 0 ) {
@@ -284,7 +293,7 @@ static int crypto_stm32_ctr_decrypt(struct cipher_ctx *ctx,
284293 return - EIO ;
285294 }
286295
287- session -> config .pInitVect = ctr ;
296+ session -> config .pInitVect = CAST_VEC ( ctr ) ;
288297
289298 ret = do_aes (ctx , hal_ctr_decrypt_op , pkt -> in_buf , pkt -> in_len , pkt -> out_buf );
290299 if (ret == 0 ) {
@@ -450,7 +459,7 @@ static int crypto_stm32_session_setup(const struct device *dev,
450459 return - EIO ;
451460 }
452461
453- session -> config .pKey = session -> key ;
462+ session -> config .pKey = CAST_VEC ( session -> key ) ;
454463 session -> config .DataType = CRYP_DATATYPE_8B ;
455464
456465#if !DT_HAS_COMPAT_STATUS_OKAY (st_stm32l4_aes )
0 commit comments