Lines Matching refs:ctx

98 asn1_open(struct asn1_ctx *ctx, unsigned char *buf, unsigned int len)
100 ctx->begin = buf;
101 ctx->end = buf + len;
102 ctx->pointer = buf;
103 ctx->error = ASN1_ERR_NOERROR;
107 asn1_octet_decode(struct asn1_ctx *ctx, unsigned char *ch)
109 if (ctx->pointer >= ctx->end) {
110 ctx->error = ASN1_ERR_DEC_EMPTY;
113 *ch = *(ctx->pointer)++;
119 asn1_enum_decode(struct asn1_ctx *ctx, __le32 *val)
123 if (ctx->pointer >= ctx->end) {
124 ctx->error = ASN1_ERR_DEC_EMPTY;
128 ch = *(ctx->pointer)++; /* ch has 0xa, ptr points to length octet */
130 *val = *(++(ctx->pointer)); /* value has enum value */
134 ctx->pointer++;
140 asn1_tag_decode(struct asn1_ctx *ctx, unsigned int *tag)
147 if (!asn1_octet_decode(ctx, &ch))
156 asn1_id_decode(struct asn1_ctx *ctx,
161 if (!asn1_octet_decode(ctx, &ch))
169 if (!asn1_tag_decode(ctx, tag))
176 asn1_length_decode(struct asn1_ctx *ctx, unsigned int *def, unsigned int *len)
180 if (!asn1_octet_decode(ctx, &ch))
195 if (!asn1_octet_decode(ctx, &ch))
204 /* don't trust len bigger than ctx buffer */
205 if (*len > ctx->end - ctx->pointer)
212 asn1_header_decode(struct asn1_ctx *ctx,
219 if (!asn1_id_decode(ctx, cls, con, tag))
222 if (!asn1_length_decode(ctx, &def, &len))
230 *eoc = ctx->pointer + len;
237 asn1_eoc_decode(struct asn1_ctx *ctx, unsigned char *eoc)
242 if (!asn1_octet_decode(ctx, &ch))
246 ctx->error = ASN1_ERR_DEC_EOC_MISMATCH;
250 if (!asn1_octet_decode(ctx, &ch))
254 ctx->error = ASN1_ERR_DEC_EOC_MISMATCH;
259 if (ctx->pointer != eoc) {
260 ctx->error = ASN1_ERR_DEC_LENGTH_MISMATCH;
267 /* static unsigned char asn1_null_decode(struct asn1_ctx *ctx,
270 ctx->pointer = eoc;
274 static unsigned char asn1_long_decode(struct asn1_ctx *ctx,
280 if (!asn1_octet_decode(ctx, &ch))
286 while (ctx->pointer < eoc) {
288 ctx->error = ASN1_ERR_DEC_BADVALUE;
292 if (!asn1_octet_decode(ctx, &ch))
301 static unsigned char asn1_uint_decode(struct asn1_ctx *ctx,
308 if (!asn1_octet_decode(ctx, &ch))
317 while (ctx->pointer < eoc) {
319 ctx->error = ASN1_ERR_DEC_BADVALUE;
323 if (!asn1_octet_decode(ctx, &ch))
332 static unsigned char asn1_ulong_decode(struct asn1_ctx *ctx,
339 if (!asn1_octet_decode(ctx, &ch))
348 while (ctx->pointer < eoc) {
350 ctx->error = ASN1_ERR_DEC_BADVALUE;
354 if (!asn1_octet_decode(ctx, &ch))
364 asn1_octets_decode(struct asn1_ctx *ctx,
372 *octets = kmalloc(eoc - ctx->pointer, GFP_ATOMIC);
378 while (ctx->pointer < eoc) {
379 if (!asn1_octet_decode(ctx, (unsigned char *) ptr++)) {
390 asn1_subid_decode(struct asn1_ctx *ctx, unsigned long *subid)
397 if (!asn1_octet_decode(ctx, &ch))
407 asn1_oid_decode(struct asn1_ctx *ctx,
414 size = eoc - ctx->pointer + 1;
426 if (!asn1_subid_decode(ctx, &subid)) {
446 while (ctx->pointer < eoc) {
448 ctx->error = ASN1_ERR_DEC_BADVALUE;
454 if (!asn1_subid_decode(ctx, optr++)) {
486 struct asn1_ctx ctx;
494 asn1_open(&ctx, security_blob, length);
497 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
507 rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
511 rc = asn1_oid_decode(&ctx, end, &oid, &oidlen);
528 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
539 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
550 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
562 (&ctx, &sequence_end, &cls, &con, &tag) == 0) {
573 while (!asn1_eoc_decode(&ctx, sequence_end)) {
574 rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
580 if (asn1_oid_decode(&ctx, end, &oid, &oidlen)) {