2 * src/lib/krb5/asn.1/asn1_encode.h
4 * Copyright 1994 by the Massachusetts Institute of Technology.
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.
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.
24 #ifndef __ASN1_ENCODE_H__
25 #define __ASN1_ENCODE_H__
27 #include <krb5/krb5.h>
35 Each of these procedures inserts the encoding of an ASN.1
36 primitive in a coding buffer.
41 asn1_encode_octetstring
43 asn1_encode_printablestring
45 asn1_encode_generaltime
46 asn1_encode_generalstring
49 asn1_error_code 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. */
58 asn1_error_code 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. */
67 asn1_error_code asn1_encode_octetstring
68 PROTOTYPE((asn1buf *buf,
69 const int len, const asn1_octet *val,
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. */
78 asn1_error_code asn1_encode_charstring
79 PROTOTYPE((asn1buf *buf,
80 const int len, const char *val,
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. */
89 asn1_error_code 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. */
98 asn1_error_code asn1_encode_printablestring
99 PROTOTYPE((asn1buf *buf,
100 const int len, const char *val,
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. */
109 asn1_error_code asn1_encode_ia5string
110 PROTOTYPE((asn1buf *buf,
111 const int len, const char *val,
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. */
120 asn1_error_code 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 */
130 asn1_error_code asn1_encode_generalstring
131 PROTOTYPE((asn1buf *buf,
132 const int len, const char *val,
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. */