~ubuntu-branches/ubuntu/precise/gnupg2/precise-proposed

« back to all changes in this revision

Viewing changes to scd/tlv.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Mueller
  • Date: 2005-03-29 10:30:32 UTC
  • Revision ID: james.westby@ubuntu.com-20050329103032-sj42n2ain3ipx310
Tags: upstream-1.9.15
ImportĀ upstreamĀ versionĀ 1.9.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* tlv.h - Tag-Length-Value Utilities
 
2
 *      Copyright (C) 2004 Free Software Foundation, Inc.
 
3
 *
 
4
 * This file is part of GnuPG.
 
5
 *
 
6
 * GnuPG is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * GnuPG is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
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
 
19
 */
 
20
 
 
21
#ifndef SCD_TLV_H
 
22
#define SCD_TLV_H 1
 
23
 
 
24
 
 
25
enum tlv_tag_class {
 
26
  CLASS_UNIVERSAL = 0,
 
27
  CLASS_APPLICATION = 1,
 
28
  CLASS_CONTEXT = 2,
 
29
  CLASS_PRIVATE =3
 
30
};
 
31
 
 
32
enum tlv_tag_type {
 
33
  TAG_NONE = 0,
 
34
  TAG_BOOLEAN = 1,
 
35
  TAG_INTEGER = 2,
 
36
  TAG_BIT_STRING = 3,
 
37
  TAG_OCTET_STRING = 4,
 
38
  TAG_NULL = 5,
 
39
  TAG_OBJECT_ID = 6,
 
40
  TAG_OBJECT_DESCRIPTOR = 7,
 
41
  TAG_EXTERNAL = 8,
 
42
  TAG_REAL = 9,
 
43
  TAG_ENUMERATED = 10,
 
44
  TAG_EMBEDDED_PDV = 11,
 
45
  TAG_UTF8_STRING = 12,
 
46
  TAG_REALTIVE_OID = 13,
 
47
  TAG_SEQUENCE = 16,
 
48
  TAG_SET = 17,
 
49
  TAG_NUMERIC_STRING = 18,
 
50
  TAG_PRINTABLE_STRING = 19,
 
51
  TAG_TELETEX_STRING = 20,
 
52
  TAG_VIDEOTEX_STRING = 21,
 
53
  TAG_IA5_STRING = 22,
 
54
  TAG_UTC_TIME = 23,
 
55
  TAG_GENERALIZED_TIME = 24,
 
56
  TAG_GRAPHIC_STRING = 25,
 
57
  TAG_VISIBLE_STRING = 26,
 
58
  TAG_GENERAL_STRING = 27,
 
59
  TAG_UNIVERSAL_STRING = 28,
 
60
  TAG_CHARACTER_STRING = 29,
 
61
  TAG_BMP_STRING = 30
 
62
};
 
63
 
 
64
 
 
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.  Note, that the function does not check whether
 
69
   the value fits into the provided buffer.*/
 
70
const unsigned char *find_tlv (const unsigned char *buffer, size_t length,
 
71
                               int tag, size_t *nbytes);
 
72
 
 
73
 
 
74
/* ASN.1 BER parser: Parse BUFFER of length SIZE and return the tag
 
75
   and the length part from the TLV triplet.  Update BUFFER and SIZE
 
76
   on success. */
 
77
gpg_error_t parse_ber_header (unsigned char const **buffer, size_t *size,
 
78
                              int *r_class, int *r_tag, 
 
79
                              int *r_constructed,
 
80
                              int *r_ndef, size_t *r_length, size_t *r_nhdr);
 
81
 
 
82
 
 
83
 
 
84
#endif /* SCD_TLV_H */