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