diff options
author | pjd <pjd@FreeBSD.org> | 2010-10-21 12:58:26 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2010-10-21 12:58:26 +0000 |
commit | 5a22d5e5873c05f015da11627eef679204444c63 (patch) | |
tree | 6d78d71517aacbbe1e5db228af48e40771417d2a /sys | |
parent | 62105f897951821d357533dd4028ade0a41d0fa0 (diff) | |
download | FreeBSD-src-5a22d5e5873c05f015da11627eef679204444c63.zip FreeBSD-src-5a22d5e5873c05f015da11627eef679204444c63.tar.gz |
Fix a bug introduced in r213067 where we use authentication key before
initializing it.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/geom/eli/g_eli.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index 66f641b..0d9b9c7 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -686,14 +686,6 @@ g_eli_create(struct gctl_req *req, struct g_class *mp, struct g_provider *bpp, sc->sc_bytes_per_sector = (md->md_sectorsize - 1) / sc->sc_data_per_sector + 1; sc->sc_bytes_per_sector *= bpp->sectorsize; - /* - * Precalculate SHA256 for HMAC key generation. - * This is expensive operation and we can do it only once now or - * for every access to sector, so now will be much better. - */ - SHA256_Init(&sc->sc_akeyctx); - SHA256_Update(&sc->sc_akeyctx, sc->sc_akey, - sizeof(sc->sc_akey)); } gp->softc = sc; @@ -753,7 +745,16 @@ g_eli_create(struct gctl_req *req, struct g_class *mp, struct g_provider *bpp, */ g_eli_mkey_propagate(sc, mkey); sc->sc_ekeylen = md->md_keylen; - + if (sc->sc_flags & G_ELI_FLAG_AUTH) { + /* + * Precalculate SHA256 for HMAC key generation. + * This is expensive operation and we can do it only once now or + * for every access to sector, so now will be much better. + */ + SHA256_Init(&sc->sc_akeyctx); + SHA256_Update(&sc->sc_akeyctx, sc->sc_akey, + sizeof(sc->sc_akey)); + } /* * Precalculate SHA256 for IV generation. * This is expensive operation and we can do it only once now or for |