f5d8036554c87f91e0d5e954c61d4c398dcb1da5
[krb5.git] / src / lib / krb5 / asn.1 / asn1_encode.h
1 /*
2  * src/lib/krb5/asn.1/asn1_encode.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_ENCODE_H__
25 #define __ASN1_ENCODE_H__
26
27 #include "k5-int.h"
28 #include <time.h>
29 #include "krbasn1.h"
30 #include "asn1buf.h"
31
32 /*
33    Overview
34
35      Each of these procedures inserts the encoding of an ASN.1
36      primitive in a coding buffer.
37
38    Operations
39
40      asn1_encode_integer
41      asn1_encode_octetstring
42      asn1_encode_null
43      asn1_encode_printablestring
44      asn1_encode_ia5string
45      asn1_encode_generaltime
46      asn1_encode_generalstring
47 */
48
49 asn1_error_code INTERFACE asn1_encode_integer
50         PROTOTYPE((asn1buf *buf, const long val, int *retlen));
51 /* requires  *buf is allocated
52    modifies  *buf, *retlen
53    effects   Inserts the encoding of val into *buf and returns 
54               the length of the encoding in *retlen.
55              Returns ENOMEM to signal an unsuccesful attempt
56               to expand the buffer. */
57
58 asn1_error_code INTERFACE asn1_encode_unsigned_integer
59         PROTOTYPE((asn1buf *buf, const unsigned long val, int *retlen));
60 /* requires  *buf is allocated
61    modifies  *buf, *retlen
62    effects   Inserts the encoding of val into *buf and returns 
63               the length of the encoding in *retlen.
64              Returns ENOMEM to signal an unsuccesful attempt
65               to expand the buffer. */
66
67 asn1_error_code INTERFACE asn1_encode_octetstring
68         PROTOTYPE((asn1buf *buf,
69                    const int len, const asn1_octet *val,
70                    int *retlen));
71 /* requires  *buf is allocated
72    modifies  *buf, *retlen
73    effects   Inserts the encoding of val into *buf and returns 
74               the length of the encoding in *retlen.
75              Returns ENOMEM to signal an unsuccesful attempt
76               to expand the buffer. */
77
78 asn1_error_code INTERFACE asn1_encode_charstring
79         PROTOTYPE((asn1buf *buf,
80                    const int len, const char *val,
81                    int *retlen));
82 /* requires  *buf is allocated
83    modifies  *buf, *retlen
84    effects   Inserts the encoding of val into *buf and returns 
85               the length of the encoding in *retlen.
86              Returns ENOMEM to signal an unsuccesful attempt
87               to expand the buffer. */
88
89 asn1_error_code INTERFACE asn1_encode_null
90         PROTOTYPE((asn1buf *buf, int *retlen));
91 /* requires  *buf is allocated
92    modifies  *buf, *retlen
93    effects   Inserts the encoding of NULL into *buf and returns 
94               the length of the encoding in *retlen.
95              Returns ENOMEM to signal an unsuccesful attempt
96               to expand the buffer. */
97
98 asn1_error_code INTERFACE asn1_encode_printablestring
99         PROTOTYPE((asn1buf *buf,
100                    const int len, const char *val,
101                    int *retlen));
102 /* requires  *buf is allocated
103    modifies  *buf, *retlen
104    effects   Inserts the encoding of val into *buf and returns 
105               the length of the encoding in *retlen.
106              Returns ENOMEM to signal an unsuccesful attempt
107               to expand the buffer. */
108
109 asn1_error_code INTERFACE asn1_encode_ia5string
110         PROTOTYPE((asn1buf *buf,
111                    const int len, const char *val,
112                    int *retlen));
113 /* requires  *buf is allocated
114    modifies  *buf, *retlen
115    effects   Inserts the encoding of val into *buf and returns 
116               the length of the encoding in *retlen.
117              Returns ENOMEM to signal an unsuccesful attempt
118               to expand the buffer. */
119
120 asn1_error_code INTERFACE asn1_encode_generaltime
121         PROTOTYPE((asn1buf *buf, const time_t val, int *retlen));
122 /* requires  *buf is allocated
123    modifies  *buf, *retlen
124    effects   Inserts the encoding of val into *buf and returns
125               the length of the encoding in *retlen.
126              Returns ENOMEM to signal an unsuccesful attempt
127               to expand the buffer.
128    Note: The encoding of GeneralizedTime is YYYYMMDDhhmmZ */
129
130 asn1_error_code INTERFACE asn1_encode_generalstring
131         PROTOTYPE((asn1buf *buf,
132                    const int len, const char *val,
133                    int *retlen));
134 /* requires  *buf is allocated,  val has a length of len characters
135    modifies  *buf, *retlen
136    effects   Inserts the encoding of val into *buf and returns 
137               the length of the encoding in *retlen.
138              Returns ENOMEM to signal an unsuccesful attempt
139               to expand the buffer. */
140
141 #endif