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