~ubuntu-branches/ubuntu/saucy/wpasupplicant/saucy

« back to all changes in this revision

Viewing changes to src/utils/uuid.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2010-11-22 09:43:43 UTC
  • mfrom: (1.1.16 upstream)
  • Revision ID: james.westby@ubuntu.com-20101122094343-qgsxaojvmswfri77
Tags: 0.7.3-0ubuntu1
* Get wpasupplicant 0.7.3 from Debian's SVN. Leaving 0.7.3-1 as unreleased
  for now.
* Build-Depend on debhelper 8, since the packaging from Debian uses compat 8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#include "includes.h"
16
16
 
17
17
#include "common.h"
18
 
#include "crypto.h"
19
 
#include "sha1.h"
20
18
#include "uuid.h"
21
19
 
22
20
int uuid_str2bin(const char *str, u8 *bin)
77
75
                        return 0;
78
76
        return 1;
79
77
}
80
 
 
81
 
 
82
 
void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid)
83
 
{
84
 
        const u8 *addr[2];
85
 
        size_t len[2];
86
 
        u8 hash[SHA1_MAC_LEN];
87
 
        u8 nsid[16] = {
88
 
                0x52, 0x64, 0x80, 0xf8,
89
 
                0xc9, 0x9b,
90
 
                0x4b, 0xe5,
91
 
                0xa6, 0x55,
92
 
                0x58, 0xed, 0x5f, 0x5d, 0x60, 0x84
93
 
        };
94
 
 
95
 
        addr[0] = nsid;
96
 
        len[0] = sizeof(nsid);
97
 
        addr[1] = mac_addr;
98
 
        len[1] = 6;
99
 
        sha1_vector(2, addr, len, hash);
100
 
        os_memcpy(uuid, hash, 16);
101
 
 
102
 
        /* Version: 5 = named-based version using SHA-1 */
103
 
        uuid[6] = (5 << 4) | (uuid[6] & 0x0f);
104
 
 
105
 
        /* Variant specified in RFC 4122 */
106
 
        uuid[8] = 0x80 | (uuid[8] & 0x3f);
107
 
}