Skip to content

Commit bc636ec

Browse files
authored
Fixed some issues, preventing building project on a mac machine (#37)
* Fixed some issues, preventing building a project on mac machine: - Set up project languages manually to prevent compiler's wrong guess - Set up current platform explicitly for mac (both Intel and Apple Silicone) - Fixed a lot of warnings, mostly with PSA crypto documentation * Removed old architecture set up call * Moved explicit languages set from project to apple only * Fixed apple architectures define to support fat binary * Added CFBundleSignature to Info.plist
1 parent a0d3b95 commit bc636ec

19 files changed

+749
-24
lines changed

CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ if(MSVC)
1212
add_compile_options(/MP)
1313
endif()
1414

15-
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)" CACHE INTERNAL "")
1615
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE INTERNAL "")
1716

1817
# linux detection
@@ -25,7 +24,9 @@ message("module path = ${CMAKE_MODULE_PATH}")
2524

2625
file(GLOB source "source/*.cpp" "source/*.hpp" "source/*.h")
2726
if (APPLE)
27+
enable_language(C CXX OBJCXX)
2828
set(OBJCPP "source/AppleUtilities.h" "source/AppleUtilities.mm")
29+
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE INTERNAL "")
2930
endif()
3031
add_executable("${PROJECT_NAME}" WIN32 ${source} "source/wxmac.icns" "source/windows.rc" ${OBJCPP})
3132
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)

mbedtls/include/psa/crypto.h

+434-6
Large diffs are not rendered by default.

mbedtls/include/psa/crypto_compat.h

+8
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,16 @@ static inline int psa_key_handle_is_null( psa_key_handle_t handle )
106106
* define any way to create such a key, but it may be possible
107107
* through implementation-specific means.
108108
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
109+
* There was a communication failure inside the implementation.
109110
* \retval #PSA_ERROR_CORRUPTION_DETECTED
111+
* There was a corruption failure inside the implementation.
110112
* \retval #PSA_ERROR_STORAGE_FAILURE
113+
* There was a storage failure that prevented the implementation from
114+
* accessing the key.
111115
* \retval #PSA_ERROR_DATA_INVALID
116+
* The key data was corrupted.
112117
* \retval #PSA_ERROR_DATA_CORRUPT
118+
* The key data was invalid.
113119
* \retval #PSA_ERROR_BAD_STATE
114120
* The library has not been previously initialized by psa_crypto_init().
115121
* It is implementation-dependent whether a failure to initialize
@@ -150,7 +156,9 @@ psa_status_t psa_open_key( mbedtls_svc_key_id_t key,
150156
* \retval #PSA_ERROR_INVALID_HANDLE
151157
* \p handle is not a valid handle nor \c 0.
152158
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
159+
* There was a communication failure inside the implementation.
153160
* \retval #PSA_ERROR_CORRUPTION_DETECTED
161+
* There was a corruption failure inside the implementation.
154162
* \retval #PSA_ERROR_BAD_STATE
155163
* The library has not been previously initialized by psa_crypto_init().
156164
* It is implementation-dependent whether a failure to initialize

mbedtls/include/psa/crypto_extra.h

+58
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,17 @@ static inline void psa_clear_key_slot_number(
192192
* \retval #PSA_ERROR_NOT_PERMITTED
193193
* The caller is not authorized to register the specified key slot.
194194
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
195+
* There is not enough memory to register the key.
195196
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE
197+
* There is not enough storage to register the key.
196198
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
199+
* There was a failure in communication with the secure element.
197200
* \retval #PSA_ERROR_DATA_INVALID
201+
* The key data is not valid.
198202
* \retval #PSA_ERROR_DATA_CORRUPT
203+
* The key data is corrupted.
199204
* \retval #PSA_ERROR_CORRUPTION_DETECTED
205+
* The key data has been corrupted.
200206
* \retval #PSA_ERROR_BAD_STATE
201207
* The library has not been previously initialized by psa_crypto_init().
202208
* It is implementation-dependent whether a failure to initialize
@@ -495,9 +501,15 @@ psa_status_t mbedtls_psa_inject_entropy(const uint8_t *seed,
495501
* \param data_length Size of the \p data buffer in bytes.
496502
*
497503
* \retval #PSA_SUCCESS
504+
* Success.
498505
* \retval #PSA_ERROR_INVALID_ARGUMENT
506+
* \p type is not a supported key type, or the key type does not
507+
* support domain parameters, or the domain parameters are not
508+
* valid for the key type.
499509
* \retval #PSA_ERROR_NOT_SUPPORTED
510+
* The key type does not support domain parameters.
500511
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
512+
* There was insufficient memory to store the domain parameters.
501513
*/
502514
psa_status_t psa_set_key_domain_parameters(psa_key_attributes_t *attributes,
503515
psa_key_type_t type,
@@ -525,7 +537,10 @@ psa_status_t psa_set_key_domain_parameters(psa_key_attributes_t *attributes,
525537
* that make up the key domain parameters data.
526538
*
527539
* \retval #PSA_SUCCESS
540+
* Success.
528541
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
542+
* \p data_size is too small. You can determine a sufficient buffer
543+
* size by calling PSA_KEY_DOMAIN_PARAMETERS_SIZE().
529544
*/
530545
psa_status_t psa_get_key_domain_parameters(
531546
const psa_key_attributes_t *attributes,
@@ -1354,8 +1369,12 @@ static psa_pake_operation_t psa_pake_operation_init(void);
13541369
* \retval #PSA_ERROR_NOT_SUPPORTED
13551370
* The \p cipher_suite is not supported or is not valid.
13561371
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
1372+
* Communication with the peer failed.
13571373
* \retval #PSA_ERROR_HARDWARE_FAILURE
1374+
* A failure of the random generator hardware.
13581375
* \retval #PSA_ERROR_CORRUPTION_DETECTED
1376+
* The implementation detected a potential corruption of its internal
1377+
* data structures.
13591378
* \retval #PSA_ERROR_BAD_STATE
13601379
* The library has not been previously initialized by psa_crypto_init().
13611380
* It is implementation-dependent whether a failure to initialize
@@ -1389,11 +1408,18 @@ psa_status_t psa_pake_setup(psa_pake_operation_t *operation,
13891408
* \retval #PSA_ERROR_BAD_STATE
13901409
* The operation state is not valid (it must have been set up.)
13911410
* \retval #PSA_ERROR_CORRUPTION_DETECTED
1411+
* The implementation detected a potential corruption of its internal
1412+
* data structures.
13921413
* \retval #PSA_ERROR_INVALID_HANDLE
1414+
* \p password is not a valid key identifier.
13931415
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
1416+
* Communication with the key store failed.
13941417
* \retval #PSA_ERROR_HARDWARE_FAILURE
1418+
* A failure of the key store hardware.
13951419
* \retval #PSA_ERROR_STORAGE_FAILURE
1420+
* Storage failure preventing the key from being retrieved.
13961421
* \retval #PSA_ERROR_NOT_PERMITTED
1422+
* The key policy does not allow the requested operation.
13971423
* \retval #PSA_ERROR_INVALID_ARGUMENT
13981424
* \p key is not compatible with the algorithm or the cipher suite.
13991425
* \retval #PSA_ERROR_BAD_STATE
@@ -1430,9 +1456,14 @@ psa_status_t psa_pake_set_password_key(psa_pake_operation_t *operation,
14301456
* \retval #PSA_ERROR_BAD_STATE
14311457
* The operation state is not valid.
14321458
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
1459+
* There was insufficient memory to perform the operation.
14331460
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
1461+
* Communication with the peer failed.
14341462
* \retval #PSA_ERROR_HARDWARE_FAILURE
1463+
* A failure of the random generator hardware.
14351464
* \retval #PSA_ERROR_CORRUPTION_DETECTED
1465+
* The implementation detected a potential corruption of its internal
1466+
* data structures.
14361467
* \retval #PSA_ERROR_INVALID_ARGUMENT
14371468
* \p user_id is NULL.
14381469
* \retval #PSA_ERROR_BAD_STATE
@@ -1472,9 +1503,14 @@ psa_status_t psa_pake_set_user(psa_pake_operation_t *operation,
14721503
* \retval #PSA_ERROR_NOT_SUPPORTED
14731504
* The algorithm doesn't associate a second identity with the session.
14741505
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
1506+
* There was insufficient memory to perform the operation.
14751507
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
1508+
* Communication with the peer failed.
14761509
* \retval #PSA_ERROR_HARDWARE_FAILURE
1510+
* A failure of the random generator hardware.
14771511
* \retval #PSA_ERROR_CORRUPTION_DETECTED
1512+
* The implementation detected a potential corruption of its internal
1513+
* data structures.
14781514
* \retval #PSA_ERROR_INVALID_ARGUMENT
14791515
* \p user_id is NULL.
14801516
* \retval #PSA_ERROR_BAD_STATE
@@ -1515,8 +1551,12 @@ psa_status_t psa_pake_set_peer(psa_pake_operation_t *operation,
15151551
* \retval #PSA_ERROR_NOT_SUPPORTED
15161552
* The \p side for this algorithm is not supported or is not valid.
15171553
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
1554+
* Communication with the peer failed.
15181555
* \retval #PSA_ERROR_HARDWARE_FAILURE
1556+
* A failure of the random generator hardware.
15191557
* \retval #PSA_ERROR_CORRUPTION_DETECTED
1558+
* The implementation detected a potential corruption of its internal
1559+
* data structures.
15201560
* \retval #PSA_ERROR_BAD_STATE
15211561
* The library has not been previously initialized by psa_crypto_init().
15221562
* It is implementation-dependent whether a failure to initialize
@@ -1562,10 +1602,16 @@ psa_status_t psa_pake_set_side(psa_pake_operation_t *operation,
15621602
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
15631603
* The size of the \p output buffer is too small.
15641604
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
1605+
* There was insufficient memory to perform the operation.
15651606
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
1607+
* Communication with the peer failed.
15661608
* \retval #PSA_ERROR_HARDWARE_FAILURE
1609+
* A failure of the random generator hardware.
15671610
* \retval #PSA_ERROR_CORRUPTION_DETECTED
1611+
* The implementation detected a potential corruption of its internal
1612+
* data structures.
15681613
* \retval #PSA_ERROR_STORAGE_FAILURE
1614+
* Storage failure preventing the key from being retrieved.
15691615
* \retval #PSA_ERROR_BAD_STATE
15701616
* The library has not been previously initialized by psa_crypto_init().
15711617
* It is implementation-dependent whether a failure to initialize
@@ -1606,10 +1652,16 @@ psa_status_t psa_pake_output(psa_pake_operation_t *operation,
16061652
* The operation state is not valid (it must be active, but beyond that
16071653
* validity is specific to the algorithm).
16081654
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
1655+
* There was insufficient memory to perform the operation.
16091656
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
1657+
* Communication with the peer failed.
16101658
* \retval #PSA_ERROR_HARDWARE_FAILURE
1659+
* A failure of the random generator hardware.
16111660
* \retval #PSA_ERROR_CORRUPTION_DETECTED
1661+
* The implementation detected a potential corruption of its internal
1662+
* data structures.
16121663
* \retval #PSA_ERROR_STORAGE_FAILURE
1664+
* Storage failure preventing the key from being retrieved.
16131665
* \retval #PSA_ERROR_INVALID_ARGUMENT
16141666
* The input is not valid for the algorithm, ciphersuite or \p step.
16151667
* \retval #PSA_ERROR_BAD_STATE
@@ -1669,10 +1721,16 @@ psa_status_t psa_pake_input(psa_pake_operation_t *operation,
16691721
* #PSA_KEY_DERIVATION_INPUT_SECRET is not compatible with the output’s
16701722
* algorithm.
16711723
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
1724+
* There was insufficient memory to perform the operation.
16721725
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
1726+
* Communication with the peer failed.
16731727
* \retval #PSA_ERROR_HARDWARE_FAILURE
1728+
* A failure of the random generator hardware.
16741729
* \retval #PSA_ERROR_CORRUPTION_DETECTED
1730+
* The implementation detected a potential corruption of its internal
1731+
* data structures.
16751732
* \retval #PSA_ERROR_STORAGE_FAILURE
1733+
* Storage failure preventing the key from being retrieved.
16761734
* \retval #PSA_ERROR_BAD_STATE
16771735
* The library has not been previously initialized by psa_crypto_init().
16781736
* It is implementation-dependent whether a failure to initialize

mbedtls/include/psa/crypto_se_driver.h

+23-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,9 @@ typedef struct {
386386
* or decrypt
387387
*
388388
* \retval #PSA_SUCCESS
389+
* Success.
389390
* \retval #PSA_ERROR_NOT_SUPPORTED
391+
* The requested algorithm is not supported.
390392
*/
391393
typedef psa_status_t (*psa_drv_se_cipher_setup_t)(psa_drv_se_context_t *drv_context,
392394
void *op_context,
@@ -408,6 +410,7 @@ typedef psa_status_t (*psa_drv_se_cipher_setup_t)(psa_drv_se_context_t *drv_cont
408410
* \param[in] iv_length The size (in bytes) of the `p_iv` buffer
409411
*
410412
* \retval #PSA_SUCCESS
413+
* Success.
411414
*/
412415
typedef psa_status_t (*psa_drv_se_cipher_set_iv_t)(void *op_context,
413416
const uint8_t *p_iv,
@@ -430,6 +433,7 @@ typedef psa_status_t (*psa_drv_se_cipher_set_iv_t)(void *op_context,
430433
* of bytes placed in the `p_output` buffer
431434
*
432435
* \retval #PSA_SUCCESS
436+
* Success.
433437
*/
434438
typedef psa_status_t (*psa_drv_se_cipher_update_t)(void *op_context,
435439
const uint8_t *p_input,
@@ -451,6 +455,7 @@ typedef psa_status_t (*psa_drv_se_cipher_update_t)(void *op_context,
451455
* bytes placed in the `p_output` buffer
452456
*
453457
* \retval #PSA_SUCCESS
458+
* Success.
454459
*/
455460
typedef psa_status_t (*psa_drv_se_cipher_finish_t)(void *op_context,
456461
uint8_t *p_output,
@@ -486,7 +491,9 @@ typedef psa_status_t (*psa_drv_se_cipher_abort_t)(void *op_context);
486491
* buffer
487492
*
488493
* \retval #PSA_SUCCESS
494+
* Success.
489495
* \retval #PSA_ERROR_NOT_SUPPORTED
496+
* The requested algorithm is not supported.
490497
*/
491498
typedef psa_status_t (*psa_drv_se_cipher_ecb_t)(psa_drv_se_context_t *drv_context,
492499
psa_key_slot_number_t key_slot,
@@ -555,6 +562,7 @@ typedef struct {
555562
* that make up the returned signature value
556563
*
557564
* \retval #PSA_SUCCESS
565+
* Success.
558566
*/
559567
typedef psa_status_t (*psa_drv_se_asymmetric_sign_t)(psa_drv_se_context_t *drv_context,
560568
psa_key_slot_number_t key_slot,
@@ -619,6 +627,7 @@ typedef psa_status_t (*psa_drv_se_asymmetric_verify_t)(psa_drv_se_context_t *drv
619627
* the returned output
620628
*
621629
* \retval #PSA_SUCCESS
630+
* Success.
622631
*/
623632
typedef psa_status_t (*psa_drv_se_asymmetric_encrypt_t)(psa_drv_se_context_t *drv_context,
624633
psa_key_slot_number_t key_slot,
@@ -659,6 +668,7 @@ typedef psa_status_t (*psa_drv_se_asymmetric_encrypt_t)(psa_drv_se_context_t *dr
659668
* that make up the returned output
660669
*
661670
* \retval #PSA_SUCCESS
671+
* Success.
662672
*/
663673
typedef psa_status_t (*psa_drv_se_asymmetric_decrypt_t)(psa_drv_se_context_t *drv_context,
664674
psa_key_slot_number_t key_slot,
@@ -906,7 +916,9 @@ typedef enum
906916
* The core will record \c *key_slot as the key slot where the key
907917
* is stored and will update the persistent data in storage.
908918
* \retval #PSA_ERROR_NOT_SUPPORTED
919+
* The requested key type is not supported.
909920
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE
921+
* There is not enough storage space for this key.
910922
*/
911923
typedef psa_status_t (*psa_drv_se_allocate_key_t)(
912924
psa_drv_se_context_t *drv_context,
@@ -1045,12 +1057,19 @@ typedef psa_status_t (*psa_drv_se_destroy_key_t)(
10451057
* that make up the key data.
10461058
*
10471059
* \retval #PSA_SUCCESS
1060+
* Success.
10481061
* \retval #PSA_ERROR_DOES_NOT_EXIST
1062+
* The specified slot is not currently in use.
10491063
* \retval #PSA_ERROR_NOT_PERMITTED
1064+
* The specified slot is not an external key slot.
10501065
* \retval #PSA_ERROR_NOT_SUPPORTED
1066+
* The specified key type is not supported.
10511067
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
1068+
* There was a communication failure with the secure element.
10521069
* \retval #PSA_ERROR_HARDWARE_FAILURE
1070+
* There was a failure in the secure element.
10531071
* \retval #PSA_ERROR_CORRUPTION_DETECTED
1072+
* There was a corruption failure in the secure element.
10541073
*/
10551074
typedef psa_status_t (*psa_drv_se_export_key_t)(psa_drv_se_context_t *drv_context,
10561075
psa_key_slot_number_t key,
@@ -1198,6 +1217,7 @@ typedef struct {
11981217
* the key derivation
11991218
*
12001219
* \retval #PSA_SUCCESS
1220+
* Success.
12011221
*/
12021222
typedef psa_status_t (*psa_drv_se_key_derivation_setup_t)(psa_drv_se_context_t *drv_context,
12031223
void *op_context,
@@ -1218,6 +1238,7 @@ typedef psa_status_t (*psa_drv_se_key_derivation_setup_t)(psa_drv_se_context_t *
12181238
* \param[in] collateral_size The size in bytes of the collateral
12191239
*
12201240
* \retval #PSA_SUCCESS
1241+
* Success.
12211242
*/
12221243
typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(void *op_context,
12231244
uint32_t collateral_id,
@@ -1232,7 +1253,7 @@ typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(void *op_context,
12321253
* \param[in] dest_key The slot where the generated key material
12331254
* should be placed
12341255
*
1235-
* \retval #PSA_SUCCESS
1256+
* \retval #PSA_SUCCESS Success.
12361257
*/
12371258
typedef psa_status_t (*psa_drv_se_key_derivation_derive_t)(void *op_context,
12381259
psa_key_slot_number_t dest_key);
@@ -1247,6 +1268,7 @@ typedef psa_status_t (*psa_drv_se_key_derivation_derive_t)(void *op_context,
12471268
* key material placed in `p_output`
12481269
*
12491270
* \retval #PSA_SUCCESS
1271+
* Success.
12501272
*/
12511273
typedef psa_status_t (*psa_drv_se_key_derivation_export_t)(void *op_context,
12521274
uint8_t *p_output,

mbedtls/library/bignum.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ void mpi_mul_hlp( size_t i,
13921392
mbedtls_mpi_uint *d,
13931393
mbedtls_mpi_uint b )
13941394
{
1395-
mbedtls_mpi_uint c = 0, t = 0;
1395+
mbedtls_mpi_uint c = 0;
13961396

13971397
#if defined(MULADDC_HUIT)
13981398
for( ; i >= 8; i -= 8 )
@@ -1443,8 +1443,6 @@ void mpi_mul_hlp( size_t i,
14431443
}
14441444
#endif /* MULADDC_HUIT */
14451445

1446-
t++;
1447-
14481446
while( c != 0 )
14491447
{
14501448
*d += c; c = ( *d < c ); d++;

mbedtls/library/psa_crypto.c

+7
Original file line numberDiff line numberDiff line change
@@ -1684,11 +1684,18 @@ static psa_status_t psa_start_key_creation(
16841684
* \retval #PSA_SUCCESS
16851685
* The key was successfully created.
16861686
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
1687+
* There was not enough storage space to create the key.
16871688
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE
1689+
* There was not enough storage space to create the key.
16881690
* \retval #PSA_ERROR_ALREADY_EXISTS
1691+
* There is already a key with this identifier.
16891692
* \retval #PSA_ERROR_DATA_INVALID
1693+
* The key data is not valid.
16901694
* \retval #PSA_ERROR_DATA_CORRUPT
1695+
* There was an inconsistency between volatile and non-volatile
1696+
* storage.
16911697
* \retval #PSA_ERROR_STORAGE_FAILURE
1698+
* There was a failure in persistent storage.
16921699
*
16931700
* \return If this function fails, the key slot is an invalid state.
16941701
* You must call psa_fail_key_creation() to wipe and free the slot.

0 commit comments

Comments
 (0)