<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Ben,<br><br>4096 is fixed in the standard to map "Passphrase" to PSK using PBKDF2 method. Modifying this would break the interoperability. <br><br>Regards<br>Sohail<br><br>--- On <b>Thu, 3/2/11, Ben Greear <i>&lt;greearb@candelatech.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Ben Greear &lt;greearb@candelatech.com&gt;<br>Subject: Re: Optimizing use of SSL?<br>To: hostap@lists.shmoo.com<br>Date: Thursday, 3 February, 2011, 5:35 AM<br><br><div class="plainMail">On 02/02/2011 03:38 PM, Ben Greear wrote:<br>&gt; I've been looking at ways to optimize wpa_supplicant for when we are using<br>&gt; lots and lots of vifs (say, 128).&nbsp; These are configured to use WPA,<br>&gt; and the NIC (ath9k) is set to software-encryption in order to work with multiple<br>&gt;
 vifs.<br>&gt;<br>&gt; I ran it under callgrind (valgrind --tool=callgrind) with only<br>&gt; 16 vifs, and libcrypto seems to be using most of the CPU.<br>&gt;<br>&gt; I'm wondering if anyone has any ideas for ways to optimize<br>&gt; supplicant to work better in this case.&nbsp; I was thinking it<br>&gt; should only be passing relatively few pkts around, so I'm<br>&gt; not too sure why it's such a CPU hog.<br><br>Hrm, seems that a lot of the cost is calculating<br>the digest:<br><br>&nbsp;&nbsp;&nbsp;Frame: Backtrace for Thread 1<br>&nbsp; &nbsp; [ 0]&nbsp; EVP_DigestInit_ex (209361 x)<br>&nbsp; &nbsp; [ 1]&nbsp; openssl_digest_vector (209361 x)<br>&nbsp; &nbsp; [ 2]&nbsp; sha1_vector (104681 x)<br>&nbsp; &nbsp; [ 3]&nbsp; hmac_sha1_vector (104655 x)<br>&nbsp; &nbsp; [ 4]&nbsp; hmac_sha1 (104629 x)<br>&nbsp; &nbsp; [ 5]&nbsp; pbkdf2_sha1 (13 x)<br>&nbsp; &nbsp; [ 6]&nbsp; wpa_config_update_psk (13 x)<br>&nbsp; &nbsp; [ 7]&nbsp; wpa_config_read (13
 x)<br>&nbsp; &nbsp; [ 8]&nbsp; wpa_supplicant_add_iface (13 x)<br>&nbsp; &nbsp; [ 9]&nbsp; main (1 x)<br>&nbsp; &nbsp; [10]&nbsp; (below main) (1 x)<br>&nbsp; &nbsp; [11]&nbsp; 0x0804c220 (1 x)<br>&nbsp; &nbsp; [12]&nbsp; 0x4d80d870<br><br>Specifically, this method has a pretty mean loop:<br><br>pbkdf2_sha1_f()<br><br>It loops for all iterations, which is passed in as 4096<br>by this method below:<br><br>/**<br>&nbsp; * wpa_config_update_psk - Update WPA PSK based on passphrase and SSID<br>&nbsp; * @ssid: Pointer to network configuration data<br>&nbsp; *<br>&nbsp; * This function must be called to update WPA PSK when either SSID or the<br>&nbsp; * passphrase has changed for the network configuration.<br>&nbsp; */<br>void wpa_config_update_psk(struct wpa_ssid *ssid)<br>{<br>#ifndef CONFIG_NO_PBKDF2<br>&nbsp;&nbsp;&nbsp; pbkdf2_sha1(ssid-&gt;passphrase,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; (char *) ssid-&gt;ssid, ssid-&gt;ssid_len,
 4096,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; ssid-&gt;psk, PMK_LEN);<br>&nbsp;&nbsp;&nbsp; wpa_hexdump_key(MSG_MSGDUMP, "PSK (from passphrase)",<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ssid-&gt;psk, PMK_LEN);<br>&nbsp;&nbsp;&nbsp; ssid-&gt;psk_set = 1;<br>#endif /* CONFIG_NO_PBKDF2 */<br>}<br><br><br>Is it required to do that 4096 times, or is it just higher<br>grade encryption that way?&nbsp; If something lesser would be<br>adequate, maybe I can make it a configurable value?<br><br></div></blockquote></td></tr></table><br>