• Home
  • Raw
  • Download

Lines Matching full:guid

54 // This class is used to generate random GUID.
55 // Currently use random number to generate a GUID since Linux has
56 // no native GUID generator. This should be OK since we don't expect
75 static bool CreateGUID(GUID *guid) { in CreateGUID() argument
77 CreateGuidFromArc4Random(guid); in CreateGUID()
82 success = CreateGUIDFromGetrandom(guid); in CreateGUID()
85 success = CreateGUIDFromDevUrandom(guid); in CreateGUID()
89 CreateGUIDFromRand(guid); in CreateGUID()
95 guid->data3 &= 0x0fff; in CreateGUID()
96 guid->data3 |= 0x4000; in CreateGUID()
99 guid->data4[0] &= 0x3f; in CreateGUID()
100 guid->data4[0] |= 0x80; in CreateGUID()
107 static void CreateGuidFromArc4Random(GUID *guid) { in CreateGuidFromArc4Random() argument
108 char *buf = reinterpret_cast<char *>(guid); in CreateGuidFromArc4Random()
110 for (size_t i = 0; i < sizeof(GUID); i += sizeof(uint32_t)) { in CreateGuidFromArc4Random()
131 static bool CreateGUIDFromGetrandom(GUID *guid) {
132 char *buf = reinterpret_cast<char *>(guid);
133 int read_bytes = getrandom(buf, sizeof(GUID), GRND_NONBLOCK);
135 return (read_bytes == static_cast<int>(sizeof(GUID)));
139 // Populate the GUID using random bytes read from /dev/urandom, returns false
140 // if the GUID wasn't fully populated with random data.
141 static bool CreateGUIDFromDevUrandom(GUID *guid) {
142 char *buf = reinterpret_cast<char *>(guid);
149 ssize_t read_bytes = HANDLE_EINTR(read(fd, buf, sizeof(GUID)));
152 return (read_bytes == static_cast<ssize_t>(sizeof(GUID)));
155 // Populate the GUID using a stream of random bytes obtained from rand().
156 static void CreateGUIDFromRand(GUID *guid) {
157 char *buf = reinterpret_cast<char *>(guid);
161 for (size_t i = 0; i < sizeof(GUID); i++) {
172 bool CreateGUID(GUID *guid) { in CreateGUID() argument
173 return GUIDGenerator::CreateGUID(guid); in CreateGUID()
176 // Parse guid to string.
177 bool GUIDToString(const GUID *guid, char *buf, int buf_len) { in GUIDToString() argument
178 // Should allow more space the the max length of GUID. in GUIDToString()
181 guid->data1, guid->data2, guid->data3, in GUIDToString()
182 GUIDGenerator::BytesToUInt32(&(guid->data4[0])), in GUIDToString()
183 GUIDGenerator::BytesToUInt32(&(guid->data4[4]))); in GUIDToString()