g_eli ivgen
Ivan Voras
ivoras at freebsd.org
Sun Sep 13 00:23:53 UTC 2009
I'm looking at doing something in GELI and I've come across the
following code in g_eli.c:
381 void
382 g_eli_crypto_ivgen(struct g_eli_softc *sc, off_t offset, u_char *iv,
383 size_t size)
384 {
385 u_char off[8], hash[SHA256_DIGEST_LENGTH];
386 SHA256_CTX ctx;
387
388 if (!(sc->sc_flags & G_ELI_FLAG_NATIVE_BYTE_ORDER))
389 le64enc(off, (uint64_t)offset);
390 /* Copy precalculated SHA256 context for IV-Key. */
391 bcopy(&sc->sc_ivctx, &ctx, sizeof(ctx));
392 SHA256_Update(&ctx, (uint8_t *)&offset, sizeof(offset));
393 SHA256_Final(hash, &ctx);
394 bcopy(hash, iv, size);
395 }
I don't get the purpose of the off variable - specifically, it looks
unused. It looks to me like the idea was to convert offset to off if
G_ELI_FLAG_NATIVE_BYTE_ORDER is not set but then it never got used and
there's an "else" clause missing. Is this correct or am I missing something?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-geom/attachments/20090913/221c77c1/signature.pgp
More information about the freebsd-geom
mailing list