/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
*
* Copyright 1994, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*/
/*
*/
#include "k5-int.h"
#include "krbasn1.h"
#include "asn1_k_decode.h"
#include "asn1_decode.h"
#include "asn1_get.h"
/* Solaris Kerberos */
#include "kerberos_dtrace.h"
/* setup *********************************************************/
/* set up variables */
/*
* the setup* macros can return, but are always used at function start
* and thus need no malloc cleanup
*/
\
unsigned int length; \
/* helper macros for cleanup */
/* alloc_field is the first thing to allocate storage that may need cleanup */
/*
* Allocate a principal and initialize enough fields for
* krb5_free_principal to have defined behavior.
*/
alloc_field(var); \
/* process encoding header ***************************************/
/* decode tag and check that it == [APPLICATION tagnum] */
{ \
}
/* process a structure *******************************************/
/* decode an explicit tag and place the number in tagnum */
}
static asn1_error_code
{
taginfo t;
if (retval)
return retval;
return ASN1_MISSING_EOC;
return 0;
}
#define get_eoc() \
{ \
}
/* decode sequence header and initialize tagnum with the first field */
#define begin_structure() \
unsigned int taglen; \
int seqindef; \
int indef; \
next_tag()
#define end_structure() \
/* process fields *******************************************/
/* normal fields ************************/
next_tag()
/*
* error_if_bad_tag
*
* Checks that the next tag is the expected one; returns with an error
* if not.
*/
if (tagnum != (tagexpect)) { clean_return ((tagnum < (tagexpect)) ? ASN1_MISPLACED_FIELD : ASN1_MISSING_FIELD); }
/*
* decode a field (<[UNIVERSAL id]> <length> <contents>)
* check that the id number == tagexpect then
* decode into var
* get the next tag
*/
/* decode (or skip, if not present) an optional field */
} \
}
/* field w/ accompanying length *********/
next_tag()
/* decode a field w/ its length (for string types) */
/* decode an optional field w/ length */
} \
}
/* clean up ******************************************************/
/* finish up */
/* to make things less painful, assume the cleanup is passed rep */
return 0; \
error_out: \
if (rep) \
cleanup_routine(rep); \
return retval;
#define cleanup_none() \
return 0; \
error_out: \
return retval;
#define cleanup_manual() \
return 0;
#ifndef LEAN_CLIENT
{
check_apptag(2);
{ begin_structure();
}
return retval;
}
#endif
{
}
{
setup(krb5_ticket *);
check_apptag(1);
{ begin_structure();
}
}
return retval;
}
{
setup(krb5_keyblock *);
{ begin_structure();
}
return retval;
}
{
check_apptag(3);
{ begin_structure();
if (tagnum == 6)
else
}
return retval;
}
{
else clean_return(KRB5_BADMSGTYPE);
}
{
check_apptag(11);
#ifdef KRB5_MSGTYPE_STRICT
#endif
return retval;
}
{
check_apptag(13);
#ifdef KRB5_MSGTYPE_STRICT
#endif
return retval;
}
{
setup(krb5_ap_req *);
check_apptag(14);
{ begin_structure();
#ifdef KRB5_MSGTYPE_STRICT
#endif
}
}
return retval;
}
{
setup(krb5_ap_rep *);
check_apptag(15);
{ begin_structure();
#ifdef KRB5_MSGTYPE_STRICT
#endif
}
}
return retval;
}
{
check_apptag(27);
{ begin_structure();
}
return retval;
}
{
check_apptag(10);
#ifdef KRB5_MSGTYPE_STRICT
#endif
/* Solaris Kerberos */
return retval;
}
{
check_apptag(12);
#ifdef KRB5_MSGTYPE_STRICT
#endif
/* Solaris Kerberos */
return retval;
}
{
}
/*
* decode_krb5_safe_with_body
*
* Like decode_krb5_safe(), but grabs the encoding of the
* KRB-SAFE-BODY as well, in case re-encoding would produce a
* different encoding. (Yes, we're using DER, but there's this
* annoying problem with pre-1.3.x code using signed sequence numbers,
* which we permissively decode and cram into unsigned 32-bit numbers.
* When they're re-encoded, they're no longer negative if they started
* out negative, so checksum verification fails.)
*
* This does *not* perform any copying; the returned pointer to the
* encoded KRB-SAFE-BODY points into the input buffer.
*/
{
check_apptag(20);
{ begin_structure();
#ifdef KRB5_MSGTYPE_STRICT
#endif
}
/*
* Gross kludge to extract pointer to encoded safe-body. Relies
* on tag prefetch done by next_tag(). Don't handle indefinite
* encoding, as it's too much work.
*/
if (!indef) {
} else {
}
}
return retval;
}
{
}
{
check_apptag(21);
{ begin_structure();
#ifdef KRB5_MSGTYPE_STRICT
#endif
}
}
return retval;
}
{
check_apptag(28);
{ begin_structure();
}
return retval;
}
{
}
{
check_apptag(22);
{ begin_structure();
#ifdef KRB5_MSGTYPE_STRICT
#endif
}
}
return retval;
}
{
check_apptag(29);
{ begin_structure();
}
/* Despite the name, krb5_free_cred_enc_part is contents only. */
return retval;
}
{
setup(krb5_error *);
check_apptag(30);
{ begin_structure();
#ifdef KRB5_MSGTYPE_STRICT
#endif
}
}
return retval;
}
{
cleanup_none(); /* we're not allocating anything here... */
}
{
}
{
setup(krb5_pwd_data *);
{ begin_structure();
end_structure (); }
return retval;
}
{
cleanup_none(); /* we're not allocating anything here */
}
{
setup(krb5_alt_method *);
{ begin_structure();
if (tagnum == 1) {
} else {
}
}
return retval;
}
{
cleanup_none(); /* we're not allocating anything here */
}
{
if (retval == ASN1_BAD_ID) {
}
cleanup_none(); /* we're not allocating anything here */
}
{
}
{
setup(krb5_pa_enc_ts *);
{ begin_structure();
if (tagnum == 1) {
} else
end_structure (); }
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
{
int indef;
unsigned int taglen;
if (tagnum != 0)
}
{begin_structure();
end_structure();}
}
{
setup(krb5_fast_req *);
{begin_structure();
end_structure(); }
if (rep) {
}
return retval;
}
{
{begin_structure();
end_structure(); }
}
{
setup(krb5_enc_data *);
{
int indef;
unsigned int taglen;
if (tagnum != 0)
}
{begin_structure();
}
}
{
}
{
}
const krb5_authdata *authdata,
unsigned int *num,
{
*num = 0;
{
cleanup_none();
}
assert(0); /* NOTREACHED */
}
#ifndef DISABLE_PKINIT
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
if (retval)
goto error_out;
}
{
}
{
}
{
}
#endif /* DISABLE_PKINIT */
{
}