2N/A/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2N/A/*
2N/A * src/lib/krb5/asn.1/asn1_make.h
2N/A *
2N/A * Copyright 1994 by the Massachusetts Institute of Technology.
2N/A * All Rights Reserved.
2N/A *
2N/A * Export of this software from the United States of America may
2N/A * require a specific license from the United States Government.
2N/A * It is the responsibility of any person or organization contemplating
2N/A * export to obtain such a license before exporting.
2N/A *
2N/A * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
2N/A * distribute this software and its documentation for any purpose and
2N/A * without fee is hereby granted, provided that the above copyright
2N/A * notice appear in all copies and that both that copyright notice and
2N/A * this permission notice appear in supporting documentation, and that
2N/A * the name of M.I.T. not be used in advertising or publicity pertaining
2N/A * to distribution of the software without specific, written prior
2N/A * permission. Furthermore if you modify this software you must label
2N/A * your software as modified software and not distribute it in such a
2N/A * fashion that it might be confused with the original M.I.T. software.
2N/A * M.I.T. makes no representations about the suitability of
2N/A * this software for any purpose. It is provided "as is" without express
2N/A * or implied warranty.
2N/A */
2N/A
2N/A#ifndef __ASN1_MAKE_H__
2N/A#define __ASN1_MAKE_H__
2N/A
2N/A#include "k5-int.h"
2N/A#include "krbasn1.h"
2N/A#include "asn1buf.h"
2N/A
2N/A/*
2N/A * Overview
2N/A *
2N/A * Each of these procedures constructs a subpart of an ASN.1
2N/A * primitive in a coding buffer.
2N/A *
2N/A * Operations
2N/A *
2N/A * asn1_make_etag
2N/A * asn1_make_sequence
2N/A * asn1_make_set
2N/A * asn1_make_tag
2N/A * asn1_make_string
2N/A */
2N/A
2N/Aasn1_error_code asn1_make_etag(asn1buf *buf, asn1_class asn1class,
2N/A asn1_tagnum tagnum, unsigned int in_len,
2N/A unsigned int *retlen);
2N/A/*
2N/A * requires *buf is allocated, in_len is the length of an ASN.1 encoding
2N/A * which has just been inserted in *buf
2N/A * modifies *buf, *retlen
2N/A * effects Inserts an explicit tag with class = asn1class, id# = tag
2N/A * length = in_len into *buf.
2N/A * Returns the length of this encoding in *retlen.
2N/A * Returns ENOMEM if memory runs out.
2N/A */
2N/A
2N/Aasn1_error_code asn1_make_tag(asn1buf *buf, asn1_class asn1class,
2N/A asn1_construction construction,
2N/A asn1_tagnum tagnum, unsigned int in_len,
2N/A unsigned int *retlen);
2N/A/*
2N/A * requires *buf is allocated, in_len is the length of an ASN.1 encoding
2N/A * which has just been inserted in *buf
2N/A * modifies *buf, *retlen
2N/A * effects Inserts the encoding of a tag with class = asn1class,
2N/A * primitive/constructed staus = construction,
2N/A * id# = tag and length = in_len into *buf.
2N/A * Returns the length of this encoding in *retlen.
2N/A * Returns ENOMEM if memory runs out.
2N/A * Returns ASN1_OVERFLOW if tagnum exceeds the limits of
2N/A * the implementation.
2N/A */
2N/A
2N/Aasn1_error_code asn1_make_sequence(asn1buf *buf, const unsigned int seq_len,
2N/A unsigned int *len);
2N/A/*
2N/A * requires *buf is allocated, seq_len is the length of a series of
2N/A * sequence components which have just been inserted in *buf
2N/A * modifies *buf, *retlen
2N/A * effects Inserts the sequence header for a sequence of length seq_len
2N/A * in *buf. Returns the length of this encoding in *retlen.
2N/A * Returns ENOMEM if memory runs out.
2N/A */
2N/A
2N/Aasn1_error_code asn1_make_set(asn1buf *buf, const unsigned int set_len,
2N/A unsigned int *retlen);
2N/A/*
2N/A * requires *buf is allocated, seq_len is the length of a series of
2N/A * sequence components which have just been inserted in *buf
2N/A * modifies *buf, *retlen
2N/A * effects Inserts the set header for a set of length set_len in *buf.
2N/A * Returns the length of this encoding in *retlen.
2N/A * Returns ENOMEM if memory runs out.
2N/A */
2N/A
2N/Aasn1_error_code asn1_make_string(asn1buf *buf, const unsigned int len,
2N/A const char *string, int *retlen);
2N/A/*
2N/A * requires *buf is allocated, len is the length of *string
2N/A * effects Inserts the encoding of *string (a series of octets) in *buf.
2N/A * Returns the length of this encoding in *retlen.
2N/A * Returns ENOMEM if memory runs out.
2N/A */
2N/A
2N/A
2N/A/****************************************************************/
2N/A/* Private procedures */
2N/A
2N/A/* "helper" procedure for asn1_make_tag */
2N/Aasn1_error_code asn1_make_length(asn1buf *buf, const unsigned int in_len,
2N/A unsigned int *retlen);
2N/A/*
2N/A * requires *buf is allocated, in_len is the length of an ASN.1 encoding
2N/A * which has just been inserted in *buf
2N/A * modifies *buf, *retlen
2N/A * effects inserts length octet(s) for in_len into *buf
2N/A */
2N/A
2N/A/* "helper" procedure for asn1_make_tag */
2N/Aasn1_error_code asn1_make_id(asn1buf *buf, asn1_class asn1class,
2N/A asn1_construction construction,
2N/A asn1_tagnum tagnum, unsigned int *retlen);
2N/A/*
2N/A * requires *buf is allocated, asn1class and tagnum are appropriate for
2N/A * the ASN.1 encoding which has just been inserted in *buf
2N/A * modifies *buf, *retlen
2N/A * effects Inserts id octet(s) of class asn1class and tag number tagnum
2N/A * into *buf
2N/A */
2N/A
2N/A#endif