1 #pragma ident "%Z%%M% %I% %E% SMI" 2 3 /* 4 * src/lib/krb5/asn.1/asn1_encode.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_ENCODE_H__ 30 #define __ASN1_ENCODE_H__ 31 32 #include "k5-int.h" 33 #include "krbasn1.h" 34 #include "asn1buf.h" 35 #include <time.h> 36 37 /* 38 Overview 39 40 Each of these procedures inserts the encoding of an ASN.1 41 primitive in a coding buffer. 42 43 Operations 44 45 asn1_encode_integer 46 asn1_encode_octetstring 47 asn1_encode_null 48 asn1_encode_printablestring 49 asn1_encode_ia5string 50 asn1_encode_generaltime 51 asn1_encode_generalstring 52 */ 53 54 asn1_error_code asn1_encode_integer 55 (asn1buf *buf, const long val, unsigned int *retlen); 56 /* requires *buf is allocated 57 modifies *buf, *retlen 58 effects Inserts the encoding of val into *buf and returns 59 the length of the encoding in *retlen. 60 Returns ENOMEM to signal an unsuccesful attempt 61 to expand the buffer. */ 62 63 asn1_error_code asn1_encode_enumerated 64 (asn1buf *buf, const long val, unsigned int *retlen); 65 66 asn1_error_code asn1_encode_unsigned_integer 67 (asn1buf *buf, const unsigned long val, 68 unsigned int *retlen); 69 /* requires *buf is allocated 70 modifies *buf, *retlen 71 effects Inserts the encoding of val into *buf and returns 72 the length of the encoding in *retlen. 73 Returns ENOMEM to signal an unsuccesful attempt 74 to expand the buffer. */ 75 76 asn1_error_code asn1_encode_octetstring 77 (asn1buf *buf, 78 const unsigned int len, const asn1_octet *val, 79 unsigned int *retlen); 80 /* requires *buf is allocated 81 modifies *buf, *retlen 82 effects Inserts the encoding of val into *buf and returns 83 the length of the encoding in *retlen. 84 Returns ENOMEM to signal an unsuccesful attempt 85 to expand the buffer. */ 86 87 asn1_error_code asn1_encode_oid 88 (asn1buf *buf, 89 const unsigned int len, const asn1_octet *val, 90 unsigned int *retlen); 91 /* requires *buf is allocated 92 modifies *buf, *retlen 93 effects Inserts the encoding of val 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 asn1_encode_charstring 99 (asn1buf *buf, 100 const unsigned int len, const char *val, 101 unsigned 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 asn1_encode_null 110 (asn1buf *buf, int *retlen); 111 /* requires *buf is allocated 112 modifies *buf, *retlen 113 effects Inserts the encoding of NULL into *buf and returns 114 the length of the encoding in *retlen. 115 Returns ENOMEM to signal an unsuccesful attempt 116 to expand the buffer. */ 117 118 asn1_error_code asn1_encode_printablestring 119 (asn1buf *buf, 120 const unsigned int len, const char *val, 121 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 129 asn1_error_code asn1_encode_ia5string 130 (asn1buf *buf, 131 const unsigned int len, const char *val, 132 int *retlen); 133 /* requires *buf is allocated 134 modifies *buf, *retlen 135 effects Inserts the encoding of val into *buf and returns 136 the length of the encoding in *retlen. 137 Returns ENOMEM to signal an unsuccesful attempt 138 to expand the buffer. */ 139 140 asn1_error_code asn1_encode_generaltime 141 (asn1buf *buf, const time_t val, unsigned int *retlen); 142 /* requires *buf is allocated 143 modifies *buf, *retlen 144 effects Inserts the encoding of val into *buf and returns 145 the length of the encoding in *retlen. 146 Returns ENOMEM to signal an unsuccesful attempt 147 to expand the buffer. 148 Note: The encoding of GeneralizedTime is YYYYMMDDhhmmZ */ 149 150 asn1_error_code asn1_encode_generalstring 151 (asn1buf *buf, 152 const unsigned int len, const char *val, 153 unsigned int *retlen); 154 /* requires *buf is allocated, val has a length of len characters 155 modifies *buf, *retlen 156 effects Inserts the encoding of val into *buf and returns 157 the length of the encoding in *retlen. 158 Returns ENOMEM to signal an unsuccesful attempt 159 to expand the buffer. */ 160 161 #endif 162