Merge pull request #3326 from kohnakagawa/fix/utf-8_encoding_bug
fix mbedtls_x509_dn_gets to show non-ASCII string properly
diff --git a/ChangeLog.d/inline-mbedtls_gcc_group_to_psa.txt b/ChangeLog.d/inline-mbedtls_gcc_group_to_psa.txt
new file mode 100644
index 0000000..d0bd1dc
--- /dev/null
+++ b/ChangeLog.d/inline-mbedtls_gcc_group_to_psa.txt
@@ -0,0 +1,4 @@
+Bugfix
+ * Fix potential linker errors on dual world platforms by inlining
+ mbedtls_gcc_group_to_psa(). This allows the pk.c module to link separately
+ from psa_crypto.c. Fixes #3300.
diff --git a/ChangeLog.d/midipix-support.txt b/ChangeLog.d/midipix-support.txt
new file mode 100644
index 0000000..53599ab
--- /dev/null
+++ b/ChangeLog.d/midipix-support.txt
@@ -0,0 +1,2 @@
+Features
+ * Add support for midipix, a POSIX layer for Microsoft Windows.
diff --git a/include/psa/crypto_extra.h b/include/psa/crypto_extra.h
index e9fa311..84cc5ab 100644
--- a/include/psa/crypto_extra.h
+++ b/include/psa/crypto_extra.h
@@ -578,8 +578,55 @@
* (`PSA_ECC_CURVE_xxx`).
* \return \c 0 on failure (\p grpid is not recognized).
*/
-psa_ecc_curve_t mbedtls_ecc_group_to_psa( mbedtls_ecp_group_id grpid,
- size_t *bits );
+static inline psa_ecc_curve_t mbedtls_ecc_group_to_psa( mbedtls_ecp_group_id grpid,
+ size_t *bits )
+{
+ switch( grpid )
+ {
+ case MBEDTLS_ECP_DP_SECP192R1:
+ *bits = 192;
+ return( PSA_ECC_CURVE_SECP_R1 );
+ case MBEDTLS_ECP_DP_SECP224R1:
+ *bits = 224;
+ return( PSA_ECC_CURVE_SECP_R1 );
+ case MBEDTLS_ECP_DP_SECP256R1:
+ *bits = 256;
+ return( PSA_ECC_CURVE_SECP_R1 );
+ case MBEDTLS_ECP_DP_SECP384R1:
+ *bits = 384;
+ return( PSA_ECC_CURVE_SECP_R1 );
+ case MBEDTLS_ECP_DP_SECP521R1:
+ *bits = 521;
+ return( PSA_ECC_CURVE_SECP_R1 );
+ case MBEDTLS_ECP_DP_BP256R1:
+ *bits = 256;
+ return( PSA_ECC_CURVE_BRAINPOOL_P_R1 );
+ case MBEDTLS_ECP_DP_BP384R1:
+ *bits = 384;
+ return( PSA_ECC_CURVE_BRAINPOOL_P_R1 );
+ case MBEDTLS_ECP_DP_BP512R1:
+ *bits = 512;
+ return( PSA_ECC_CURVE_BRAINPOOL_P_R1 );
+ case MBEDTLS_ECP_DP_CURVE25519:
+ *bits = 255;
+ return( PSA_ECC_CURVE_MONTGOMERY );
+ case MBEDTLS_ECP_DP_SECP192K1:
+ *bits = 192;
+ return( PSA_ECC_CURVE_SECP_K1 );
+ case MBEDTLS_ECP_DP_SECP224K1:
+ *bits = 224;
+ return( PSA_ECC_CURVE_SECP_K1 );
+ case MBEDTLS_ECP_DP_SECP256K1:
+ *bits = 256;
+ return( PSA_ECC_CURVE_SECP_K1 );
+ case MBEDTLS_ECP_DP_CURVE448:
+ *bits = 448;
+ return( PSA_ECC_CURVE_MONTGOMERY );
+ default:
+ *bits = 0;
+ return( 0 );
+ }
+}
/** Convert an ECC curve identifier from the PSA encoding to Mbed TLS.
*
diff --git a/library/entropy_poll.c b/library/entropy_poll.c
index c9b2c95..8b4a5af 100644
--- a/library/entropy_poll.c
+++ b/library/entropy_poll.c
@@ -52,7 +52,7 @@
#if !defined(unix) && !defined(__unix__) && !defined(__unix) && \
!defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \
- !defined(__HAIKU__)
+ !defined(__HAIKU__) && !defined(__midipix__)
#error "Platform entropy sources only work on Unix and Windows, see MBEDTLS_NO_PLATFORM_ENTROPY in config.h"
#endif
@@ -95,7 +95,7 @@
* Since there is no wrapper in the libc yet, use the generic syscall wrapper
* available in GNU libc and compatible libc's (eg uClibc).
*/
-#if defined(__linux__) && defined(__GLIBC__)
+#if ((defined(__linux__) && defined(__GLIBC__)) || defined(__midipix__))
#include <unistd.h>
#include <sys/syscall.h>
#if defined(SYS_getrandom)
@@ -113,7 +113,7 @@
return( syscall( SYS_getrandom, buf, buflen, flags ) );
}
#endif /* SYS_getrandom */
-#endif /* __linux__ */
+#endif /* __linux__ || __midipix__ */
#include <stdio.h>
diff --git a/library/net_sockets.c b/library/net_sockets.c
index 5c1e665..8258aea 100644
--- a/library/net_sockets.c
+++ b/library/net_sockets.c
@@ -34,7 +34,7 @@
#if !defined(unix) && !defined(__unix__) && !defined(__unix) && \
!defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \
- !defined(__HAIKU__)
+ !defined(__HAIKU__) && !defined(__midipix__)
#error "This module only works on Unix and Windows, see MBEDTLS_NET_C in config.h"
#endif
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 733a2e4..6932318 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -375,55 +375,6 @@
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
#if defined(MBEDTLS_ECP_C)
-psa_ecc_curve_t mbedtls_ecc_group_to_psa( mbedtls_ecp_group_id grpid,
- size_t *bits )
-{
- switch( grpid )
- {
- case MBEDTLS_ECP_DP_SECP192R1:
- *bits = 192;
- return( PSA_ECC_CURVE_SECP_R1 );
- case MBEDTLS_ECP_DP_SECP224R1:
- *bits = 224;
- return( PSA_ECC_CURVE_SECP_R1 );
- case MBEDTLS_ECP_DP_SECP256R1:
- *bits = 256;
- return( PSA_ECC_CURVE_SECP_R1 );
- case MBEDTLS_ECP_DP_SECP384R1:
- *bits = 384;
- return( PSA_ECC_CURVE_SECP_R1 );
- case MBEDTLS_ECP_DP_SECP521R1:
- *bits = 521;
- return( PSA_ECC_CURVE_SECP_R1 );
- case MBEDTLS_ECP_DP_BP256R1:
- *bits = 256;
- return( PSA_ECC_CURVE_BRAINPOOL_P_R1 );
- case MBEDTLS_ECP_DP_BP384R1:
- *bits = 384;
- return( PSA_ECC_CURVE_BRAINPOOL_P_R1 );
- case MBEDTLS_ECP_DP_BP512R1:
- *bits = 512;
- return( PSA_ECC_CURVE_BRAINPOOL_P_R1 );
- case MBEDTLS_ECP_DP_CURVE25519:
- *bits = 255;
- return( PSA_ECC_CURVE_MONTGOMERY );
- case MBEDTLS_ECP_DP_SECP192K1:
- *bits = 192;
- return( PSA_ECC_CURVE_SECP_K1 );
- case MBEDTLS_ECP_DP_SECP224K1:
- *bits = 224;
- return( PSA_ECC_CURVE_SECP_K1 );
- case MBEDTLS_ECP_DP_SECP256K1:
- *bits = 256;
- return( PSA_ECC_CURVE_SECP_K1 );
- case MBEDTLS_ECP_DP_CURVE448:
- *bits = 448;
- return( PSA_ECC_CURVE_MONTGOMERY );
- default:
- return( 0 );
- }
-}
-
mbedtls_ecp_group_id mbedtls_ecc_group_of_psa( psa_ecc_curve_t curve,
size_t byte_length )
{
diff --git a/library/timing.c b/library/timing.c
index 009516a..4a65422 100644
--- a/library/timing.c
+++ b/library/timing.c
@@ -40,7 +40,7 @@
#if !defined(unix) && !defined(__unix__) && !defined(__unix) && \
!defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \
- !defined(__HAIKU__)
+ !defined(__HAIKU__) && !defined(__midipix__)
#error "This module only works on Unix and Windows, see MBEDTLS_TIMING_C in config.h"
#endif
diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c
index efd6ee1..0c04cd8 100644
--- a/programs/test/benchmark.c
+++ b/programs/test/benchmark.c
@@ -101,7 +101,7 @@
#define OPTIONS \
"md4, md5, ripemd160, sha1, sha256, sha512,\n" \
"arc4, des3, des, camellia, blowfish, chacha20,\n" \
- "aes_cbc, aes_gcm, aes_ccm, aes_ctx, chachapoly,\n" \
+ "aes_cbc, aes_gcm, aes_ccm, aes_xts, chachapoly,\n" \
"aes_cmac, des3_cmac, poly1305\n" \
"havege, ctr_drbg, hmac_drbg\n" \
"rsa, dhm, ecdsa, ecdh.\n"