File: sc_asn1_decode.3

package info (click to toggle)
opensc 0.11.1-2etch2
  • links: PTS
  • area: main
  • in suites: etch
  • size: 7,284 kB
  • ctags: 7,257
  • sloc: ansic: 69,499; sh: 9,480; xml: 4,191; makefile: 346; lex: 92; perl: 25
file content (54 lines) | stat: -rw-r--r-- 1,756 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
.\"Generated by db2man.xsl. Don't modify this, modify the source.
.de Sh \" Subsection
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Ip \" List item
.br
.ie \\n(.$>=3 .ne \\$3
.el .ne 3
.IP "\\$1" \\$2
..
.TH "SC_ASN1_DECODE" 3 "" "" "OpenSC API Reference"
.SH NAME
sc_asn1_decode \- Extract entries from an ASN.1 stream
.SH "SYNOPSIS"

.PP


.nf

#include <opensc\&.h>

int sc_asn1_decode(struct sc_context *ctx, struct sc_asn1_entry *asn1,
                   const unsigned char *inbuf, size_t len,
                   const unsigned char **newbuf, size_t *len_left);
		
.fi
 

.SH "DESCRIPTION"

.PP
This function extracts information from the ASN\&.1 stream pointed to by \fIinbuf\fR (which is \fIlen\fR bytes in size) and stores it into the array ofstruct sc_asn_1 entries pointed to by\fIasn1\fR\&. The array must be big enough to contain all the entries that will be found, or an error will be flagged\&. The last entry in the array must be a NULL entry, i\&.e\&. thename field must be set to NULL\&.

.PP
The structure of the expected data must be encoded in the entries in \fIasn1\fR before calling this function; specifically the name,type, tag andflags fields must be filled in\&.

.PP
The function will then scan the stream and fill in the remaining fields\&.\fInewbuf\fR will point to the byte immediately following the extracted record, and\fIlen_left\fR will contain the number of bytes left in the buffer\&. Thus, the\fInewbuf\fR and \fIlen_left\fR fields may be passed in to sc_asn1_decode() again, as the \fIinbuf\fR and \fIlen\fR parameters, until \fIlen\fR reaches 0\&.

.SH "RETURN VALUE"

.PP
Returns 0 if successful, or a negative value in case of error\&.