• Home
  • Raw
  • Download

Lines Matching refs:ctx

23 			       struct pefile_context *ctx)  in pefile_parse_binary()  argument
60 ctx->image_checksum_offset = in pefile_parse_binary()
62 ctx->header_size = pe32->header_size; in pefile_parse_binary()
64 ctx->n_data_dirents = pe32->data_dirs; in pefile_parse_binary()
69 ctx->image_checksum_offset = in pefile_parse_binary()
71 ctx->header_size = pe64->header_size; in pefile_parse_binary()
73 ctx->n_data_dirents = pe64->data_dirs; in pefile_parse_binary()
81 pr_debug("checksum @ %x\n", ctx->image_checksum_offset); in pefile_parse_binary()
82 pr_debug("header size = %x\n", ctx->header_size); in pefile_parse_binary()
84 if (cursor >= ctx->header_size || ctx->header_size >= datalen) in pefile_parse_binary()
87 if (ctx->n_data_dirents > (ctx->header_size - cursor) / sizeof(*dde)) in pefile_parse_binary()
91 cursor += sizeof(*dde) * ctx->n_data_dirents; in pefile_parse_binary()
93 ctx->cert_dirent_offset = in pefile_parse_binary()
95 ctx->certs_size = ddir->certs.size; in pefile_parse_binary()
102 chkaddr(ctx->header_size, ddir->certs.virtual_address, in pefile_parse_binary()
104 ctx->sig_offset = ddir->certs.virtual_address; in pefile_parse_binary()
105 ctx->sig_len = ddir->certs.size; in pefile_parse_binary()
107 ctx->sig_len, ctx->sig_offset, in pefile_parse_binary()
108 ctx->sig_len, pebuf + ctx->sig_offset); in pefile_parse_binary()
110 ctx->n_sections = pe->sections; in pefile_parse_binary()
111 if (ctx->n_sections > (ctx->header_size - cursor) / sizeof(*sec)) in pefile_parse_binary()
113 ctx->secs = secs = pebuf + cursor; in pefile_parse_binary()
123 struct pefile_context *ctx) in pefile_strip_sig_wrapper() argument
129 if (ctx->sig_len < sizeof(wrapper)) { in pefile_strip_sig_wrapper()
134 memcpy(&wrapper, pebuf + ctx->sig_offset, sizeof(wrapper)); in pefile_strip_sig_wrapper()
144 if (wrapper.length > ctx->sig_len) { in pefile_strip_sig_wrapper()
146 ctx->sig_len, wrapper.length); in pefile_strip_sig_wrapper()
163 ctx->sig_len = wrapper.length; in pefile_strip_sig_wrapper()
164 ctx->sig_offset += sizeof(wrapper); in pefile_strip_sig_wrapper()
165 ctx->sig_len -= sizeof(wrapper); in pefile_strip_sig_wrapper()
166 if (ctx->sig_len < 4) { in pefile_strip_sig_wrapper()
172 pkcs7 = pebuf + ctx->sig_offset; in pefile_strip_sig_wrapper()
195 if (len <= ctx->sig_len) { in pefile_strip_sig_wrapper()
197 ctx->sig_len = len; in pefile_strip_sig_wrapper()
246 struct pefile_context *ctx, in pefile_digest_pe_contents() argument
255 ret = crypto_shash_update(desc, pebuf, ctx->image_checksum_offset); in pefile_digest_pe_contents()
259 tmp = ctx->image_checksum_offset + sizeof(uint32_t); in pefile_digest_pe_contents()
261 ctx->cert_dirent_offset - tmp); in pefile_digest_pe_contents()
265 tmp = ctx->cert_dirent_offset + sizeof(struct data_dirent); in pefile_digest_pe_contents()
266 ret = crypto_shash_update(desc, pebuf + tmp, ctx->header_size - tmp); in pefile_digest_pe_contents()
270 canon = kcalloc(ctx->n_sections, sizeof(unsigned), GFP_KERNEL); in pefile_digest_pe_contents()
278 for (loop = 1; loop < ctx->n_sections; loop++) { in pefile_digest_pe_contents()
280 if (pefile_compare_shdrs(&ctx->secs[canon[i]], in pefile_digest_pe_contents()
281 &ctx->secs[loop]) > 0) { in pefile_digest_pe_contents()
290 hashed_bytes = ctx->header_size; in pefile_digest_pe_contents()
291 for (loop = 0; loop < ctx->n_sections; loop++) { in pefile_digest_pe_contents()
293 if (ctx->secs[i].raw_data_size == 0) in pefile_digest_pe_contents()
296 pebuf + ctx->secs[i].data_addr, in pefile_digest_pe_contents()
297 ctx->secs[i].raw_data_size); in pefile_digest_pe_contents()
302 hashed_bytes += ctx->secs[i].raw_data_size; in pefile_digest_pe_contents()
307 tmp = hashed_bytes + ctx->certs_size; in pefile_digest_pe_contents()
323 struct pefile_context *ctx) in pefile_digest_pe() argument
331 kenter(",%s", ctx->digest_algo); in pefile_digest_pe()
336 tfm = crypto_alloc_shash(ctx->digest_algo, 0, 0); in pefile_digest_pe()
343 if (digest_size != ctx->digest_len) { in pefile_digest_pe()
345 digest_size, ctx->digest_len); in pefile_digest_pe()
361 ret = pefile_digest_pe_contents(pebuf, pelen, ctx, desc); in pefile_digest_pe()
370 pr_debug("Digest calc = [%*ph]\n", ctx->digest_len, digest); in pefile_digest_pe()
375 if (memcmp(digest, ctx->digest, ctx->digest_len) != 0) { in pefile_digest_pe()
424 struct pefile_context ctx; in verify_pefile_signature() local
429 memset(&ctx, 0, sizeof(ctx)); in verify_pefile_signature()
430 ret = pefile_parse_binary(pebuf, pelen, &ctx); in verify_pefile_signature()
434 ret = pefile_strip_sig_wrapper(pebuf, &ctx); in verify_pefile_signature()
439 pebuf + ctx.sig_offset, ctx.sig_len, in verify_pefile_signature()
441 mscode_parse, &ctx); in verify_pefile_signature()
446 ctx.digest_len, ctx.digest_len, ctx.digest); in verify_pefile_signature()
451 ret = pefile_digest_pe(pebuf, pelen, &ctx); in verify_pefile_signature()
454 kfree_sensitive(ctx.digest); in verify_pefile_signature()