6fcf891a893aa20c2536dbed89919220a2e445bc
[krb5.git] / src / lib / krb5 / asn.1 / asn1_make.h
1 /*
2  * src/lib/krb5/asn.1/asn1_make.h
3  * 
4  * Copyright 1994 by the Massachusetts Institute of Technology.
5  * All Rights Reserved.
6  *
7  * Export of this software from the United States of America may
8  *   require a specific license from the United States Government.
9  *   It is the responsibility of any person or organization contemplating
10  *   export to obtain such a license before exporting.
11  * 
12  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13  * distribute this software and its documentation for any purpose and
14  * without fee is hereby granted, provided that the above copyright
15  * notice appear in all copies and that both that copyright notice and
16  * this permission notice appear in supporting documentation, and that
17  * the name of M.I.T. not be used in advertising or publicity pertaining
18  * to distribution of the software without specific, written prior
19  * permission.  M.I.T. makes no representations about the suitability of
20  * this software for any purpose.  It is provided "as is" without express
21  * or implied warranty.
22  */
23
24 #ifndef __ASN1_MAKE_H__
25 #define __ASN1_MAKE_H__
26
27 #include "k5-int.h"
28 #include "krbasn1.h"
29 #include "asn1buf.h"
30
31 /*
32    Overview
33
34      Each of these procedures constructs a subpart of an ASN.1
35      primitive in a coding buffer.
36
37     Operations
38
39       asn1_make_etag
40       asn1_make_sequence
41       asn1_make_set
42       asn1_make_tag
43       asn1_make_string
44 */
45
46 asn1_error_code INTERFACE asn1_make_etag
47         PROTOTYPE((asn1buf *buf,
48                    const asn1_class class,
49                    const asn1_tagnum tagnum,
50                    const int in_len,
51                    int *retlen));
52 /* requires  *buf is allocated, in_len is the length of an ASN.1 encoding
53              which has just been inserted in *buf
54    modifies  *buf, *retlen
55    effects   Inserts an explicit tag with class = class, id# = tag
56               length = in_len into *buf.
57              Returns the length of this encoding in *retlen.
58              Returns ENOMEM if memory runs out. */
59
60 asn1_error_code INTERFACE asn1_make_tag
61         PROTOTYPE((asn1buf *buf, const asn1_class class,
62                    const asn1_construction construction,
63                    const asn1_tagnum tagnum,
64                    const int in_len,
65                    int *retlen));
66 /* requires  *buf is allocated, in_len is the length of an ASN.1 encoding
67              which has just been inserted in *buf
68    modifies  *buf, *retlen
69    effects   Inserts the encoding of a tag with class = class,
70               primitive/constructed staus = construction,
71               id# = tag and length = in_len into *buf.
72              Returns the length of this encoding in *retlen.
73              Returns ENOMEM if memory runs out.
74              Returns ASN1_OVERFLOW if tagnum exceeds the limits of
75               the implementation. */
76
77 asn1_error_code INTERFACE asn1_make_sequence
78         PROTOTYPE((asn1buf *buf, const int seq_len, int *len));
79 /* requires  *buf is allocated, seq_len is the length of a series of
80              sequence components which have just been inserted in *buf
81    modifies  *buf, *retlen
82    effects   Inserts the sequence header for a sequence of length seq_len
83               in *buf.  Returns the length of this encoding in *retlen.
84              Returns ENOMEM if memory runs out. */
85
86 asn1_error_code INTERFACE asn1_make_set
87         PROTOTYPE((asn1buf *buf, const int set_len, int *retlen));
88 /* requires  *buf is allocated, seq_len is the length of a series of
89              sequence components which have just been inserted in *buf
90    modifies  *buf, *retlen
91    effects   Inserts the set header for a set of length set_len in *buf.
92              Returns the length of this encoding in *retlen.
93              Returns ENOMEM if memory runs out. */
94
95 asn1_error_code INTERFACE asn1_make_string
96         PROTOTYPE((asn1buf *buf,
97                    const int len, const char *string,
98                    int *retlen));
99 /* requires  *buf is allocated, len is the length of *string
100    effects   Inserts the encoding of *string 
101         PROTOTYPE((a series of octets) in *buf.
102              Returns the length of this encoding in *retlen.
103              Returns ENOMEM if memory runs out. */
104
105
106 /****************************************************************/
107 /* Private procedures */
108
109 /* "helper" procedure for asn1_make_tag */
110 asn1_error_code INTERFACE asn1_make_length
111         PROTOTYPE((asn1buf *buf, const int in_len, int *retlen));
112 /* requires  *buf is allocated, in_len is the length of an ASN.1 encoding
113              which has just been inserted in *buf
114    modifies  *buf, *retlen
115    effects   inserts length octet
116         PROTOTYPE((s) for in_len into *buf */
117
118 /* "helper" procedure for asn1_make_tag */
119 asn1_error_code INTERFACE asn1_make_id
120         PROTOTYPE((asn1buf *buf,
121                    const asn1_class class,
122                    const asn1_construction construction,
123                    const asn1_tagnum tagnum,
124                    int *retlen));
125 /* requires  *buf is allocated, class and tagnum are appropriate for
126              the ASN.1 encoding which has just been inserted in *buf
127    modifies  *buf, *retlen
128    effects   Inserts id octet
129         PROTOTYPE((s) of class class and tag number tagnum
130              into *buf */
131
132 #endif