Index: sbin/geom/class/eli/geli.8 =================================================================== --- sbin/geom/class/eli/geli.8 +++ sbin/geom/class/eli/geli.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 17, 2017 +.Dd April 9, 2018 .Dt GELI 8 .Os .Sh NAME @@ -67,7 +67,7 @@ .Cm init .Nm .Cm attach -.Op Fl dprv +.Op Fl dnprv .Op Fl j Ar passfile .Op Fl k Ar keyfile .Ar prov @@ -420,6 +420,9 @@ option for the .Cm init subcommand. +.It Fl n +Do a dry-run decryption. +This is useful to verify passphrase and keyfile without decrypting the device. .It Fl p Do not use a passphrase as a component of the User Key. Cannot be combined with the Index: sbin/geom/class/eli/geom_eli.c =================================================================== --- sbin/geom/class/eli/geom_eli.c +++ sbin/geom/class/eli/geom_eli.c @@ -148,11 +148,12 @@ { 'd', "detach", NULL, G_TYPE_BOOL }, { 'j', "passfile", G_VAL_OPTIONAL, G_TYPE_STRING | G_TYPE_MULTI }, { 'k', "keyfile", G_VAL_OPTIONAL, G_TYPE_STRING | G_TYPE_MULTI }, + { 'n', "dryrun", NULL, G_TYPE_BOOL }, { 'p', "nopassphrase", NULL, G_TYPE_BOOL }, { 'r', "readonly", NULL, G_TYPE_BOOL }, G_OPT_SENTINEL }, - "[-dprv] [-j passfile] [-k keyfile] prov" + "[-dnprv] [-j passfile] [-k keyfile] prov" }, { "detach", 0, NULL, { Index: sys/geom/eli/g_eli_ctl.c =================================================================== --- sys/geom/eli/g_eli_ctl.c +++ sys/geom/eli/g_eli_ctl.c @@ -59,7 +59,7 @@ struct g_provider *pp; const char *name; u_char *key, mkey[G_ELI_DATAIVKEYLEN]; - int *nargs, *detach, *readonly; + int *nargs, *detach, *readonly, *dryrun; int keysize, error; u_int nkey; @@ -87,6 +87,12 @@ return; } + dryrun = gctl_get_paraml(req, "dryrun", sizeof(*dryrun)); + if (dryrun == NULL) { + gctl_error(req, "No '%s' argument.", "dryrun"); + return; + } + if (*detach && *readonly) { gctl_error(req, "Options -d and -r are mutually exclusive."); return; @@ -141,7 +147,8 @@ md.md_flags |= G_ELI_FLAG_WO_DETACH; if (*readonly) md.md_flags |= G_ELI_FLAG_RO; - g_eli_create(req, mp, pp, &md, mkey, nkey); + if (!*dryrun) + g_eli_create(req, mp, pp, &md, mkey, nkey); explicit_bzero(mkey, sizeof(mkey)); explicit_bzero(&md, sizeof(md)); }