Changeset View
Changeset View
Standalone View
Standalone View
lib/libsecureboot/vectx.c
Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | vectx_open(int fd, const char *path, off_t off, struct stat *stp, int *error) | ||||
ctx->vec_status = 0; | ctx->vec_status = 0; | ||||
hashsz = 0; | hashsz = 0; | ||||
cp = fingerprint_info_lookup(fd, path); | cp = fingerprint_info_lookup(fd, path); | ||||
if (!cp) { | if (!cp) { | ||||
ctx->vec_status = VE_FINGERPRINT_NONE; | ctx->vec_status = VE_FINGERPRINT_NONE; | ||||
ve_error_set("%s: no entry", path); | ve_error_set("%s: no entry", path); | ||||
} else { | } else { | ||||
if (strncmp(cp, "sha256=", 7) == 0) { | if (strncmp(cp, "no_hash", 7) == 0) { | ||||
ctx->vec_status = VE_FINGERPRINT_IGNORE; | |||||
hashsz = 0; | |||||
} else if (strncmp(cp, "sha256=", 7) == 0) { | |||||
ctx->vec_md = &br_sha256_vtable; | ctx->vec_md = &br_sha256_vtable; | ||||
hashsz = br_sha256_SIZE; | hashsz = br_sha256_SIZE; | ||||
cp += 7; | cp += 7; | ||||
#ifdef VE_SHA1_SUPPORT | #ifdef VE_SHA1_SUPPORT | ||||
} else if (strncmp(cp, "sha1=", 5) == 0) { | } else if (strncmp(cp, "sha1=", 5) == 0) { | ||||
ctx->vec_md = &br_sha1_vtable; | ctx->vec_md = &br_sha1_vtable; | ||||
hashsz = br_sha1_SIZE; | hashsz = br_sha1_SIZE; | ||||
cp += 5; | cp += 5; | ||||
Show All 13 Lines | #endif | ||||
} else { | } else { | ||||
ctx->vec_status = VE_FINGERPRINT_UNKNOWN; | ctx->vec_status = VE_FINGERPRINT_UNKNOWN; | ||||
ve_error_set("%s: no supported fingerprint", path); | ve_error_set("%s: no supported fingerprint", path); | ||||
} | } | ||||
} | } | ||||
*error = ctx->vec_status; | *error = ctx->vec_status; | ||||
ctx->vec_hashsz = hashsz; | ctx->vec_hashsz = hashsz; | ||||
ctx->vec_want = cp; | ctx->vec_want = cp; | ||||
if (hashsz > 0) { | |||||
ctx->vec_md->init(&ctx->vec_ctx.vtable); | ctx->vec_md->init(&ctx->vec_ctx.vtable); | ||||
if (hashsz > 0 && off > 0) { | if (off > 0) { | ||||
lseek(fd, 0, SEEK_SET); | lseek(fd, 0, SEEK_SET); | ||||
vectx_lseek(ctx, off, SEEK_SET); | vectx_lseek(ctx, off, SEEK_SET); | ||||
} | |||||
} | } | ||||
return (ctx); | return (ctx); | ||||
enomem: /* unlikely */ | enomem: /* unlikely */ | ||||
*error = ENOMEM; | *error = ENOMEM; | ||||
free(ctx); | free(ctx); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |