summaryrefslogtreecommitdiffstats
path: root/sbin/geom/class
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2013-02-10 15:55:42 +0000
committerpjd <pjd@FreeBSD.org>2013-02-10 15:55:42 +0000
commit007755626aecbbb77acb634bc17a8f7c675187ca (patch)
tree71ed174d08fa78e4c1cd7fb65b5cb52f4b00f2e0 /sbin/geom/class
parentaade44b4e0666d993d852d338acb6a3fb309f11e (diff)
downloadFreeBSD-src-007755626aecbbb77acb634bc17a8f7c675187ca.zip
FreeBSD-src-007755626aecbbb77acb634bc17a8f7c675187ca.tar.gz
Use arc4random_buf(3) instead of reimplementing it.
Diffstat (limited to 'sbin/geom/class')
-rw-r--r--sbin/geom/class/eli/geom_eli.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/sbin/geom/class/eli/geom_eli.c b/sbin/geom/class/eli/geom_eli.c
index f209800..ed65fff 100644
--- a/sbin/geom/class/eli/geom_eli.c
+++ b/sbin/geom/class/eli/geom_eli.c
@@ -326,22 +326,6 @@ eli_main(struct gctl_req *req, unsigned int flags)
gctl_error(req, "Unknown command: %s.", name);
}
-static void
-arc4rand(unsigned char *buf, size_t size)
-{
- uint32_t *buf4;
- size_t size4;
- unsigned int i;
-
- buf4 = (uint32_t *)buf;
- size4 = size / 4;
-
- for (i = 0; i < size4; i++)
- buf4[i] = arc4random();
- for (i *= 4; i < size; i++)
- buf[i] = arc4random() % 0xff;
-}
-
static bool
eli_is_attached(const char *prov)
{
@@ -813,8 +797,8 @@ eli_init(struct gctl_req *req)
}
md.md_keys = 0x01;
- arc4rand(md.md_salt, sizeof(md.md_salt));
- arc4rand(md.md_mkeys, sizeof(md.md_mkeys));
+ arc4random_buf(md.md_salt, sizeof(md.md_salt));
+ arc4random_buf(md.md_mkeys, sizeof(md.md_mkeys));
/* Generate user key. */
if (eli_genkey(req, &md, key, true) == NULL) {
@@ -1146,7 +1130,7 @@ eli_delkey_detached(struct gctl_req *req, const char *prov)
all = gctl_get_int(req, "all");
if (all)
- arc4rand(md.md_mkeys, sizeof(md.md_mkeys));
+ arc4random_buf(md.md_mkeys, sizeof(md.md_mkeys));
else {
force = gctl_get_int(req, "force");
val = gctl_get_intmax(req, "keyno");
@@ -1170,7 +1154,7 @@ eli_delkey_detached(struct gctl_req *req, const char *prov)
return;
}
mkeydst = md.md_mkeys + nkey * G_ELI_MKEYLEN;
- arc4rand(mkeydst, G_ELI_MKEYLEN);
+ arc4random_buf(mkeydst, G_ELI_MKEYLEN);
}
eli_metadata_store(req, prov, &md);
@@ -1262,7 +1246,7 @@ eli_trash_metadata(struct gctl_req *req, const char *prov, int fd, off_t offset)
error = 0;
do {
- arc4rand(sector, size);
+ arc4random_buf(sector, size);
if (pwrite(fd, sector, size, offset) != size) {
if (error == 0)
error = errno;
OpenPOWER on IntegriCloud