summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2006-06-06 22:06:24 +0000
committerpjd <pjd@FreeBSD.org>2006-06-06 22:06:24 +0000
commitec70ef58cb0b1e1ae85196811da2e42d64dac5a0 (patch)
tree2a855b24d212057fbebbf49f60b05e7ab78a75c5 /sys/geom
parent88f89f303f98a490372396329e6e2b207a3a08d3 (diff)
downloadFreeBSD-src-ec70ef58cb0b1e1ae85196811da2e42d64dac5a0.zip
FreeBSD-src-ec70ef58cb0b1e1ae85196811da2e42d64dac5a0.tar.gz
Allow to use the old -a option to specify an encryption algorithm to use
(for backward compatibility), but print a warning to inform about the change.
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/eli/g_eli_ctl.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/sys/geom/eli/g_eli_ctl.c b/sys/geom/eli/g_eli_ctl.c
index a7b6b45..a6db6c2 100644
--- a/sys/geom/eli/g_eli_ctl.c
+++ b/sys/geom/eli/g_eli_ctl.c
@@ -250,6 +250,7 @@ g_eli_ctl_onetime(struct gctl_req *req, struct g_class *mp)
if (*detach)
md.md_flags |= G_ELI_FLAG_WO_DETACH;
+ md.md_ealgo = CRYPTO_ALGORITHM_MIN - 1;
name = gctl_get_asciiparam(req, "aalgo");
if (name == NULL) {
gctl_error(req, "No '%s' argument.", "aalgo");
@@ -257,24 +258,41 @@ g_eli_ctl_onetime(struct gctl_req *req, struct g_class *mp)
}
if (strcmp(name, "none") != 0) {
md.md_aalgo = g_eli_str2aalgo(name);
- if (md.md_aalgo < CRYPTO_ALGORITHM_MIN ||
- md.md_aalgo > CRYPTO_ALGORITHM_MAX) {
- gctl_error(req, "Invalid authentication algorithm.");
- return;
+ if (md.md_aalgo >= CRYPTO_ALGORITHM_MIN &&
+ md.md_aalgo <= CRYPTO_ALGORITHM_MAX) {
+ md.md_flags |= G_ELI_FLAG_AUTH;
+ } else {
+ /*
+ * For backward compatibility, check if the -a option
+ * was used to provide encryption algorithm.
+ */
+ md.md_ealgo = g_eli_str2ealgo(name);
+ if (md.md_ealgo < CRYPTO_ALGORITHM_MIN ||
+ md.md_ealgo > CRYPTO_ALGORITHM_MAX) {
+ gctl_error(req,
+ "Invalid authentication algorithm.");
+ return;
+ } else {
+ gctl_error(req, "warning: The -e option, not "
+ "the -a option is now used to specify "
+ "encryption algorithm to use.");
+ }
}
- md.md_flags |= G_ELI_FLAG_AUTH;
}
- name = gctl_get_asciiparam(req, "ealgo");
- if (name == NULL) {
- gctl_error(req, "No '%s' argument.", "ealgo");
- return;
- }
- md.md_ealgo = g_eli_str2ealgo(name);
if (md.md_ealgo < CRYPTO_ALGORITHM_MIN ||
md.md_ealgo > CRYPTO_ALGORITHM_MAX) {
- gctl_error(req, "Invalid encryption algorithm.");
- return;
+ name = gctl_get_asciiparam(req, "ealgo");
+ if (name == NULL) {
+ gctl_error(req, "No '%s' argument.", "ealgo");
+ return;
+ }
+ md.md_ealgo = g_eli_str2ealgo(name);
+ if (md.md_ealgo < CRYPTO_ALGORITHM_MIN ||
+ md.md_ealgo > CRYPTO_ALGORITHM_MAX) {
+ gctl_error(req, "Invalid encryption algorithm.");
+ return;
+ }
}
keylen = gctl_get_paraml(req, "keylen", sizeof(*keylen));
OpenPOWER on IntegriCloud