Share a single buf_shift_right() implementation
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>
This commit is contained in:
parent
1e237903f5
commit
ff229da309
4 changed files with 11 additions and 18 deletions
|
@ -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];
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue