From ec70ef58cb0b1e1ae85196811da2e42d64dac5a0 Mon Sep 17 00:00:00 2001 From: pjd Date: Tue, 6 Jun 2006 22:06:24 +0000 Subject: 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. --- sbin/geom/class/eli/geom_eli.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'sbin') diff --git a/sbin/geom/class/eli/geom_eli.c b/sbin/geom/class/eli/geom_eli.c index 90df179..eac6a80 100644 --- a/sbin/geom/class/eli/geom_eli.c +++ b/sbin/geom/class/eli/geom_eli.c @@ -527,22 +527,40 @@ eli_init(struct gctl_req *req) md.md_flags = 0; if (gctl_get_int(req, "boot")) md.md_flags |= G_ELI_FLAG_BOOT; + md.md_ealgo = CRYPTO_ALGORITHM_MIN - 1; str = gctl_get_ascii(req, "aalgo"); if (strcmp(str, "none") != 0) { md.md_aalgo = g_eli_str2aalgo(str); - 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(str); + if (md.md_ealgo < CRYPTO_ALGORITHM_MIN || + md.md_ealgo > CRYPTO_ALGORITHM_MAX) { + gctl_error(req, + "Invalid authentication algorithm."); + return; + } else { + fprintf(stderr, "warning: The -e option, not " + "the -a option is now used to specify " + "encryption algorithm to use.\n"); + } } - md.md_flags |= G_ELI_FLAG_AUTH; } - str = gctl_get_ascii(req, "ealgo"); - md.md_ealgo = g_eli_str2ealgo(str); if (md.md_ealgo < CRYPTO_ALGORITHM_MIN || md.md_ealgo > CRYPTO_ALGORITHM_MAX) { - gctl_error(req, "Invalid encryption algorithm."); - return; + str = gctl_get_ascii(req, "ealgo"); + md.md_ealgo = g_eli_str2ealgo(str); + if (md.md_ealgo < CRYPTO_ALGORITHM_MIN || + md.md_ealgo > CRYPTO_ALGORITHM_MAX) { + gctl_error(req, "Invalid encryption algorithm."); + return; + } } val = gctl_get_intmax(req, "keylen"); md.md_keylen = val; -- cgit v1.1