]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Share a single buf_shift_right() implementation
authorJouni Malinen <jouni@codeaurora.org>
Thu, 25 Apr 2019 16:29:39 +0000 (19:29 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 25 Apr 2019 20:49:43 +0000 (23:49 +0300)
Move the identical function used by both SAE and EAP-pwd to
src/utils/common.c to avoid duplicated implementation.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/common/sae.c
src/eap_common/eap_pwd_common.c
src/utils/common.c
src/utils/common.h

index 0d56e5505327b4299b6fdeb4e29f46102980ed0c..466d0a8530370aa2ef648e9f2f9b002be7171e45 100644 (file)
@@ -134,15 +134,6 @@ void sae_clear_data(struct sae_data *sae)
 }
 
 
-static void buf_shift_right(u8 *buf, size_t len, size_t bits)
-{
-       size_t i;
-       for (i = len - 1; i > 0; i--)
-               buf[i] = (buf[i - 1] << (8 - bits)) | (buf[i] >> bits);
-       buf[0] >>= bits;
-}
-
-
 static struct crypto_bignum * sae_get_rand(struct sae_data *sae)
 {
        u8 val[SAE_MAX_PRIME_LEN];
index 6ca2c8badb880710d884aeab7f088b05c9d54bdb..2efcfc7f95ad0113463c77c210bc09cb45f7f58d 100644 (file)
@@ -119,15 +119,6 @@ EAP_PWD_group * get_eap_pwd_group(u16 num)
 }
 
 
-static void buf_shift_right(u8 *buf, size_t len, size_t bits)
-{
-       size_t i;
-       for (i = len - 1; i > 0; i--)
-               buf[i] = (buf[i - 1] << (8 - bits)) | (buf[i] >> bits);
-       buf[0] >>= bits;
-}
-
-
 /*
  * compute a "random" secret point on an elliptic curve based
  * on the password and identities.
index b9c8bfdb98e95f077630573d9530c68ab5846382..836fef190c54e0aedc344d2073c46eecf487c49b 100644 (file)
@@ -230,6 +230,16 @@ void inc_byte_array(u8 *counter, size_t len)
 }
 
 
+void buf_shift_right(u8 *buf, size_t len, size_t bits)
+{
+       size_t i;
+
+       for (i = len - 1; i > 0; i--)
+               buf[i] = (buf[i - 1] << (8 - bits)) | (buf[i] >> bits);
+       buf[0] >>= bits;
+}
+
+
 void wpa_get_ntp_timestamp(u8 *buf)
 {
        struct os_time now;
index 792a30ab9bbebc16c116942728982e237318e66c..36f67fa7171e1d75abce3a5020957051daa3aaf1 100644 (file)
@@ -477,6 +477,7 @@ int hwaddr_aton2(const char *txt, u8 *addr);
 int hex2byte(const char *hex);
 int hexstr2bin(const char *hex, u8 *buf, size_t len);
 void inc_byte_array(u8 *counter, size_t len);
+void buf_shift_right(u8 *buf, size_t len, size_t bits);
 void wpa_get_ntp_timestamp(u8 *buf);
 int wpa_scnprintf(char *buf, size_t size, const char *fmt, ...);
 int wpa_snprintf_hex_sep(char *buf, size_t buf_size, const u8 *data, size_t len,