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. Furthermore if you modify this software you must label 20 * your software as modified software and not distribute it in such a 21 * fashion that it might be confused with the original M.I.T. software. 22 * M.I.T. makes no representations about the suitability of 23 * this software for any purpose. It is provided "as is" without express 24 * or implied warranty. 25 */ 26 27 #ifndef __ASN1_MAKE_H__ 28 #define __ASN1_MAKE_H__ 29 30 #include "k5-int.h" 31 #include "krbasn1.h" 32 #include "asn1buf.h" 33 34 /* 35 Overview 36 37 Each of these procedures constructs a subpart of an ASN.1 38 primitive in a coding buffer. 39 40 Operations 41 42 asn1_make_etag 43 asn1_make_sequence 44 asn1_make_set 45 asn1_make_tag 46 asn1_make_string 47 */ 48 49 asn1_error_code asn1_make_etag 50 (asn1buf *buf, 51 const asn1_class asn1class, 52 const asn1_tagnum tagnum, 53 const unsigned int in_len, 54 unsigned int *retlen); 55 /* requires *buf is allocated, in_len is the length of an ASN.1 encoding 56 which has just been inserted in *buf 57 modifies *buf, *retlen 58 effects Inserts an explicit tag with class = asn1class, id# = tag 59 length = in_len into *buf. 60 Returns the length of this encoding in *retlen. 61 Returns ENOMEM if memory runs out. */ 62 63 asn1_error_code asn1_make_tag 64 (asn1buf *buf, const asn1_class asn1class, 65 const asn1_construction construction, 66 const asn1_tagnum tagnum, 67 const unsigned int in_len, 68 unsigned int *retlen); 69 /* requires *buf is allocated, in_len is the length of an ASN.1 encoding 70 which has just been inserted in *buf 71 modifies *buf, *retlen 72 effects Inserts the encoding of a tag with class = asn1class, 73 primitive/constructed staus = construction, 74 id# = tag and length = in_len into *buf. 75 Returns the length of this encoding in *retlen. 76 Returns ENOMEM if memory runs out. 77 Returns ASN1_OVERFLOW if tagnum exceeds the limits of 78 the implementation. */ 79 80 asn1_error_code asn1_make_sequence 81 (asn1buf *buf, const unsigned int seq_len, unsigned int *len); 82 /* requires *buf is allocated, seq_len is the length of a series of 83 sequence components which have just been inserted in *buf 84 modifies *buf, *retlen 85 effects Inserts the sequence header for a sequence of length seq_len 86 in *buf. Returns the length of this encoding in *retlen. 87 Returns ENOMEM if memory runs out. */ 88 89 asn1_error_code asn1_make_set 90 (asn1buf *buf, const unsigned int set_len, 91 unsigned int *retlen); 92 /* requires *buf is allocated, seq_len is the length of a series of 93 sequence components which have just been inserted in *buf 94 modifies *buf, *retlen 95 effects Inserts the set header for a set of length set_len in *buf. 96 Returns the length of this encoding in *retlen. 97 Returns ENOMEM if memory runs out. */ 98 99 asn1_error_code asn1_make_string 100 (asn1buf *buf, 101 const unsigned int len, const char *string, 102 int *retlen); 103 /* requires *buf is allocated, len is the length of *string 104 effects Inserts the encoding of *string (a series of octets) in *buf. 105 Returns the length of this encoding in *retlen. 106 Returns ENOMEM if memory runs out. */ 107 108 109 /****************************************************************/ 110 /* Private procedures */ 111 112 /* "helper" procedure for asn1_make_tag */ 113 asn1_error_code asn1_make_length 114 (asn1buf *buf, const unsigned int in_len, 115 unsigned int *retlen); 116 /* requires *buf is allocated, in_len is the length of an ASN.1 encoding 117 which has just been inserted in *buf 118 modifies *buf, *retlen 119 effects inserts length octet(s) for in_len into *buf */ 120 121 /* "helper" procedure for asn1_make_tag */ 122 asn1_error_code asn1_make_id 123 (asn1buf *buf, 124 const asn1_class asn1class, 125 const asn1_construction construction, 126 const asn1_tagnum tagnum, 127 unsigned int *retlen); 128 /* requires *buf is allocated, asn1class and tagnum are appropriate for 129 the ASN.1 encoding which has just been inserted in *buf 130 modifies *buf, *retlen 131 effects Inserts id octet(s) of class asn1class and tag number tagnum 132 into *buf */ 133 134 #endif 135