Lines Matching refs:md
260 eli_metadata_encode_v0(struct g_eli_metadata *md, u_char **datap) in eli_metadata_encode_v0() argument
265 le32enc(p, md->md_flags); p += sizeof(md->md_flags); in eli_metadata_encode_v0()
266 le16enc(p, md->md_ealgo); p += sizeof(md->md_ealgo); in eli_metadata_encode_v0()
267 le16enc(p, md->md_keylen); p += sizeof(md->md_keylen); in eli_metadata_encode_v0()
268 le64enc(p, md->md_provsize); p += sizeof(md->md_provsize); in eli_metadata_encode_v0()
269 le32enc(p, md->md_sectorsize); p += sizeof(md->md_sectorsize); in eli_metadata_encode_v0()
270 *p = md->md_keys; p += sizeof(md->md_keys); in eli_metadata_encode_v0()
271 le32enc(p, md->md_iterations); p += sizeof(md->md_iterations); in eli_metadata_encode_v0()
272 bcopy(md->md_salt, p, sizeof(md->md_salt)); p += sizeof(md->md_salt); in eli_metadata_encode_v0()
273 bcopy(md->md_mkeys, p, sizeof(md->md_mkeys)); p += sizeof(md->md_mkeys); in eli_metadata_encode_v0()
277 eli_metadata_encode_v1v2v3v4v5v6v7(struct g_eli_metadata *md, u_char **datap) in eli_metadata_encode_v1v2v3v4v5v6v7() argument
282 le32enc(p, md->md_flags); p += sizeof(md->md_flags); in eli_metadata_encode_v1v2v3v4v5v6v7()
283 le16enc(p, md->md_ealgo); p += sizeof(md->md_ealgo); in eli_metadata_encode_v1v2v3v4v5v6v7()
284 le16enc(p, md->md_keylen); p += sizeof(md->md_keylen); in eli_metadata_encode_v1v2v3v4v5v6v7()
285 le16enc(p, md->md_aalgo); p += sizeof(md->md_aalgo); in eli_metadata_encode_v1v2v3v4v5v6v7()
286 le64enc(p, md->md_provsize); p += sizeof(md->md_provsize); in eli_metadata_encode_v1v2v3v4v5v6v7()
287 le32enc(p, md->md_sectorsize); p += sizeof(md->md_sectorsize); in eli_metadata_encode_v1v2v3v4v5v6v7()
288 *p = md->md_keys; p += sizeof(md->md_keys); in eli_metadata_encode_v1v2v3v4v5v6v7()
289 le32enc(p, md->md_iterations); p += sizeof(md->md_iterations); in eli_metadata_encode_v1v2v3v4v5v6v7()
290 bcopy(md->md_salt, p, sizeof(md->md_salt)); p += sizeof(md->md_salt); in eli_metadata_encode_v1v2v3v4v5v6v7()
291 bcopy(md->md_mkeys, p, sizeof(md->md_mkeys)); p += sizeof(md->md_mkeys); in eli_metadata_encode_v1v2v3v4v5v6v7()
295 eli_metadata_encode(struct g_eli_metadata *md, u_char *data) in eli_metadata_encode() argument
302 bcopy(md->md_magic, p, sizeof(md->md_magic)); in eli_metadata_encode()
303 p += sizeof(md->md_magic); in eli_metadata_encode()
304 le32enc(p, md->md_version); in eli_metadata_encode()
305 p += sizeof(md->md_version); in eli_metadata_encode()
306 switch (md->md_version) { in eli_metadata_encode()
308 eli_metadata_encode_v0(md, &p); in eli_metadata_encode()
317 eli_metadata_encode_v1v2v3v4v5v6v7(md, &p); in eli_metadata_encode()
322 (u_int)md->md_version); in eli_metadata_encode()
330 bcopy(hash, md->md_hash, sizeof(md->md_hash)); in eli_metadata_encode()
331 bcopy(md->md_hash, p, sizeof(md->md_hash)); in eli_metadata_encode()
334 eli_metadata_decode_v0(const u_char *data, struct g_eli_metadata *md) in eli_metadata_decode_v0() argument
340 p = data + sizeof(md->md_magic) + sizeof(md->md_version); in eli_metadata_decode_v0()
341 md->md_flags = le32dec(p); p += sizeof(md->md_flags); in eli_metadata_decode_v0()
342 md->md_ealgo = le16dec(p); p += sizeof(md->md_ealgo); in eli_metadata_decode_v0()
343 md->md_keylen = le16dec(p); p += sizeof(md->md_keylen); in eli_metadata_decode_v0()
344 md->md_provsize = le64dec(p); p += sizeof(md->md_provsize); in eli_metadata_decode_v0()
345 md->md_sectorsize = le32dec(p); p += sizeof(md->md_sectorsize); in eli_metadata_decode_v0()
346 md->md_keys = *p; p += sizeof(md->md_keys); in eli_metadata_decode_v0()
347 md->md_iterations = le32dec(p); p += sizeof(md->md_iterations); in eli_metadata_decode_v0()
348 bcopy(p, md->md_salt, sizeof(md->md_salt)); p += sizeof(md->md_salt); in eli_metadata_decode_v0()
349 bcopy(p, md->md_mkeys, sizeof(md->md_mkeys)); p += sizeof(md->md_mkeys); in eli_metadata_decode_v0()
353 bcopy(hash, md->md_hash, sizeof(md->md_hash)); in eli_metadata_decode_v0()
354 if (bcmp(md->md_hash, p, 16) != 0) in eli_metadata_decode_v0()
360 eli_metadata_decode_v1v2v3v4v5v6v7(const u_char *data, struct g_eli_metadata *md) in eli_metadata_decode_v1v2v3v4v5v6v7() argument
366 p = data + sizeof(md->md_magic) + sizeof(md->md_version); in eli_metadata_decode_v1v2v3v4v5v6v7()
367 md->md_flags = le32dec(p); p += sizeof(md->md_flags); in eli_metadata_decode_v1v2v3v4v5v6v7()
368 md->md_ealgo = le16dec(p); p += sizeof(md->md_ealgo); in eli_metadata_decode_v1v2v3v4v5v6v7()
369 md->md_keylen = le16dec(p); p += sizeof(md->md_keylen); in eli_metadata_decode_v1v2v3v4v5v6v7()
370 md->md_aalgo = le16dec(p); p += sizeof(md->md_aalgo); in eli_metadata_decode_v1v2v3v4v5v6v7()
371 md->md_provsize = le64dec(p); p += sizeof(md->md_provsize); in eli_metadata_decode_v1v2v3v4v5v6v7()
372 md->md_sectorsize = le32dec(p); p += sizeof(md->md_sectorsize); in eli_metadata_decode_v1v2v3v4v5v6v7()
373 md->md_keys = *p; p += sizeof(md->md_keys); in eli_metadata_decode_v1v2v3v4v5v6v7()
374 md->md_iterations = le32dec(p); p += sizeof(md->md_iterations); in eli_metadata_decode_v1v2v3v4v5v6v7()
375 bcopy(p, md->md_salt, sizeof(md->md_salt)); p += sizeof(md->md_salt); in eli_metadata_decode_v1v2v3v4v5v6v7()
376 bcopy(p, md->md_mkeys, sizeof(md->md_mkeys)); p += sizeof(md->md_mkeys); in eli_metadata_decode_v1v2v3v4v5v6v7()
380 bcopy(hash, md->md_hash, sizeof(md->md_hash)); in eli_metadata_decode_v1v2v3v4v5v6v7()
381 if (bcmp(md->md_hash, p, 16) != 0) in eli_metadata_decode_v1v2v3v4v5v6v7()
386 eli_metadata_decode(const u_char *data, struct g_eli_metadata *md) in eli_metadata_decode() argument
390 bcopy(data, md->md_magic, sizeof(md->md_magic)); in eli_metadata_decode()
391 if (strcmp(md->md_magic, G_ELI_MAGIC) != 0) in eli_metadata_decode()
393 md->md_version = le32dec(data + sizeof(md->md_magic)); in eli_metadata_decode()
394 switch (md->md_version) { in eli_metadata_decode()
396 error = eli_metadata_decode_v0(data, md); in eli_metadata_decode()
405 error = eli_metadata_decode_v1v2v3v4v5v6v7(data, md); in eli_metadata_decode()
481 eli_metadata_dump(const struct g_eli_metadata *md) in eli_metadata_dump() argument
484 char str[sizeof(md->md_mkeys) * 2 + 1]; in eli_metadata_dump()
487 printf(" magic: %s\n", md->md_magic); in eli_metadata_dump()
488 printf(" version: %u\n", (u_int)md->md_version); in eli_metadata_dump()
489 printf(" flags: 0x%x\n", (u_int)md->md_flags); in eli_metadata_dump()
490 printf(" ealgo: %s\n", g_eli_algo2str(md->md_ealgo)); in eli_metadata_dump()
491 printf(" keylen: %u\n", (u_int)md->md_keylen); in eli_metadata_dump()
492 if (md->md_flags & G_ELI_FLAG_AUTH) in eli_metadata_dump()
493 printf(" aalgo: %s\n", g_eli_algo2str(md->md_aalgo)); in eli_metadata_dump()
494 printf(" provsize: %ju\n", (uintmax_t)md->md_provsize); in eli_metadata_dump()
495 printf("sectorsize: %u\n", (u_int)md->md_sectorsize); in eli_metadata_dump()
496 printf(" keys: 0x%02x\n", (u_int)md->md_keys); in eli_metadata_dump()
497 printf("iterations: %d\n", (int)md->md_iterations); in eli_metadata_dump()
499 for (i = 0; i < sizeof(md->md_salt); i++) { in eli_metadata_dump()
500 str[i * 2] = hex[md->md_salt[i] >> 4]; in eli_metadata_dump()
501 str[i * 2 + 1] = hex[md->md_salt[i] & 0x0f]; in eli_metadata_dump()
505 for (i = 0; i < sizeof(md->md_mkeys); i++) { in eli_metadata_dump()
506 str[i * 2] = hex[md->md_mkeys[i] >> 4]; in eli_metadata_dump()
507 str[i * 2 + 1] = hex[md->md_mkeys[i] & 0x0f]; in eli_metadata_dump()
512 str[i * 2] = hex[md->md_hash[i] >> 4]; in eli_metadata_dump()
513 str[i * 2 + 1] = hex[md->md_hash[i] & 0x0f]; in eli_metadata_dump()
520 eli_metadata_crypto_supported(const struct g_eli_metadata *md) in eli_metadata_crypto_supported() argument
523 switch (md->md_ealgo) { in eli_metadata_crypto_supported()
532 if (md->md_flags & G_ELI_FLAG_AUTH) { in eli_metadata_crypto_supported()
533 switch (md->md_aalgo) { in eli_metadata_crypto_supported()
640 eli_metadata_softc(struct g_eli_softc *sc, const struct g_eli_metadata *md, in eli_metadata_softc() argument
644 sc->sc_version = md->md_version; in eli_metadata_softc()
647 sc->sc_flags = md->md_flags; in eli_metadata_softc()
649 if (md->md_version < G_ELI_VERSION_04) in eli_metadata_softc()
651 if (md->md_version < G_ELI_VERSION_05) in eli_metadata_softc()
653 if (md->md_version < G_ELI_VERSION_06 && in eli_metadata_softc()
657 if (md->md_version < G_ELI_VERSION_07) in eli_metadata_softc()
659 sc->sc_ealgo = md->md_ealgo; in eli_metadata_softc()
663 sc->sc_aalgo = md->md_aalgo; in eli_metadata_softc()
677 (md->md_sectorsize - 1) / sc->sc_data_per_sector + 1; in eli_metadata_softc()
681 sc->sc_sectorsize = md->md_sectorsize; in eli_metadata_softc()
683 sc->sc_ekeylen = md->md_keylen; in eli_metadata_softc()
688 struct g_eli_metadata *md);
690 struct g_provider *bpp, const struct g_eli_metadata *md,
714 int g_eli_mkey_decrypt(const struct g_eli_metadata *md,
716 int g_eli_mkey_decrypt_any(const struct g_eli_metadata *md,
738 void g_eli_crypto_hmac_final(struct hmac_ctx *ctx, uint8_t *md, size_t mdsize);
740 const uint8_t *data, size_t datasize, uint8_t *md, size_t mdsize);