1 #pragma ident "%Z%%M% %I% %E% SMI" 2 3 /* 4 * src/lib/krb5/asn.1/asn1_make.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_MAKE_H__ 30 #define __ASN1_MAKE_H__ 31 32 #include "k5-int.h" 33 #include "krbasn1.h" 34 #include "asn1buf.h" 35 36 /* 37 Overview 38 39 Each of these procedures constructs a subpart of an ASN.1 40 primitive in a coding buffer. 41 42 Operations 43 44 asn1_make_etag 45 asn1_make_sequence 46 asn1_make_set 47 asn1_make_tag 48 asn1_make_string 49 */ 50 51 asn1_error_code asn1_make_etag 52 (asn1buf *buf, 53 const asn1_class asn1class, 54 const asn1_tagnum tagnum, 55 const unsigned int in_len, 56 unsigned int *retlen); 57 /* requires *buf is allocated, in_len is the length of an ASN.1 encoding 58 which has just been inserted in *buf 59 modifies *buf, *retlen 60 effects Inserts an explicit tag with class = asn1class, id# = tag 61 length = in_len into *buf. 62 Returns the length of this encoding in *retlen. 63 Returns ENOMEM if memory runs out. */ 64 65 asn1_error_code asn1_make_tag 66 (asn1buf *buf, const asn1_class asn1class, 67 const asn1_construction construction, 68 const asn1_tagnum tagnum, 69 const unsigned int in_len, 70 unsigned int *retlen); 71 /* requires *buf is allocated, in_len is the length of an ASN.1 encoding 72 which has just been inserted in *buf 73 modifies *buf, *retlen 74 effects Inserts the encoding of a tag with class = asn1class, 75 primitive/constructed staus = construction, 76 id# = tag and length = in_len into *buf. 77 Returns the length of this encoding in *retlen. 78 Returns ENOMEM if memory runs out. 79 Returns ASN1_OVERFLOW if tagnum exceeds the limits of 80 the implementation. */ 81 82 asn1_error_code asn1_make_sequence 83 (asn1buf *buf, const unsigned int seq_len, unsigned int *len); 84 /* requires *buf is allocated, seq_len is the length of a series of 85 sequence components which have just been inserted in *buf 86 modifies *buf, *retlen 87 effects Inserts the sequence header for a sequence of length seq_len 88 in *buf. Returns the length of this encoding in *retlen. 89 Returns ENOMEM if memory runs out. */ 90 91 asn1_error_code asn1_make_set 92 (asn1buf *buf, const unsigned int set_len, 93 unsigned int *retlen); 94 /* requires *buf is allocated, seq_len is the length of a series of 95 sequence components which have just been inserted in *buf 96 modifies *buf, *retlen 97 effects Inserts the set header for a set of length set_len in *buf. 98 Returns the length of this encoding in *retlen. 99 Returns ENOMEM if memory runs out. */ 100 101 asn1_error_code asn1_make_string 102 (asn1buf *buf, 103 const unsigned int len, const char *string, 104 int *retlen); 105 /* requires *buf is allocated, len is the length of *string 106 effects Inserts the encoding of *string (a series of octets) in *buf. 107 Returns the length of this encoding in *retlen. 108 Returns ENOMEM if memory runs out. */ 109 110 111 /****************************************************************/ 112 /* Private procedures */ 113 114 /* "helper" procedure for asn1_make_tag */ 115 asn1_error_code asn1_make_length 116 (asn1buf *buf, const unsigned int in_len, 117 unsigned int *retlen); 118 /* requires *buf is allocated, in_len is the length of an ASN.1 encoding 119 which has just been inserted in *buf 120 modifies *buf, *retlen 121 effects inserts length octet(s) for in_len into *buf */ 122 123 /* "helper" procedure for asn1_make_tag */ 124 asn1_error_code asn1_make_id 125 (asn1buf *buf, 126 const asn1_class asn1class, 127 const asn1_construction construction, 128 const asn1_tagnum tagnum, 129 unsigned int *retlen); 130 /* requires *buf is allocated, asn1class and tagnum are appropriate for 131 the ASN.1 encoding which has just been inserted in *buf 132 modifies *buf, *retlen 133 effects Inserts id octet(s) of class asn1class and tag number tagnum 134 into *buf */ 135 136 #endif 137