aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-11-29 11:15:32 (GMT)
committerJouni Malinen <j@w1.fi>2009-11-29 11:15:32 (GMT)
commit120158cc8b9ad83fede1e30c6e6004cc7f737a60 (patch)
tree234a9c24744c7eac1047978df1a0cd269055b1ac
parent197ef6abef842a45e9bbdfd0ee659dffc87a7fa3 (diff)
downloadhostap-120158cc8b9ad83fede1e30c6e6004cc7f737a60.zip
hostap-120158cc8b9ad83fede1e30c6e6004cc7f737a60.tar.gz
hostap-120158cc8b9ad83fede1e30c6e6004cc7f737a60.tar.bz2
Move uuid_gen_mac_addr() from uuid.c into src/wps
This removes the only src/crypto dependency from src/utils files.
-rw-r--r--src/utils/uuid.c30
-rw-r--r--src/utils/uuid.h1
-rw-r--r--src/wps/wps.h1
-rw-r--r--src/wps/wps_common.c31
4 files changed, 31 insertions, 32 deletions
diff --git a/src/utils/uuid.c b/src/utils/uuid.c
index 620d3d6..d8cc267 100644
--- a/src/utils/uuid.c
+++ b/src/utils/uuid.c
@@ -15,8 +15,6 @@
#include "includes.h"
#include "common.h"
-#include "crypto.h"
-#include "sha1.h"
#include "uuid.h"
int uuid_str2bin(const char *str, u8 *bin)
@@ -77,31 +75,3 @@ int is_nil_uuid(const u8 *uuid)
return 0;
return 1;
}
-
-
-void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid)
-{
- const u8 *addr[2];
- size_t len[2];
- u8 hash[SHA1_MAC_LEN];
- u8 nsid[16] = {
- 0x52, 0x64, 0x80, 0xf8,
- 0xc9, 0x9b,
- 0x4b, 0xe5,
- 0xa6, 0x55,
- 0x58, 0xed, 0x5f, 0x5d, 0x60, 0x84
- };
-
- addr[0] = nsid;
- len[0] = sizeof(nsid);
- addr[1] = mac_addr;
- len[1] = 6;
- sha1_vector(2, addr, len, hash);
- os_memcpy(uuid, hash, 16);
-
- /* Version: 5 = named-based version using SHA-1 */
- uuid[6] = (5 << 4) | (uuid[6] & 0x0f);
-
- /* Variant specified in RFC 4122 */
- uuid[8] = 0x80 | (uuid[8] & 0x3f);
-}
diff --git a/src/utils/uuid.h b/src/utils/uuid.h
index 9fc2ba0..0759165 100644
--- a/src/utils/uuid.h
+++ b/src/utils/uuid.h
@@ -20,6 +20,5 @@
int uuid_str2bin(const char *str, u8 *bin);
int uuid_bin2str(const u8 *bin, char *str, size_t max_len);
int is_nil_uuid(const u8 *uuid);
-void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid);
#endif /* UUID_H */
diff --git a/src/wps/wps.h b/src/wps/wps.h
index ead6c1d..e6464a6 100644
--- a/src/wps/wps.h
+++ b/src/wps/wps.h
@@ -686,5 +686,6 @@ int wps_er_learn(struct wps_er *er, const u8 *uuid, const u8 *pin,
int wps_dev_type_str2bin(const char *str, u8 dev_type[WPS_DEV_TYPE_LEN]);
char * wps_dev_type_bin2str(const u8 dev_type[WPS_DEV_TYPE_LEN], char *buf,
size_t buf_len);
+void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid);
#endif /* WPS_H */
diff --git a/src/wps/wps_common.c b/src/wps/wps_common.c
index 7956459..dab85b7 100644
--- a/src/wps/wps_common.c
+++ b/src/wps/wps_common.c
@@ -1,6 +1,6 @@
/*
* Wi-Fi Protected Setup - common functionality
- * Copyright (c) 2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2008-2009, Jouni Malinen <j@w1.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -16,6 +16,7 @@
#include "common.h"
#include "dh_group5.h"
+#include "sha1.h"
#include "sha256.h"
#include "aes_wrap.h"
#include "crypto.h"
@@ -566,3 +567,31 @@ char * wps_dev_type_bin2str(const u8 dev_type[WPS_DEV_TYPE_LEN], char *buf,
return buf;
}
+
+
+void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid)
+{
+ const u8 *addr[2];
+ size_t len[2];
+ u8 hash[SHA1_MAC_LEN];
+ u8 nsid[16] = {
+ 0x52, 0x64, 0x80, 0xf8,
+ 0xc9, 0x9b,
+ 0x4b, 0xe5,
+ 0xa6, 0x55,
+ 0x58, 0xed, 0x5f, 0x5d, 0x60, 0x84
+ };
+
+ addr[0] = nsid;
+ len[0] = sizeof(nsid);
+ addr[1] = mac_addr;
+ len[1] = 6;
+ sha1_vector(2, addr, len, hash);
+ os_memcpy(uuid, hash, 16);
+
+ /* Version: 5 = named-based version using SHA-1 */
+ uuid[6] = (5 << 4) | (uuid[6] & 0x0f);
+
+ /* Variant specified in RFC 4122 */
+ uuid[8] = 0x80 | (uuid[8] & 0x3f);
+}