Skip to content

Commit a6fb419

Browse files
Clean up header inclusions in pk_wrap.c
To better reflect what the code relies on, limit the headers that are included when MBEDTLS_USE_PSA_CRYPTO is disabled. Also stop including "pkwrite.h" when it is no longer needed. Include "mbedlts/platform_util.h" unconditionally. It was only included for RSA ALT but was also used for MBEDTLS_USE_PSA_CRYPTO (the code worked because other headers include "mbedtls/platform_util.h"). Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
1 parent c74d5ae commit a6fb419

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

library/pk_wrap.c

+11-14
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,37 @@
1919

2020
#include "common.h"
2121

22+
#include "mbedtls/platform_util.h"
23+
2224
#if defined(MBEDTLS_PK_C)
2325
#include "pk_wrap.h"
2426
#include "mbedtls/error.h"
2527

2628
/* Even if RSA not activated, for the sake of RSA-alt */
2729
#include "mbedtls/rsa.h"
2830

29-
#include <string.h>
30-
3131
#if defined(MBEDTLS_ECP_C)
3232
#include "mbedtls/ecp.h"
3333
#endif
3434

35-
#if defined(MBEDTLS_RSA_C) || defined(MBEDTLS_ECP_C)
36-
#include "pkwrite.h"
37-
#endif
38-
3935
#if defined(MBEDTLS_ECDSA_C)
4036
#include "mbedtls/ecdsa.h"
4137
#endif
4238

4339
#if defined(MBEDTLS_USE_PSA_CRYPTO)
44-
#include "mbedtls/asn1write.h"
45-
#endif
40+
#include "psa/crypto.h"
41+
#include "mbedtls/psa_util.h"
42+
#include "hash_info.h"
4643

47-
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
48-
#include "mbedtls/platform_util.h"
44+
#if defined(MBEDTLS_RSA_C)
45+
#include "pkwrite.h"
4946
#endif
5047

51-
#if defined(MBEDTLS_USE_PSA_CRYPTO)
52-
#include "psa/crypto.h"
53-
#include "mbedtls/psa_util.h"
48+
#if defined(MBEDTLS_ECDSA_C)
49+
#include "mbedtls/asn1write.h"
5450
#include "mbedtls/asn1.h"
55-
#include "hash_info.h"
5651
#endif
52+
#endif /* MBEDTLS_USE_PSA_CRYPTO */
5753

5854
#if defined(MBEDTLS_PLATFORM_C)
5955
#include "mbedtls/platform.h"
@@ -65,6 +61,7 @@
6561

6662
#include <limits.h>
6763
#include <stdint.h>
64+
#include <string.h>
6865

6966
#if defined(MBEDTLS_PSA_CRYPTO_C)
7067
int mbedtls_pk_error_from_psa( psa_status_t status )

0 commit comments

Comments
 (0)