~ubuntu-branches/ubuntu/hardy/gnupg/hardy-updates

« back to all changes in this revision

Viewing changes to g10/tlv.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2005-12-16 16:57:39 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20051216165739-v0m2d1you6hd8jho
Tags: upstream-1.4.2
ImportĀ upstreamĀ versionĀ 1.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 *
16
16
 * You should have received a copy of the GNU General Public License
17
17
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 
19
 * USA.
19
20
 */
20
21
 
21
22
#ifndef SCD_TLV_H
22
23
#define SCD_TLV_H 1
23
24
 
24
 
#include "types.h"
25
 
#include "cardglue.h"
26
25
 
27
26
enum tlv_tag_class {
28
27
  CLASS_UNIVERSAL = 0,
64
63
};
65
64
 
66
65
 
 
66
/* Locate a TLV encoded data object in BUFFER of LENGTH and return a
 
67
   pointer to value as well as its length in NBYTES.  Return NULL if
 
68
   it was not found or if the object does not fit into the buffer. */
 
69
const unsigned char *find_tlv (const unsigned char *buffer, size_t length,
 
70
                               int tag, size_t *nbytes);
 
71
 
67
72
 
68
73
/* Locate a TLV encoded data object in BUFFER of LENGTH and return a
69
74
   pointer to value as well as its length in NBYTES.  Return NULL if
70
75
   it was not found.  Note, that the function does not check whether
71
76
   the value fits into the provided buffer.*/
72
 
const unsigned char *find_tlv (const unsigned char *buffer, size_t length,
73
 
                               int tag, size_t *nbytes);
 
77
const unsigned char *find_tlv_unchecked (const unsigned char *buffer,
 
78
                                         size_t length,
 
79
                                         int tag, size_t *nbytes);
74
80
 
75
81
 
76
82
/* ASN.1 BER parser: Parse BUFFER of length SIZE and return the tag
83
89
 
84
90
 
85
91
 
 
92
/* Return the next token of an canconical encoded S-expression.  BUF
 
93
   is the pointer to the S-expression and BUFLEN is a pointer to the
 
94
   length of this S-expression (used to validate the syntax).  Both
 
95
   are updated to reflect the new position.  The token itself is
 
96
   returned as a pointer into the orginal buffer at TOK and TOKLEN.
 
97
   If a parentheses is the next token, TOK will be set to NULL.
 
98
   TOKLEN is checked to be within the bounds.  On error a error code
 
99
   is returned and all pointers should are not guaranteed to point to
 
100
   a meanigful value. DEPTH should be initialized to 0 and will
 
101
   reflect on return the actual depth of the tree. To detect the end
 
102
   of the S-expression it is advisable to check DEPTH after a
 
103
   successful return. */
 
104
gpg_error_t parse_sexp (unsigned char const **buf, size_t *buflen,
 
105
                        int *depth, unsigned char const **tok, size_t *toklen);
 
106
 
 
107
 
 
108
 
86
109
#endif /* SCD_TLV_H */