17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * src/lib/krb5/asn.1/asn1_make.h 3*1da57d55SToomas Soome * 47c478bd9Sstevel@tonic-gate * Copyright 1994 by the Massachusetts Institute of Technology. 57c478bd9Sstevel@tonic-gate * All Rights Reserved. 67c478bd9Sstevel@tonic-gate * 77c478bd9Sstevel@tonic-gate * Export of this software from the United States of America may 87c478bd9Sstevel@tonic-gate * require a specific license from the United States Government. 97c478bd9Sstevel@tonic-gate * It is the responsibility of any person or organization contemplating 107c478bd9Sstevel@tonic-gate * export to obtain such a license before exporting. 11*1da57d55SToomas Soome * 127c478bd9Sstevel@tonic-gate * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 137c478bd9Sstevel@tonic-gate * distribute this software and its documentation for any purpose and 147c478bd9Sstevel@tonic-gate * without fee is hereby granted, provided that the above copyright 157c478bd9Sstevel@tonic-gate * notice appear in all copies and that both that copyright notice and 167c478bd9Sstevel@tonic-gate * this permission notice appear in supporting documentation, and that 177c478bd9Sstevel@tonic-gate * the name of M.I.T. not be used in advertising or publicity pertaining 187c478bd9Sstevel@tonic-gate * to distribution of the software without specific, written prior 197c478bd9Sstevel@tonic-gate * permission. Furthermore if you modify this software you must label 207c478bd9Sstevel@tonic-gate * your software as modified software and not distribute it in such a 217c478bd9Sstevel@tonic-gate * fashion that it might be confused with the original M.I.T. software. 227c478bd9Sstevel@tonic-gate * M.I.T. makes no representations about the suitability of 237c478bd9Sstevel@tonic-gate * this software for any purpose. It is provided "as is" without express 247c478bd9Sstevel@tonic-gate * or implied warranty. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef __ASN1_MAKE_H__ 287c478bd9Sstevel@tonic-gate #define __ASN1_MAKE_H__ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include "k5-int.h" 317c478bd9Sstevel@tonic-gate #include "krbasn1.h" 327c478bd9Sstevel@tonic-gate #include "asn1buf.h" 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate /* 357c478bd9Sstevel@tonic-gate Overview 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate Each of these procedures constructs a subpart of an ASN.1 387c478bd9Sstevel@tonic-gate primitive in a coding buffer. 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate Operations 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate asn1_make_etag 437c478bd9Sstevel@tonic-gate asn1_make_sequence 447c478bd9Sstevel@tonic-gate asn1_make_set 457c478bd9Sstevel@tonic-gate asn1_make_tag 467c478bd9Sstevel@tonic-gate asn1_make_string 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_etag 507c478bd9Sstevel@tonic-gate (asn1buf *buf, 517c478bd9Sstevel@tonic-gate const asn1_class asn1class, 527c478bd9Sstevel@tonic-gate const asn1_tagnum tagnum, 537c478bd9Sstevel@tonic-gate const unsigned int in_len, 547c478bd9Sstevel@tonic-gate unsigned int *retlen); 557c478bd9Sstevel@tonic-gate /* requires *buf is allocated, in_len is the length of an ASN.1 encoding 567c478bd9Sstevel@tonic-gate which has just been inserted in *buf 577c478bd9Sstevel@tonic-gate modifies *buf, *retlen 587c478bd9Sstevel@tonic-gate effects Inserts an explicit tag with class = asn1class, id# = tag 597c478bd9Sstevel@tonic-gate length = in_len into *buf. 607c478bd9Sstevel@tonic-gate Returns the length of this encoding in *retlen. 617c478bd9Sstevel@tonic-gate Returns ENOMEM if memory runs out. */ 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_tag 647c478bd9Sstevel@tonic-gate (asn1buf *buf, const asn1_class asn1class, 657c478bd9Sstevel@tonic-gate const asn1_construction construction, 667c478bd9Sstevel@tonic-gate const asn1_tagnum tagnum, 677c478bd9Sstevel@tonic-gate const unsigned int in_len, 687c478bd9Sstevel@tonic-gate unsigned int *retlen); 697c478bd9Sstevel@tonic-gate /* requires *buf is allocated, in_len is the length of an ASN.1 encoding 707c478bd9Sstevel@tonic-gate which has just been inserted in *buf 717c478bd9Sstevel@tonic-gate modifies *buf, *retlen 727c478bd9Sstevel@tonic-gate effects Inserts the encoding of a tag with class = asn1class, 737c478bd9Sstevel@tonic-gate primitive/constructed staus = construction, 747c478bd9Sstevel@tonic-gate id# = tag and length = in_len into *buf. 757c478bd9Sstevel@tonic-gate Returns the length of this encoding in *retlen. 767c478bd9Sstevel@tonic-gate Returns ENOMEM if memory runs out. 777c478bd9Sstevel@tonic-gate Returns ASN1_OVERFLOW if tagnum exceeds the limits of 787c478bd9Sstevel@tonic-gate the implementation. */ 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_sequence 817c478bd9Sstevel@tonic-gate (asn1buf *buf, const unsigned int seq_len, unsigned int *len); 827c478bd9Sstevel@tonic-gate /* requires *buf is allocated, seq_len is the length of a series of 837c478bd9Sstevel@tonic-gate sequence components which have just been inserted in *buf 847c478bd9Sstevel@tonic-gate modifies *buf, *retlen 857c478bd9Sstevel@tonic-gate effects Inserts the sequence header for a sequence of length seq_len 867c478bd9Sstevel@tonic-gate in *buf. Returns the length of this encoding in *retlen. 877c478bd9Sstevel@tonic-gate Returns ENOMEM if memory runs out. */ 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_set 90*1da57d55SToomas Soome (asn1buf *buf, const unsigned int set_len, 917c478bd9Sstevel@tonic-gate unsigned int *retlen); 927c478bd9Sstevel@tonic-gate /* requires *buf is allocated, seq_len is the length of a series of 937c478bd9Sstevel@tonic-gate sequence components which have just been inserted in *buf 947c478bd9Sstevel@tonic-gate modifies *buf, *retlen 957c478bd9Sstevel@tonic-gate effects Inserts the set header for a set of length set_len in *buf. 967c478bd9Sstevel@tonic-gate Returns the length of this encoding in *retlen. 977c478bd9Sstevel@tonic-gate Returns ENOMEM if memory runs out. */ 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_string 1007c478bd9Sstevel@tonic-gate (asn1buf *buf, 1017c478bd9Sstevel@tonic-gate const unsigned int len, const char *string, 1027c478bd9Sstevel@tonic-gate int *retlen); 1037c478bd9Sstevel@tonic-gate /* requires *buf is allocated, len is the length of *string 1047c478bd9Sstevel@tonic-gate effects Inserts the encoding of *string (a series of octets) in *buf. 1057c478bd9Sstevel@tonic-gate Returns the length of this encoding in *retlen. 1067c478bd9Sstevel@tonic-gate Returns ENOMEM if memory runs out. */ 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate /****************************************************************/ 1107c478bd9Sstevel@tonic-gate /* Private procedures */ 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate /* "helper" procedure for asn1_make_tag */ 1137c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_length 114*1da57d55SToomas Soome (asn1buf *buf, const unsigned int in_len, 1157c478bd9Sstevel@tonic-gate unsigned int *retlen); 1167c478bd9Sstevel@tonic-gate /* requires *buf is allocated, in_len is the length of an ASN.1 encoding 1177c478bd9Sstevel@tonic-gate which has just been inserted in *buf 1187c478bd9Sstevel@tonic-gate modifies *buf, *retlen 1197c478bd9Sstevel@tonic-gate effects inserts length octet(s) for in_len into *buf */ 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate /* "helper" procedure for asn1_make_tag */ 1227c478bd9Sstevel@tonic-gate asn1_error_code asn1_make_id 1237c478bd9Sstevel@tonic-gate (asn1buf *buf, 1247c478bd9Sstevel@tonic-gate const asn1_class asn1class, 1257c478bd9Sstevel@tonic-gate const asn1_construction construction, 1267c478bd9Sstevel@tonic-gate const asn1_tagnum tagnum, 1277c478bd9Sstevel@tonic-gate unsigned int *retlen); 1287c478bd9Sstevel@tonic-gate /* requires *buf is allocated, asn1class and tagnum are appropriate for 1297c478bd9Sstevel@tonic-gate the ASN.1 encoding which has just been inserted in *buf 1307c478bd9Sstevel@tonic-gate modifies *buf, *retlen 1317c478bd9Sstevel@tonic-gate effects Inserts id octet(s) of class asn1class and tag number tagnum 1327c478bd9Sstevel@tonic-gate into *buf */ 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate #endif 135