summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/geom/eli/g_eli.c24
-rw-r--r--sys/geom/eli/g_eli_ctl.c20
-rw-r--r--sys/geom/eli/g_eli_key.c25
3 files changed, 27 insertions, 42 deletions
diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c
index 3b9ffdd81b..fd04ee2 100644
--- a/sys/geom/eli/g_eli.c
+++ b/sys/geom/eli/g_eli.c
@@ -817,30 +817,6 @@ 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
- * every access to sector, so now will be much better.
- */
- switch (sc->sc_ealgo) {
- case CRYPTO_AES_XTS:
- break;
- default:
- SHA256_Init(&sc->sc_ivctx);
- SHA256_Update(&sc->sc_ivctx, sc->sc_ivkey,
- sizeof(sc->sc_ivkey));
- break;
- }
LIST_INIT(&sc->sc_workers);
diff --git a/sys/geom/eli/g_eli_ctl.c b/sys/geom/eli/g_eli_ctl.c
index 7147b27..f1dbfbd 100644
--- a/sys/geom/eli/g_eli_ctl.c
+++ b/sys/geom/eli/g_eli_ctl.c
@@ -882,26 +882,10 @@ g_eli_ctl_resume(struct gctl_req *req, struct g_class *mp)
mtx_lock(&sc->sc_queue_mtx);
/* Restore sc_mkey, sc_ekeys, sc_akey and sc_ivkey. */
g_eli_mkey_propagate(sc, mkey);
- bzero(mkey, sizeof(mkey));
- bzero(&md, sizeof(md));
- /* Restore sc_akeyctx. */
- if (sc->sc_flags & G_ELI_FLAG_AUTH) {
- SHA256_Init(&sc->sc_akeyctx);
- SHA256_Update(&sc->sc_akeyctx, sc->sc_akey,
- sizeof(sc->sc_akey));
- }
- /* Restore sc_ivctx. */
- switch (sc->sc_ealgo) {
- case CRYPTO_AES_XTS:
- break;
- default:
- SHA256_Init(&sc->sc_ivctx);
- SHA256_Update(&sc->sc_ivctx, sc->sc_ivkey,
- sizeof(sc->sc_ivkey));
- break;
- }
sc->sc_flags &= ~G_ELI_FLAG_SUSPEND;
mtx_unlock(&sc->sc_queue_mtx);
+ bzero(mkey, sizeof(mkey));
+ bzero(&md, sizeof(md));
G_ELI_DEBUG(1, "Resumed %s.", pp->name);
wakeup(sc);
}
diff --git a/sys/geom/eli/g_eli_key.c b/sys/geom/eli/g_eli_key.c
index bb060e4..37b2ad3 100644
--- a/sys/geom/eli/g_eli_key.c
+++ b/sys/geom/eli/g_eli_key.c
@@ -264,5 +264,30 @@ g_eli_mkey_propagate(struct g_eli_softc *sc, const unsigned char *mkey)
/* Generate all encryption keys. */
g_eli_ekeys_generate(sc);
}
+
+ 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
+ * every access to sector, so now will be much better.
+ */
+ switch (sc->sc_ealgo) {
+ case CRYPTO_AES_XTS:
+ break;
+ default:
+ SHA256_Init(&sc->sc_ivctx);
+ SHA256_Update(&sc->sc_ivctx, sc->sc_ivkey,
+ sizeof(sc->sc_ivkey));
+ break;
+ }
}
#endif
OpenPOWER on IntegriCloud