12 #define pr_fmt(fmt) "X.509: "fmt
13 #include <linux/kernel.h>
14 #include <linux/slab.h>
19 #include "x509-asn1.h"
20 #include "x509_rsakey-asn1.h"
105 const void *
value,
size_t vlen)
112 sprint_oid(value, vlen, buffer,
sizeof(buffer));
114 (
unsigned long)value - ctx->
data, buffer);
125 const void *
value,
size_t vlen)
129 pr_debug(
"x509_note_tbs_certificate(,%zu,%02x,%ld,%zu)!\n",
130 hdrlen, tag, (
unsigned long)value - ctx->
data, vlen);
142 const void *
value,
size_t vlen)
194 const void *
value,
size_t vlen)
201 pr_warn(
"Got cert with pkey (%u) and sig (%u) algorithm OIDs\n",
207 ctx->
cert->sig_size = vlen;
216 const void *
value,
size_t vlen)
245 char **_name,
size_t vlen)
272 goto single_component;
276 goto single_component;
320 const void *
value,
size_t vlen)
323 return x509_fabricate_name(ctx, hdrlen, tag, &ctx->
cert->issuer, vlen);
328 const void *
value,
size_t vlen)
331 return x509_fabricate_name(ctx, hdrlen, tag, &ctx->
cert->subject, vlen);
339 const void *
value,
size_t vlen)
348 ctx->
key = value + 1;
358 const void *
value,
size_t vlen)
364 pr_err(
"Too many public key MPIs in certificate\n");
381 const void *
value,
size_t vlen)
384 const unsigned char *
v =
value;
394 if (v[0] !=
ASN1_OTS || v[1] != vlen - 2)
402 for (i = 0; i < vlen; i++)
403 sprintf(f + i * 2,
"%02x", v[i]);
405 ctx->
cert->fingerprint =
f;
424 for (i = 0; i < vlen; i++)
425 sprintf(f + i * 2,
"%02x", v[i]);
427 ctx->
cert->authority =
f;
437 static int x509_note_time(
struct tm *
tm,
size_t hdrlen,
439 const unsigned char *
value,
size_t vlen)
441 const unsigned char *
p =
value;
443 #define dec2bin(X) ((X) - '0')
444 #define DD2bin(P) ({ unsigned x = dec2bin(P[0]) * 10 + dec2bin(P[1]); P += 2; x; })
449 goto unsupported_time;
458 goto unsupported_time;
461 goto unsupported_time;
472 goto unsupported_time;
477 pr_debug(
"Got unsupported time [tag %02x]: '%*.*s'\n",
478 tag, (
int)vlen, (
int)vlen, value);
484 const void *value,
size_t vlen)
487 return x509_note_time(&ctx->
cert->valid_from, hdrlen, tag, value, vlen);
492 const void *value,
size_t vlen)
495 return x509_note_time(&ctx->
cert->valid_to, hdrlen, tag, value, vlen);