Lines Matching +full:eoc +full:- +full:level

1 /*-
32 * http://blog.engelke.com/2014/10/17/parsing-ber-and-der-encoded-asn-1-objects/
62 #define DER_BAD CAST(uint32_t, -1)
118 "eoc", "bool", "int", "bit_str", "octet_str",
125 "oid-iri", "rel-oid-iri",
165 tag = tag * 128 + c[(*p)++] - 0x80; in gettag()
216 if (len > UINT32_MAX - *p || *p + len > l) { in getlength()
249 "20%c%c-%c%c-%c%c %c%c:%c%c:%c%c GMT", d[0], d[1], d[2], in der_data()
257 if (z < blen - 2) in der_data()
258 snprintf(buf + z, blen - z, "%.2x", d[i]); in der_data()
266 const uint8_t *b = RCAST(const uint8_t *, ms->search.s); in der_offs()
267 size_t offs = 0, len = ms->search.s_len ? ms->search.s_len : nbytes; in der_offs()
271 return -1; in der_offs()
273 DPRINTF(("%s1: %u %" SIZE_T_FORMAT "u %d\n", __func__, ms->offset, in der_offs()
274 offs, m->offset)); in der_offs()
279 return -1; in der_offs()
281 DPRINTF(("%s2: %u %" SIZE_T_FORMAT "u %u\n", __func__, ms->offset, in der_offs()
284 offs += ms->offset + m->offset; in der_offs()
285 DPRINTF(("cont_level = %d\n", m->cont_level)); in der_offs()
288 for (i = 0; i < m->cont_level; i++) in der_offs()
290 ms->c.li[i].off); in der_offs()
292 if (m->cont_level != 0) { in der_offs()
294 return -1; in der_offs()
295 ms->c.li[m->cont_level - 1].off = CAST(int, offs + tlen); in der_offs()
296 DPRINTF(("cont_level[%u] = %d\n", m->cont_level - 1, in der_offs()
297 ms->c.li[m->cont_level - 1].off)); in der_offs()
305 const uint8_t *b = RCAST(const uint8_t *, ms->search.s); in der_cmp()
306 const char *s = m->value.s; in der_cmp()
307 size_t offs = 0, len = ms->search.s_len; in der_cmp()
316 return -1; in der_cmp()
319 DPRINTF(("%s1: %d %" SIZE_T_FORMAT "u %d\n", __func__, ms->offset, in der_cmp()
320 offs, m->offset)); in der_cmp()
325 return -1; in der_cmp()
329 if ((ms->flags & MAGIC_DEBUG) != 0) in der_cmp()
357 slen = slen * 10 + *s - '0'; in der_cmp()
359 if ((ms->flags & MAGIC_DEBUG) != 0) in der_cmp()
372 if ((ms->flags & MAGIC_DEBUG) != 0) in der_cmp()
378 strlcpy(ms->ms_value.s, buf, sizeof(ms->ms_value.s)); in der_cmp()
406 printdata(size_t level, const void *v, size_t x, size_t l) in printdata() argument
418 // printf("%.2x %.2x %.2x\n", p[x - 1], p[x], p[x + 1]); in printdata()
419 uint32_t tag = gettag(p, &x, ep - p + x); in printdata()
422 uint32_t len = getlength(p, &x, ep - p + x); in printdata()
424 printf("%" SIZE_T_FORMAT "u %" SIZE_T_FORMAT "u-%" in printdata()
425 SIZE_T_FORMAT "u %c,%c,%s,%u:", level, ox, x, in printdata()
433 printdata(level + 1, p, x, len + x); in printdata()
446 if ((fd = open(argv[1], O_RDONLY)) == -1) in main()
448 if (fstat(fd, &st) == -1) in main()