1SC_ASN1_DECODE(3) OpenSC API reference SC_ASN1_DECODE(3)
2
3
4
6 sc_asn1_decode - Extract entries from an ASN.1 stream
7
9 #include <opensc.h>
10
11 int sc_asn1_decode(struct sc_context *ctx, struct sc_asn1_entry *asn1,
12 const unsigned char *inbuf, size_t len,
13 const unsigned char **newbuf, size_t *len_left);
14
15
16
18 This function extracts information from the ASN.1 stream pointed to by
19 inbuf (which is len bytes in size) and stores it into the array of
20 struct sc_asn_1 entries pointed to by asn1. The array must be big
21 enough to contain all the entries that will be found, or an error will
22 be flagged. The last entry in the array must be a NULL entry, i.e. the
23 name field must be set to NULL.
24
25 The structure of the expected data must be encoded in the entries in
26 asn1 before calling this function; specifically the name, type, tag and
27 flags fields must be filled in.
28
29 The function will then scan the stream and fill in the remaining
30 fields. newbuf will point to the byte immediately following the
31 extracted record, and len_left will contain the number of bytes left in
32 the buffer. Thus, the newbuf and len_left fields may be passed in to
33 sc_asn1_decode() again, as the inbuf and len parameters, until len
34 reaches 0.
35
37 Returns 0 if successful, or a negative value in case of error.
38
39
40
41opensc 02/16/2010 SC_ASN1_DECODE(3)