Always initialize sc_ekey, because as of r238116 it is always used.
If GELI provider was created on FreeBSD HEAD r238116 or later (but before this change), it is using very weak keys and the data is not protected. The bug was introduced on 4th July 2012. One can verify if its provider was created with weak keys by running: # geli dump <provider> | grep version If the version is 7 and the system didn't include this fix when provider was initialized, then the data has to be backed up, underlying provider overwritten with random data, system upgraded and provider recreated. Reported by: Fabian Keil <fk@fabiankeil.de> Tested by: Fabian Keil <fk@fabiankeil.de> Discussed with: so MFC after: 3 days
This commit is contained in:
parent
9000aabf3b
commit
9d18043979
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=239184
@ -193,24 +193,24 @@ g_eli_key_remove(struct g_eli_softc *sc, struct g_eli_key *key)
|
||||
void
|
||||
g_eli_key_init(struct g_eli_softc *sc)
|
||||
{
|
||||
uint8_t *mkey;
|
||||
|
||||
mtx_lock(&sc->sc_ekeys_lock);
|
||||
|
||||
mkey = sc->sc_mkey + sizeof(sc->sc_ivkey);
|
||||
if ((sc->sc_flags & G_ELI_FLAG_AUTH) == 0)
|
||||
bcopy(mkey, sc->sc_ekey, G_ELI_DATAKEYLEN);
|
||||
else {
|
||||
/*
|
||||
* The encryption key is: ekey = HMAC_SHA512(Data-Key, 0x10)
|
||||
*/
|
||||
g_eli_crypto_hmac(mkey, G_ELI_MAXKEYLEN, "\x10", 1,
|
||||
sc->sc_ekey, 0);
|
||||
}
|
||||
|
||||
if ((sc->sc_flags & G_ELI_FLAG_SINGLE_KEY) != 0) {
|
||||
uint8_t *mkey;
|
||||
|
||||
mkey = sc->sc_mkey + sizeof(sc->sc_ivkey);
|
||||
|
||||
sc->sc_ekeys_total = 1;
|
||||
sc->sc_ekeys_allocated = 0;
|
||||
if ((sc->sc_flags & G_ELI_FLAG_AUTH) == 0)
|
||||
bcopy(mkey, sc->sc_ekey, G_ELI_DATAKEYLEN);
|
||||
else {
|
||||
/*
|
||||
* The encryption key is: ekey = HMAC_SHA512(Data-Key, 0x10)
|
||||
*/
|
||||
g_eli_crypto_hmac(mkey, G_ELI_MAXKEYLEN, "\x10", 1,
|
||||
sc->sc_ekey, 0);
|
||||
}
|
||||
} else {
|
||||
off_t mediasize;
|
||||
size_t blocksize;
|
||||
@ -241,6 +241,7 @@ g_eli_key_init(struct g_eli_softc *sc)
|
||||
(uintmax_t)sc->sc_ekeys_allocated));
|
||||
}
|
||||
}
|
||||
|
||||
mtx_unlock(&sc->sc_ekeys_lock);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user