Deleted Added
sdiff udiff text old ( 162347 ) new ( 162353 )
full compact
1/*-
2 * Copyright (c) 2004-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sbin/geom/class/eli/geom_eli.c 162347 2006-09-16 09:26:57Z pjd $");
29
30#include <stdio.h>
31#include <stdint.h>
32#include <stdlib.h>
33#include <unistd.h>
34#include <fcntl.h>
35#include <readpassphrase.h>
36#include <string.h>

--- 23 unchanged lines hidden (view full) ---

60static intmax_t keyno = -1;
61static intmax_t iterations = -1;
62static intmax_t sectorsize = 0;
63static char keyfile[] = "", newkeyfile[] = "";
64
65static void eli_main(struct gctl_req *req, unsigned flags);
66static void eli_init(struct gctl_req *req);
67static void eli_attach(struct gctl_req *req);
68static void eli_setkey(struct gctl_req *req);
69static void eli_delkey(struct gctl_req *req);
70static void eli_kill(struct gctl_req *req);
71static void eli_backup(struct gctl_req *req);
72static void eli_restore(struct gctl_req *req);
73static void eli_clear(struct gctl_req *req);
74static void eli_dump(struct gctl_req *req);
75
76/*
77 * Available commands:
78 *
79 * init [-bhPv] [-a aalgo] [-e ealgo] [-i iterations] [-l keylen] [-K newkeyfile] prov
80 * label - alias for 'init'
81 * attach [-dprv] [-k keyfile] prov
82 * detach [-fl] prov ...
83 * stop - alias for 'detach'
84 * onetime [-d] [-a aalgo] [-e ealgo] [-l keylen] prov ...
85 * setkey [-pPv] [-n keyno] [-k keyfile] [-K newkeyfile] prov
86 * delkey [-afv] [-n keyno] prov
87 * kill [-av] [prov ...]
88 * backup [-v] prov file
89 * restore [-v] file prov
90 * clear [-v] prov ...
91 * dump [-v] prov ...
92 */

--- 58 unchanged lines hidden (view full) ---

151 { 'd', "detach", NULL, G_TYPE_NONE },
152 { 'e', "ealgo", ealgo, G_TYPE_STRING },
153 { 'l', "keylen", &keylen, G_TYPE_NUMBER },
154 { 's', "sectorsize", &sectorsize, G_TYPE_NUMBER },
155 G_OPT_SENTINEL
156 },
157 "[-d] [-a aalgo] [-e ealgo] [-l keylen] [-s sectorsize] prov ..."
158 },
159 { "setkey", G_FLAG_VERBOSE, eli_main,
160 {
161 { 'i', "iterations", &iterations, G_TYPE_NUMBER },
162 { 'k', "keyfile", keyfile, G_TYPE_STRING },
163 { 'K', "newkeyfile", newkeyfile, G_TYPE_STRING },
164 { 'n', "keyno", &keyno, G_TYPE_NUMBER },
165 { 'p', "nopassphrase", NULL, G_TYPE_NONE },
166 { 'P', "nonewpassphrase", NULL, G_TYPE_NONE },

--- 70 unchanged lines hidden (view full) ---

237 if (name == NULL) {
238 gctl_error(req, "No '%s' argument.", "verb");
239 return;
240 }
241 if (strcmp(name, "init") == 0 || strcmp(name, "label") == 0)
242 eli_init(req);
243 else if (strcmp(name, "attach") == 0)
244 eli_attach(req);
245 else if (strcmp(name, "setkey") == 0)
246 eli_setkey(req);
247 else if (strcmp(name, "delkey") == 0)
248 eli_delkey(req);
249 else if (strcmp(name, "kill") == 0)
250 eli_kill(req);
251 else if (strcmp(name, "backup") == 0)
252 eli_backup(req);

--- 408 unchanged lines hidden (view full) ---

661 if (gctl_issue(req) == NULL) {
662 if (verbose)
663 printf("Attched to %s.\n", prov);
664 }
665 bzero(key, sizeof(key));
666}
667
668static void
669eli_setkey_attached(struct gctl_req *req, struct g_eli_metadata *md)
670{
671 unsigned char key[G_ELI_USERKEYLEN];
672 intmax_t val;
673
674 val = gctl_get_intmax(req, "iterations");
675 /* Check if iterations number should be changed. */
676 if (val != -1)

--- 484 unchanged lines hidden ---