Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 914c69344bd47cd9bdd70ec10555f3ab28b3c5ab)
+++ uspace/lib/c/Makefile	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
@@ -133,4 +133,5 @@
 	generic/double_to_str.c \
 	generic/malloc.c \
+	generic/rndgen.c \
 	generic/stdio/scanf.c \
 	generic/stdio/sprintf.c \
Index: uspace/lib/c/generic/rndgen.c
===================================================================
--- uspace/lib/c/generic/rndgen.c	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
+++ uspace/lib/c/generic/rndgen.c	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2018 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/**
+ * @file
+ * @brief Random number generator.
+ *
+ * Generate random (as opposed to pseudorandom) numbers. This should be
+ * used sparingly (e.g. to seed a pseudorandom number generator).
+ */
+
+#include <errno.h>
+#include <rndgen.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <time.h>
+
+/** Create random number generator.
+ *
+ * @param rrndgen Place to store new random number generator
+ * @return EOK on success or error code
+ */
+errno_t rndgen_create(rndgen_t **rrndgen)
+{
+	rndgen_t *rndgen;
+	struct timeval tv;
+
+	rndgen = calloc(1, sizeof(rndgen_t));
+	if (rndgen == NULL)
+		return ENOMEM;
+
+	/* XXX This is a rather poor way of generating random numbers */
+	gettimeofday(&tv, NULL);
+	rndgen->seed = tv.tv_sec ^ tv.tv_usec;
+
+	*rrndgen = rndgen;
+	return EOK;
+}
+
+/** Destroy random number generator.
+ *
+ * @param rndgen Random number generator or @c NULL
+ */
+void rndgen_destroy(rndgen_t *rndgen)
+{
+	if (rndgen == NULL)
+		return;
+
+	free(rndgen);
+}
+
+/** Generate random 8-bit integer.
+ *
+ * @param rndgen Random number generator
+ * @param rb Place to store random 8-bit integer
+ * @return EOK on success or error code
+ */
+errno_t rndgen_uint8(rndgen_t *rndgen, uint8_t *rb)
+{
+	rndgen->seed = (1366 * rndgen->seed + 150889) % 714025;
+
+	*rb = rndgen->seed & 0xff;
+	return EOK;
+}
+
+/** Generate random 32-bit integer.
+ *
+ * @param rndgen Random number generator
+ * @param rw Place to store random 32-bit integer
+ * @return EOK on success or error code
+ */
+errno_t rndgen_uint32(rndgen_t *rndgen, uint32_t *rw)
+{
+	int i;
+	uint8_t b;
+	uint32_t w;
+	errno_t rc;
+
+	w = 0;
+	for (i = 0; i < 4; i++) {
+		rc = rndgen_uint8(rndgen, &b);
+		if (rc != EOK)
+			return rc;
+
+		w = (w << 8) | b;
+	}
+
+	*rw = w;
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/lib/c/generic/uuid.c
===================================================================
--- uspace/lib/c/generic/uuid.c	(revision 914c69344bd47cd9bdd70ec10555f3ab28b3c5ab)
+++ uspace/lib/c/generic/uuid.c	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
@@ -35,7 +35,7 @@
 #include <errno.h>
 #include <uuid.h>
+#include <rndgen.h>
 #include <stdlib.h>
 #include <stddef.h>
-#include <time.h>
 #include <str.h>
 
@@ -48,12 +48,18 @@
 {
 	int i;
-	struct timeval tv;
+	rndgen_t *rndgen;
+	errno_t rc;
 
-	/* XXX This is a rather poor way of generating random numbers */
-	gettimeofday(&tv, NULL);
-	srand(tv.tv_sec ^ tv.tv_usec);
+	rc = rndgen_create(&rndgen);
+	if (rc != EOK)
+		return EIO;
 
-	for (i = 0; i < uuid_bytes; i++)
-		uuid->b[i] = rand();
+	for (i = 0; i < uuid_bytes; i++) {
+		rc = rndgen_uint8(rndgen, &uuid->b[i]);
+		if (rc != EOK) {
+			rc = EIO;
+			goto error;
+		}
+	}
 
 	/* Version 4 UUID from random or pseudo-random numbers */
@@ -62,4 +68,7 @@
 
 	return EOK;
+error:
+	rndgen_destroy(rndgen);
+	return rc;
 }
 
Index: uspace/lib/c/include/rndgen.h
===================================================================
--- uspace/lib/c/include/rndgen.h	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
+++ uspace/lib/c/include/rndgen.h	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2018 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file Random number generator
+ */
+
+#ifndef LIBC_RNDGEN_H_
+#define LIBC_RNDGEN_H_
+
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+
+typedef struct {
+	unsigned int seed;
+} rndgen_t;
+
+extern errno_t rndgen_create(rndgen_t **);
+extern void rndgen_destroy(rndgen_t *);
+extern errno_t rndgen_uint8(rndgen_t *, uint8_t *);
+extern errno_t rndgen_uint32(rndgen_t *, uint32_t *);
+
+#endif
+
+/** @}
+ */
