1*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 2*7c478bd9Sstevel@tonic-gate 3*7c478bd9Sstevel@tonic-gate /* 4*7c478bd9Sstevel@tonic-gate * src/lib/krb5/asn.1/asn1_make.h 5*7c478bd9Sstevel@tonic-gate * 6*7c478bd9Sstevel@tonic-gate * Copyright 1994 by the Massachusetts Institute of Technology. 7*7c478bd9Sstevel@tonic-gate * All Rights Reserved. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * Export of this software from the United States of America may 10*7c478bd9Sstevel@tonic-gate * require a specific license from the United States Government. 11*7c478bd9Sstevel@tonic-gate * It is the responsibility of any person or organization contemplating 12*7c478bd9Sstevel@tonic-gate * export to obtain such a license before exporting. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 15*7c478bd9Sstevel@tonic-gate * distribute this software and its documentation for any purpose and 16*7c478bd9Sstevel@tonic-gate * without fee is hereby granted, provided that the above copyright 17*7c478bd9Sstevel@tonic-gate * notice appear in all copies and that both that copyright notice and 18*7c478bd9Sstevel@tonic-gate * this permission notice appear in supporting documentation, and that 19*7c478bd9Sstevel@tonic-gate * the name of M.I.T. not be used in advertising or publicity pertaining 20*7c478bd9Sstevel@tonic-gate * to distribution of the software without specific, written prior 21*7c478bd9Sstevel@tonic-gate * permission. Furthermore if you modify this software you must label 22*7c478bd9Sstevel@tonic-gate * your software as modified software and not distribute it in such a 23*7c478bd9Sstevel@tonic-gate * fashion that it might be confused with the original M.I.T. software. 24*7c478bd9Sstevel@tonic-gate * M.I.T. makes no representations about the suitability of 25*7c478bd9Sstevel@tonic-gate * this software for any purpose. It is provided "as is" without express 26*7c478bd9Sstevel@tonic-gate * or implied warranty. 27*7c478bd9Sstevel@tonic-gate */ 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #ifndef __ASN1_MAKE_H__ 30*7c478bd9Sstevel@tonic-gate #define __ASN1_MAKE_H__ 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include "k5-int.h" 33*7c478bd9Sstevel@tonic-gate #include "krbasn1.h" 34*7c478bd9Sstevel@tonic-gate #include "asn1buf.h" 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate /* 37*7c478bd9Sstevel@tonic-gate Overview 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate Each of these procedures constructs a subpart of an ASN.1 40*7c478bd9Sstevel@tonic-gate primitive in a coding buffer. 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate Operations 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate asn1_make_etag 45*7c478bd9Sstevel@tonic-gate asn1_make_sequence 46*7c478bd9Sstevel@tonic-gate asn1_make_set 47*7c478bd9Sstevel@tonic-gate asn1_make_tag 48*7c478bd9Sstevel@tonic-gate asn1_make_string 49*7c478bd9Sstevel@tonic-gate */ 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_etag 52*7c478bd9Sstevel@tonic-gate (asn1buf *buf, 53*7c478bd9Sstevel@tonic-gate const asn1_class asn1class, 54*7c478bd9Sstevel@tonic-gate const asn1_tagnum tagnum, 55*7c478bd9Sstevel@tonic-gate const unsigned int in_len, 56*7c478bd9Sstevel@tonic-gate unsigned int *retlen); 57*7c478bd9Sstevel@tonic-gate /* requires *buf is allocated, in_len is the length of an ASN.1 encoding 58*7c478bd9Sstevel@tonic-gate which has just been inserted in *buf 59*7c478bd9Sstevel@tonic-gate modifies *buf, *retlen 60*7c478bd9Sstevel@tonic-gate effects Inserts an explicit tag with class = asn1class, id# = tag 61*7c478bd9Sstevel@tonic-gate length = in_len into *buf. 62*7c478bd9Sstevel@tonic-gate Returns the length of this encoding in *retlen. 63*7c478bd9Sstevel@tonic-gate Returns ENOMEM if memory runs out. */ 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_tag 66*7c478bd9Sstevel@tonic-gate (asn1buf *buf, const asn1_class asn1class, 67*7c478bd9Sstevel@tonic-gate const asn1_construction construction, 68*7c478bd9Sstevel@tonic-gate const asn1_tagnum tagnum, 69*7c478bd9Sstevel@tonic-gate const unsigned int in_len, 70*7c478bd9Sstevel@tonic-gate unsigned int *retlen); 71*7c478bd9Sstevel@tonic-gate /* requires *buf is allocated, in_len is the length of an ASN.1 encoding 72*7c478bd9Sstevel@tonic-gate which has just been inserted in *buf 73*7c478bd9Sstevel@tonic-gate modifies *buf, *retlen 74*7c478bd9Sstevel@tonic-gate effects Inserts the encoding of a tag with class = asn1class, 75*7c478bd9Sstevel@tonic-gate primitive/constructed staus = construction, 76*7c478bd9Sstevel@tonic-gate id# = tag and length = in_len into *buf. 77*7c478bd9Sstevel@tonic-gate Returns the length of this encoding in *retlen. 78*7c478bd9Sstevel@tonic-gate Returns ENOMEM if memory runs out. 79*7c478bd9Sstevel@tonic-gate Returns ASN1_OVERFLOW if tagnum exceeds the limits of 80*7c478bd9Sstevel@tonic-gate the implementation. */ 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_sequence 83*7c478bd9Sstevel@tonic-gate (asn1buf *buf, const unsigned int seq_len, unsigned int *len); 84*7c478bd9Sstevel@tonic-gate /* requires *buf is allocated, seq_len is the length of a series of 85*7c478bd9Sstevel@tonic-gate sequence components which have just been inserted in *buf 86*7c478bd9Sstevel@tonic-gate modifies *buf, *retlen 87*7c478bd9Sstevel@tonic-gate effects Inserts the sequence header for a sequence of length seq_len 88*7c478bd9Sstevel@tonic-gate in *buf. Returns the length of this encoding in *retlen. 89*7c478bd9Sstevel@tonic-gate Returns ENOMEM if memory runs out. */ 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_set 92*7c478bd9Sstevel@tonic-gate (asn1buf *buf, const unsigned int set_len, 93*7c478bd9Sstevel@tonic-gate unsigned int *retlen); 94*7c478bd9Sstevel@tonic-gate /* requires *buf is allocated, seq_len is the length of a series of 95*7c478bd9Sstevel@tonic-gate sequence components which have just been inserted in *buf 96*7c478bd9Sstevel@tonic-gate modifies *buf, *retlen 97*7c478bd9Sstevel@tonic-gate effects Inserts the set header for a set of length set_len in *buf. 98*7c478bd9Sstevel@tonic-gate Returns the length of this encoding in *retlen. 99*7c478bd9Sstevel@tonic-gate Returns ENOMEM if memory runs out. */ 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_string 102*7c478bd9Sstevel@tonic-gate (asn1buf *buf, 103*7c478bd9Sstevel@tonic-gate const unsigned int len, const char *string, 104*7c478bd9Sstevel@tonic-gate int *retlen); 105*7c478bd9Sstevel@tonic-gate /* requires *buf is allocated, len is the length of *string 106*7c478bd9Sstevel@tonic-gate effects Inserts the encoding of *string (a series of octets) in *buf. 107*7c478bd9Sstevel@tonic-gate Returns the length of this encoding in *retlen. 108*7c478bd9Sstevel@tonic-gate Returns ENOMEM if memory runs out. */ 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate /****************************************************************/ 112*7c478bd9Sstevel@tonic-gate /* Private procedures */ 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate /* "helper" procedure for asn1_make_tag */ 115*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_length 116*7c478bd9Sstevel@tonic-gate (asn1buf *buf, const unsigned int in_len, 117*7c478bd9Sstevel@tonic-gate unsigned int *retlen); 118*7c478bd9Sstevel@tonic-gate /* requires *buf is allocated, in_len is the length of an ASN.1 encoding 119*7c478bd9Sstevel@tonic-gate which has just been inserted in *buf 120*7c478bd9Sstevel@tonic-gate modifies *buf, *retlen 121*7c478bd9Sstevel@tonic-gate effects inserts length octet(s) for in_len into *buf */ 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate /* "helper" procedure for asn1_make_tag */ 124*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_id 125*7c478bd9Sstevel@tonic-gate (asn1buf *buf, 126*7c478bd9Sstevel@tonic-gate const asn1_class asn1class, 127*7c478bd9Sstevel@tonic-gate const asn1_construction construction, 128*7c478bd9Sstevel@tonic-gate const asn1_tagnum tagnum, 129*7c478bd9Sstevel@tonic-gate unsigned int *retlen); 130*7c478bd9Sstevel@tonic-gate /* requires *buf is allocated, asn1class and tagnum are appropriate for 131*7c478bd9Sstevel@tonic-gate the ASN.1 encoding which has just been inserted in *buf 132*7c478bd9Sstevel@tonic-gate modifies *buf, *retlen 133*7c478bd9Sstevel@tonic-gate effects Inserts id octet(s) of class asn1class and tag number tagnum 134*7c478bd9Sstevel@tonic-gate into *buf */ 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate #endif 137