Lines Matching refs:ctx
71 struct x509_parse_context *ctx; in x509_cert_parse() local
82 ctx = kzalloc(sizeof(struct x509_parse_context), GFP_KERNEL); in x509_cert_parse()
83 if (!ctx) in x509_cert_parse()
86 ctx->cert = cert; in x509_cert_parse()
87 ctx->data = (unsigned long)data; in x509_cert_parse()
90 ret = asn1_ber_decoder(&x509_decoder, ctx, data, datalen); in x509_cert_parse()
95 if (ctx->raw_akid) { in x509_cert_parse()
97 ctx->raw_akid_size, ctx->raw_akid_size, ctx->raw_akid); in x509_cert_parse()
98 ret = asn1_ber_decoder(&x509_akid_decoder, ctx, in x509_cert_parse()
99 ctx->raw_akid, ctx->raw_akid_size); in x509_cert_parse()
107 ret = asn1_ber_decoder(&x509_rsakey_decoder, ctx, in x509_cert_parse()
108 ctx->key, ctx->key_size); in x509_cert_parse()
123 kfree(ctx); in x509_cert_parse()
127 kfree(ctx); in x509_cert_parse()
143 struct x509_parse_context *ctx = context; in x509_note_OID() local
145 ctx->last_oid = look_up_OID(value, vlen); in x509_note_OID()
146 if (ctx->last_oid == OID__NR) { in x509_note_OID()
150 (unsigned long)value - ctx->data, buffer); in x509_note_OID()
163 struct x509_parse_context *ctx = context; in x509_note_tbs_certificate() local
166 hdrlen, tag, (unsigned long)value - ctx->data, vlen); in x509_note_tbs_certificate()
168 ctx->cert->tbs = value - hdrlen; in x509_note_tbs_certificate()
169 ctx->cert->tbs_size = vlen + hdrlen; in x509_note_tbs_certificate()
180 struct x509_parse_context *ctx = context; in x509_note_pkey_algo() local
182 pr_debug("PubKey Algo: %u\n", ctx->last_oid); in x509_note_pkey_algo()
184 switch (ctx->last_oid) { in x509_note_pkey_algo()
191 ctx->cert->sig.pkey_hash_algo = HASH_ALGO_MD5; in x509_note_pkey_algo()
192 ctx->cert->sig.pkey_algo = PKEY_ALGO_RSA; in x509_note_pkey_algo()
196 ctx->cert->sig.pkey_hash_algo = HASH_ALGO_SHA1; in x509_note_pkey_algo()
197 ctx->cert->sig.pkey_algo = PKEY_ALGO_RSA; in x509_note_pkey_algo()
201 ctx->cert->sig.pkey_hash_algo = HASH_ALGO_SHA256; in x509_note_pkey_algo()
202 ctx->cert->sig.pkey_algo = PKEY_ALGO_RSA; in x509_note_pkey_algo()
206 ctx->cert->sig.pkey_hash_algo = HASH_ALGO_SHA384; in x509_note_pkey_algo()
207 ctx->cert->sig.pkey_algo = PKEY_ALGO_RSA; in x509_note_pkey_algo()
211 ctx->cert->sig.pkey_hash_algo = HASH_ALGO_SHA512; in x509_note_pkey_algo()
212 ctx->cert->sig.pkey_algo = PKEY_ALGO_RSA; in x509_note_pkey_algo()
216 ctx->cert->sig.pkey_hash_algo = HASH_ALGO_SHA224; in x509_note_pkey_algo()
217 ctx->cert->sig.pkey_algo = PKEY_ALGO_RSA; in x509_note_pkey_algo()
221 ctx->algo_oid = ctx->last_oid; in x509_note_pkey_algo()
232 struct x509_parse_context *ctx = context; in x509_note_signature() local
234 pr_debug("Signature type: %u size %zu\n", ctx->last_oid, vlen); in x509_note_signature()
236 if (ctx->last_oid != ctx->algo_oid) { in x509_note_signature()
238 ctx->algo_oid, ctx->last_oid); in x509_note_signature()
242 ctx->cert->raw_sig = value; in x509_note_signature()
243 ctx->cert->raw_sig_size = vlen; in x509_note_signature()
254 struct x509_parse_context *ctx = context; in x509_note_serial() local
255 ctx->cert->raw_serial = value; in x509_note_serial()
256 ctx->cert->raw_serial_size = vlen; in x509_note_serial()
267 struct x509_parse_context *ctx = context; in x509_extract_name_segment() local
269 switch (ctx->last_oid) { in x509_extract_name_segment()
271 ctx->cn_size = vlen; in x509_extract_name_segment()
272 ctx->cn_offset = (unsigned long)value - ctx->data; in x509_extract_name_segment()
275 ctx->o_size = vlen; in x509_extract_name_segment()
276 ctx->o_offset = (unsigned long)value - ctx->data; in x509_extract_name_segment()
279 ctx->email_size = vlen; in x509_extract_name_segment()
280 ctx->email_offset = (unsigned long)value - ctx->data; in x509_extract_name_segment()
292 static int x509_fabricate_name(struct x509_parse_context *ctx, size_t hdrlen, in x509_fabricate_name() argument
296 const void *name, *data = (const void *)ctx->data; in x509_fabricate_name()
304 if (!ctx->cn_size && !ctx->o_size && !ctx->email_size) { in x509_fabricate_name()
312 if (ctx->cn_size && ctx->o_size) { in x509_fabricate_name()
316 namesize = ctx->cn_size; in x509_fabricate_name()
317 name = data + ctx->cn_offset; in x509_fabricate_name()
318 if (ctx->cn_size >= ctx->o_size && in x509_fabricate_name()
319 memcmp(data + ctx->cn_offset, data + ctx->o_offset, in x509_fabricate_name()
320 ctx->o_size) == 0) in x509_fabricate_name()
322 if (ctx->cn_size >= 7 && in x509_fabricate_name()
323 ctx->o_size >= 7 && in x509_fabricate_name()
324 memcmp(data + ctx->cn_offset, data + ctx->o_offset, 7) == 0) in x509_fabricate_name()
327 buffer = kmalloc(ctx->o_size + 2 + ctx->cn_size + 1, in x509_fabricate_name()
333 data + ctx->o_offset, ctx->o_size); in x509_fabricate_name()
334 buffer[ctx->o_size + 0] = ':'; in x509_fabricate_name()
335 buffer[ctx->o_size + 1] = ' '; in x509_fabricate_name()
336 memcpy(buffer + ctx->o_size + 2, in x509_fabricate_name()
337 data + ctx->cn_offset, ctx->cn_size); in x509_fabricate_name()
338 buffer[ctx->o_size + 2 + ctx->cn_size] = 0; in x509_fabricate_name()
341 } else if (ctx->cn_size) { in x509_fabricate_name()
342 namesize = ctx->cn_size; in x509_fabricate_name()
343 name = data + ctx->cn_offset; in x509_fabricate_name()
344 } else if (ctx->o_size) { in x509_fabricate_name()
345 namesize = ctx->o_size; in x509_fabricate_name()
346 name = data + ctx->o_offset; in x509_fabricate_name()
348 namesize = ctx->email_size; in x509_fabricate_name()
349 name = data + ctx->email_offset; in x509_fabricate_name()
361 ctx->cn_size = 0; in x509_fabricate_name()
362 ctx->o_size = 0; in x509_fabricate_name()
363 ctx->email_size = 0; in x509_fabricate_name()
371 struct x509_parse_context *ctx = context; in x509_note_issuer() local
372 ctx->cert->raw_issuer = value; in x509_note_issuer()
373 ctx->cert->raw_issuer_size = vlen; in x509_note_issuer()
374 return x509_fabricate_name(ctx, hdrlen, tag, &ctx->cert->issuer, vlen); in x509_note_issuer()
381 struct x509_parse_context *ctx = context; in x509_note_subject() local
382 ctx->cert->raw_subject = value; in x509_note_subject()
383 ctx->cert->raw_subject_size = vlen; in x509_note_subject()
384 return x509_fabricate_name(ctx, hdrlen, tag, &ctx->cert->subject, vlen); in x509_note_subject()
394 struct x509_parse_context *ctx = context; in x509_extract_key_data() local
396 if (ctx->last_oid != OID_rsaEncryption) in x509_extract_key_data()
399 ctx->cert->pub->pkey_algo = PKEY_ALGO_RSA; in x509_extract_key_data()
402 ctx->key = value + 1; in x509_extract_key_data()
403 ctx->key_size = vlen - 1; in x509_extract_key_data()
414 struct x509_parse_context *ctx = context; in rsa_extract_mpi() local
417 if (ctx->nr_mpi >= ARRAY_SIZE(ctx->cert->pub->mpi)) { in rsa_extract_mpi()
426 ctx->cert->pub->mpi[ctx->nr_mpi++] = mpi; in rsa_extract_mpi()
440 struct x509_parse_context *ctx = context; in x509_process_extension() local
444 pr_debug("Extension: %u\n", ctx->last_oid); in x509_process_extension()
446 if (ctx->last_oid == OID_subjectKeyIdentifier) { in x509_process_extension()
448 if (ctx->cert->skid || vlen < 3) in x509_process_extension()
455 ctx->cert->raw_skid_size = vlen; in x509_process_extension()
456 ctx->cert->raw_skid = v; in x509_process_extension()
460 ctx->cert->skid = kid; in x509_process_extension()
465 if (ctx->last_oid == OID_authorityKeyIdentifier) { in x509_process_extension()
467 ctx->raw_akid = v; in x509_process_extension()
468 ctx->raw_akid_size = vlen; in x509_process_extension()
574 struct x509_parse_context *ctx = context; in x509_note_not_before() local
575 return x509_decode_time(&ctx->cert->valid_from, hdrlen, tag, value, vlen); in x509_note_not_before()
582 struct x509_parse_context *ctx = context; in x509_note_not_after() local
583 return x509_decode_time(&ctx->cert->valid_to, hdrlen, tag, value, vlen); in x509_note_not_after()
593 struct x509_parse_context *ctx = context; in x509_akid_note_kid() local
598 if (ctx->cert->akid_skid) in x509_akid_note_kid()
605 ctx->cert->akid_skid = kid; in x509_akid_note_kid()
616 struct x509_parse_context *ctx = context; in x509_akid_note_name() local
620 ctx->akid_raw_issuer = value; in x509_akid_note_name()
621 ctx->akid_raw_issuer_size = vlen; in x509_akid_note_name()
632 struct x509_parse_context *ctx = context; in x509_akid_note_serial() local
637 if (!ctx->akid_raw_issuer || ctx->cert->akid_id) in x509_akid_note_serial()
642 ctx->akid_raw_issuer, in x509_akid_note_serial()
643 ctx->akid_raw_issuer_size); in x509_akid_note_serial()
648 ctx->cert->akid_id = kid; in x509_akid_note_serial()