summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-08-31 10:59:31 +0200
committerThomas Haller <thaller@redhat.com>2018-09-03 18:07:59 +0200
commit2f435e87572f48a614be711ff54b9c517d3310b7 (patch)
tree8f19e2c2922d4f88329428c5e2c8c6630ddb375c
parent42d212fb4c011b1e093275754da6106d9fcbb7a9 (diff)
downloadNetworkManager-2f435e87572f48a614be711ff54b9c517d3310b7.tar.gz
libnm/crypto: rework endianness detection for crypto_verify_pkcs12()
At other places, we already use __BYTE_ORDER define to detect endianness. We don't need multiple mechanisms. Also note that meson did not do the correct thing as AC_C_BIGENDIAN, so meson + nss + big-endian was possibly broken.
-rw-r--r--config.h.meson12
-rw-r--r--configure.ac5
-rw-r--r--libnm-core/nm-crypto-nss.c15
-rw-r--r--libnm-util/crypto_nss.c15
4 files changed, 16 insertions, 31 deletions
diff --git a/config.h.meson b/config.h.meson
index c5fbf5fab3..ce77952bec 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -226,18 +226,6 @@
/* Define if you have iwd support */
#mesondefine WITH_IWD
-/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
- significant byte first (like Motorola and SPARC, unlike Intel). */
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-# endif
-#else
-# ifndef WORDS_BIGENDIAN
-/* # undef WORDS_BIGENDIAN */
-# endif
-#endif
-
/* Define to 1 if on MINIX. */
#mesondefine _MINIX
diff --git a/configure.ac b/configure.ac
index 62c7e0392e..c104c9b930 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,11 +109,6 @@ GETTEXT_PACKAGE=NetworkManager
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
-dnl
-dnl Make sha1.c happy on big endian systems
-dnl
-AC_C_BIGENDIAN
-
# Add runstatedir if not specified manually in autoconf < 2.70
AS_IF([test -z "$runstatedir"], runstatedir="$localstatedir/run")
AC_SUBST(runstatedir)
diff --git a/libnm-core/nm-crypto-nss.c b/libnm-core/nm-crypto-nss.c
index 1260b3b45f..feb081e621 100644
--- a/libnm-core/nm-crypto-nss.c
+++ b/libnm-core/nm-crypto-nss.c
@@ -414,9 +414,6 @@ _nm_crypto_verify_pkcs12 (const guint8 *data,
SECStatus s;
gunichar2 *ucs2_password;
long ucs2_chars = 0;
-#ifndef WORDS_BIGENDIAN
- guint16 *p;
-#endif /* WORDS_BIGENDIAN */
if (error)
g_return_val_if_fail (*error == NULL, FALSE);
@@ -446,10 +443,14 @@ _nm_crypto_verify_pkcs12 (const guint8 *data,
nm_explicit_bzero (ucs2_password, ucs2_chars);
g_free (ucs2_password);
-#ifndef WORDS_BIGENDIAN
- for (p = (guint16 *) pw.data; p < (guint16 *) (pw.data + pw.len); p++)
- *p = GUINT16_SWAP_LE_BE (*p);
-#endif /* WORDS_BIGENDIAN */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ {
+ guint16 *p;
+
+ for (p = (guint16 *) pw.data; p < (guint16 *) (pw.data + pw.len); p++)
+ *p = GUINT16_SWAP_LE_BE (*p);
+ }
+#endif
} else {
/* NULL password */
pw.data = NULL;
diff --git a/libnm-util/crypto_nss.c b/libnm-util/crypto_nss.c
index 5736db4f89..01bb28c33d 100644
--- a/libnm-util/crypto_nss.c
+++ b/libnm-util/crypto_nss.c
@@ -442,9 +442,6 @@ crypto_verify_pkcs12 (const GByteArray *data,
SECStatus s;
char *ucs2_password;
long ucs2_chars = 0;
-#ifndef WORDS_BIGENDIAN
- guint16 *p;
-#endif /* WORDS_BIGENDIAN */
if (error)
g_return_val_if_fail (*error == NULL, FALSE);
@@ -470,10 +467,14 @@ crypto_verify_pkcs12 (const GByteArray *data,
memset (ucs2_password, 0, ucs2_chars);
g_free (ucs2_password);
-#ifndef WORDS_BIGENDIAN
- for (p = (guint16 *) pw.data; p < (guint16 *) (pw.data + pw.len); p++)
- *p = GUINT16_SWAP_LE_BE (*p);
-#endif /* WORDS_BIGENDIAN */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ {
+ guint16 *p;
+
+ for (p = (guint16 *) pw.data; p < (guint16 *) (pw.data + pw.len); p++)
+ *p = GUINT16_SWAP_LE_BE (*p);
+ }
+#endif
} else {
/* NULL password */
pw.data = NULL;