diff options
author | Pawel Jakub Dawidek <pjd@FreeBSD.org> | 2013-02-10 15:55:42 +0000 |
---|---|---|
committer | Pawel Jakub Dawidek <pjd@FreeBSD.org> | 2013-02-10 15:55:42 +0000 |
commit | d4e5fe17e680449caeb0628ee183d962fbeab0ca (patch) | |
tree | 71ed174d08fa78e4c1cd7fb65b5cb52f4b00f2e0 | |
parent | 9a71ddccd092a74958841d5b0f33f0b8e1dba1dc (diff) | |
download | src-test2-d4e5fe17e680449caeb0628ee183d962fbeab0ca.tar.gz src-test2-d4e5fe17e680449caeb0628ee183d962fbeab0ca.zip |
Notes
-rw-r--r-- | sbin/geom/class/eli/geom_eli.c | 26 |
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 f20980024bb7..ed65fff2bc9c 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; |