xref: /titanic_41/usr/src/lib/gss_mechs/mech_krb5/krb5/asn.1/asn1_decode.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 #pragma ident	"%Z%%M%	%I%	%E% SMI"
2 
3 /*
4  * src/lib/krb5/asn.1/asn1_decode.h
5  *
6  * Copyright 1994 by the Massachusetts Institute of Technology.
7  * All Rights Reserved.
8  *
9  * Export of this software from the United States of America may
10  *   require a specific license from the United States Government.
11  *   It is the responsibility of any person or organization contemplating
12  *   export to obtain such a license before exporting.
13  *
14  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
15  * distribute this software and its documentation for any purpose and
16  * without fee is hereby granted, provided that the above copyright
17  * notice appear in all copies and that both that copyright notice and
18  * this permission notice appear in supporting documentation, and that
19  * the name of M.I.T. not be used in advertising or publicity pertaining
20  * to distribution of the software without specific, written prior
21  * permission.  Furthermore if you modify this software you must label
22  * your software as modified software and not distribute it in such a
23  * fashion that it might be confused with the original M.I.T. software.
24  * M.I.T. makes no representations about the suitability of
25  * this software for any purpose.  It is provided "as is" without express
26  * or implied warranty.
27  */
28 
29 #ifndef __ASN1_DECODE_H__
30 #define __ASN1_DECODE_H__
31 
32 #include "k5-int.h"
33 #include "krbasn1.h"
34 #include "asn1buf.h"
35 
36 /*
37    Overview
38 
39      These procedures take an asn1buf whose current position points
40      to the beginning of an ASN.1 primitive (<id><length><contents>).
41      The primitive is removed from the buffer and decoded.
42 
43    Operations
44 
45     asn1_decode_integer
46     asn1_decode_unsigned_integer
47     asn1_decode_octetstring
48     asn1_decode_charstring
49     asn1_decode_generalstring
50     asn1_decode_null
51     asn1_decode_printablestring
52     asn1_decode_ia5string
53     asn1_decode_generaltime
54 */
55 
56 /* asn1_error_code asn1_decode_type(asn1buf *buf, ctype *val); */
57 /* requires  *buf is allocated
58    modifies  *buf, *len
59    effects   Decodes the octet string in *buf into *val.
60              Returns ENOMEM if memory is exhausted.
61 	     Returns asn1 errors. */
62 
63 asn1_error_code asn1_decode_integer
64 	(asn1buf *buf, long *val);
65 asn1_error_code asn1_decode_unsigned_integer
66 	(asn1buf *buf, unsigned long *val);
67 asn1_error_code asn1_decode_maybe_unsigned
68 	(asn1buf *buf, unsigned long *val);
69 asn1_error_code asn1_decode_null
70 	(asn1buf *buf);
71 
72 asn1_error_code asn1_decode_oid
73 	(asn1buf *buf, unsigned int *retlen, asn1_octet **val);
74 asn1_error_code asn1_decode_octetstring
75 	(asn1buf *buf, unsigned int *retlen, asn1_octet **val);
76 asn1_error_code asn1_decode_generalstring
77 	(asn1buf *buf, unsigned int *retlen, char **val);
78 asn1_error_code asn1_decode_charstring
79 	(asn1buf *buf, unsigned int *retlen, char **val);
80 /* Note: A charstring is a special hack to account for the fact that
81          krb5 structures store some OCTET STRING values in krb5_octet
82 	 arrays and others in krb5_data structures
83 	 (which use char arrays).
84 	 From the ASN.1 point of view, the two string types are the same,
85 	 only the receptacles differ. */
86 asn1_error_code asn1_decode_printablestring
87 	(asn1buf *buf, int *retlen, char **val);
88 asn1_error_code asn1_decode_ia5string
89 	(asn1buf *buf, int *retlen, char **val);
90 
91 asn1_error_code asn1_decode_generaltime
92 	(asn1buf *buf, time_t *val);
93 
94 #endif
95