Moved rsn_pmkid() into shared code to avoid duplication
authorJouni Malinen <j@w1.fi>
Wed, 14 Jan 2009 19:31:47 +0000 (21:31 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 14 Jan 2009 19:31:47 +0000 (21:31 +0200)
hostapd/pmksa_cache.c
hostapd/pmksa_cache.h
src/common/wpa_common.c
src/common/wpa_common.h
src/rsn_supp/pmksa_cache.c

index 152a4cb..2de0219 100644 (file)
@@ -40,40 +40,6 @@ struct rsn_pmksa_cache {
 };
 
 
-/**
- * rsn_pmkid - Calculate PMK identifier
- * @pmk: Pairwise master key
- * @pmk_len: Length of pmk in bytes
- * @aa: Authenticator address
- * @spa: Supplicant address
- * @pmkid: Buffer for PMKID
- * @use_sha256: Whether to use SHA256-based KDF
- *
- * IEEE Std 802.11i-2004 - 8.5.1.2 Pairwise key hierarchy
- * PMKID = HMAC-SHA1-128(PMK, "PMK Name" || AA || SPA)
- */
-void rsn_pmkid(const u8 *pmk, size_t pmk_len, const u8 *aa, const u8 *spa,
-              u8 *pmkid, int use_sha256)
-{
-       char *title = "PMK Name";
-       const u8 *addr[3];
-       const size_t len[3] = { 8, ETH_ALEN, ETH_ALEN };
-       unsigned char hash[SHA256_MAC_LEN];
-
-       addr[0] = (u8 *) title;
-       addr[1] = aa;
-       addr[2] = spa;
-
-#ifdef CONFIG_IEEE80211W
-       if (use_sha256)
-               hmac_sha256_vector(pmk, pmk_len, 3, addr, len, hash);
-       else
-#endif /* CONFIG_IEEE80211W */
-               hmac_sha1_vector(pmk, pmk_len, 3, addr, len, hash);
-       os_memcpy(pmkid, hash, PMKID_LEN);
-}
-
-
 static void pmksa_cache_set_expiration(struct rsn_pmksa_cache *pmksa);
 
 
index 6ba2da6..1c984a2 100644 (file)
@@ -56,7 +56,5 @@ pmksa_cache_add_okc(struct rsn_pmksa_cache *pmksa,
                    const u8 *aa, const u8 *pmkid);
 void pmksa_cache_to_eapol_data(struct rsn_pmksa_cache_entry *entry,
                               struct eapol_state_machine *eapol);
-void rsn_pmkid(const u8 *pmk, size_t pmk_len, const u8 *aa, const u8 *spa,
-              u8 *pmkid, int use_sha256);
 
 #endif /* PMKSA_CACHE_H */
index c9ff319..0e3984f 100644 (file)
@@ -568,3 +568,37 @@ void wpa_pmk_r1_to_ptk(const u8 *pmk_r1, const u8 *snonce, const u8 *anonce,
 }
 
 #endif /* CONFIG_IEEE80211R */
+
+
+/**
+ * rsn_pmkid - Calculate PMK identifier
+ * @pmk: Pairwise master key
+ * @pmk_len: Length of pmk in bytes
+ * @aa: Authenticator address
+ * @spa: Supplicant address
+ * @pmkid: Buffer for PMKID
+ * @use_sha256: Whether to use SHA256-based KDF
+ *
+ * IEEE Std 802.11i-2004 - 8.5.1.2 Pairwise key hierarchy
+ * PMKID = HMAC-SHA1-128(PMK, "PMK Name" || AA || SPA)
+ */
+void rsn_pmkid(const u8 *pmk, size_t pmk_len, const u8 *aa, const u8 *spa,
+              u8 *pmkid, int use_sha256)
+{
+       char *title = "PMK Name";
+       const u8 *addr[3];
+       const size_t len[3] = { 8, ETH_ALEN, ETH_ALEN };
+       unsigned char hash[SHA256_MAC_LEN];
+
+       addr[0] = (u8 *) title;
+       addr[1] = aa;
+       addr[2] = spa;
+
+#ifdef CONFIG_IEEE80211W
+       if (use_sha256)
+               hmac_sha256_vector(pmk, pmk_len, 3, addr, len, hash);
+       else
+#endif /* CONFIG_IEEE80211W */
+               hmac_sha1_vector(pmk, pmk_len, 3, addr, len, hash);
+       os_memcpy(pmkid, hash, PMKID_LEN);
+}
index 3074cd4..2fcb9f2 100644 (file)
@@ -332,4 +332,7 @@ struct wpa_ie_data {
 int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
                         struct wpa_ie_data *data);
 
+void rsn_pmkid(const u8 *pmk, size_t pmk_len, const u8 *aa, const u8 *spa,
+              u8 *pmkid, int use_sha256);
+
 #endif /* WPA_COMMON_H */
index ef872b1..94b255f 100644 (file)
@@ -38,39 +38,6 @@ struct rsn_pmksa_cache {
 };
 
 
-/**
- * rsn_pmkid - Calculate PMK identifier
- * @pmk: Pairwise master key
- * @pmk_len: Length of pmk in bytes
- * @aa: Authenticator address
- * @spa: Supplicant address
- * @use_sha256: Whether to use SHA256-based KDF
- *
- * IEEE Std 802.11i-2004 - 8.5.1.2 Pairwise key hierarchy
- * PMKID = HMAC-SHA1-128(PMK, "PMK Name" || AA || SPA)
- */
-static void rsn_pmkid(const u8 *pmk, size_t pmk_len, const u8 *aa,
-                     const u8 *spa, u8 *pmkid, int use_sha256)
-{
-       char *title = "PMK Name";
-       const u8 *addr[3];
-       const size_t len[3] = { 8, ETH_ALEN, ETH_ALEN };
-       unsigned char hash[SHA256_MAC_LEN];
-
-       addr[0] = (u8 *) title;
-       addr[1] = aa;
-       addr[2] = spa;
-
-#ifdef CONFIG_IEEE80211W
-       if (use_sha256)
-               hmac_sha256_vector(pmk, pmk_len, 3, addr, len, hash);
-       else
-#endif /* CONFIG_IEEE80211W */
-               hmac_sha1_vector(pmk, pmk_len, 3, addr, len, hash);
-       os_memcpy(pmkid, hash, PMKID_LEN);
-}
-
-
 static void pmksa_cache_set_expiration(struct rsn_pmksa_cache *pmksa);