diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2013-04-29 19:21:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:42 -0400 |
commit | cedddb00023b1321f2bb2739739aa8c9927fc063 (patch) | |
tree | 425bb1e104ffd4693b28076ee35bcad8f7fbfcd9 /lib/uuid.c | |
parent | 3ec39abdcc0d3099e8d8894dcbcc8c9490ee48e2 (diff) |
uuid: use prandom_bytes()
Use prandom_bytes() to generate 16 bytes of pseudo-random bytes.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Huang Ying <ying.huang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/uuid.c')
-rw-r--r-- | lib/uuid.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/uuid.c b/lib/uuid.c index 52a6fe6387de..398821e4dce1 100644 --- a/lib/uuid.c +++ b/lib/uuid.c | |||
@@ -25,13 +25,7 @@ | |||
25 | 25 | ||
26 | static void __uuid_gen_common(__u8 b[16]) | 26 | static void __uuid_gen_common(__u8 b[16]) |
27 | { | 27 | { |
28 | int i; | 28 | prandom_bytes(b, 16); |
29 | u32 r; | ||
30 | |||
31 | for (i = 0; i < 4; i++) { | ||
32 | r = random32(); | ||
33 | memcpy(b + i * 4, &r, 4); | ||
34 | } | ||
35 | /* reversion 0b10 */ | 29 | /* reversion 0b10 */ |
36 | b[8] = (b[8] & 0x3F) | 0x80; | 30 | b[8] = (b[8] & 0x3F) | 0x80; |
37 | } | 31 | } |