/* -*- 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.
*/
/* ASN.1 primitive encoders */
#include "asn1_encode.h"
#include "asn1_make.h"
{
unsigned int length = 0;
return 0;
}
static asn1_error_code
unsigned int *retlen)
{
unsigned int length = 0;
long valcopy;
int digit;
do {
length++;
length++;
length++;
}
return 0;
}
{
unsigned int length = 0;
unsigned int partlen;
return 0;
}
#if 0
unsigned int *retlen)
{
unsigned int length = 0;
unsigned int partlen;
return 0;
}
#endif
unsigned int *retlen)
{
unsigned int length = 0;
unsigned int partlen;
unsigned long valcopy;
int digit;
do {
length++;
} while (valcopy != 0);
length++;
}
return 0;
}
static asn1_error_code
unsigned int *retlen)
{
unsigned int length;
return 0;
}
unsigned int *retlen)
{
retlen);
}
unsigned int *retlen)
{
retlen);
}
#if 0
{
*retlen = 2;
return 0;
}
{
retlen);
}
{
retlen);
}
#endif
{
/*
* Time encoding: YYYYMMDDhhmmssZ
*/
if (gmt_time == 0) {
sp = "19700101000000Z";
} else {
int len;
/*
* Sanity check this just to be paranoid, as gmtime can return NULL,
* and some bogus implementations might overrun on the sprintf.
*/
#ifdef HAVE_GMTIME_R
# ifdef GMTIME_R_RETURNS_INT
return ASN1_BAD_GMTIME;
# else
return ASN1_BAD_GMTIME;
# endif
#else
return ASN1_BAD_GMTIME;
#endif
return ASN1_BAD_GMTIME;
if (SNPRINTF_OVERFLOW(len, sizeof(s)))
/* Shouldn't be possible given above tests. */
return ASN1_BAD_GMTIME;
sp = s;
}
retlen);
}
unsigned int *retlen)
{
retlen);
}
unsigned int *retlen)
{
unsigned int length;
return 0;
}
unsigned int *retlen)
{
return 0;
}
/*
* ASN.1 constructed type encoder engine
*
* Two entry points here:
*
* krb5int_asn1_encode_a_thing: Incrementally adds the partial
* encoding of an object to an already-initialized asn1buf.
*
* krb5int_asn1_do_full_encode: Returns a completed encoding, in the
* correct byte order, in an allocated krb5_data.
*/
#ifdef POINTERS_ARE_ALL_THE_SAME
(*(const void *const *)(PTR))
#else
#endif
static int
{
int i;
const struct atype_info *a;
a = seq;
i = 0;
while (1) {
break;
i++;
}
return i;
}
static asn1_error_code
const struct atype_info *eltinfo,
unsigned int *retlen);
static asn1_error_code
const struct atype_info *type,
int can_be_empty,
unsigned int *retlen)
{
}
static asn1_error_code
unsigned int *retlen);
static asn1_error_code
const struct field_info *field,
unsigned int *retlen);
const struct atype_info *a, unsigned int *retlen)
{
switch (a->type) {
case atype_fn:
case atype_sequence:
case atype_ptr:
case atype_field:
a->type == atype_nullterm_sequence_of,
retlen);
case atype_tagged_thing:
{
return 0;
}
case atype_int:
case atype_uint:
case atype_min:
case atype_max:
case atype_fn_len:
default:
abort();
}
}
static asn1_error_code
const struct field_info *field,
unsigned int *retlen)
{
unsigned int sum = 0;
case field_immediate:
{
unsigned int length;
&length);
break;
}
case field_sequenceof_len:
{
int slen;
unsigned int length;
const struct atype_info *a;
/*
* The field holds a pointer to the array of objects. So the
* address we compute is a pointer-to-pointer, and that's what
* field->atype must help us dereference.
*/
assert(sizeof(int) <= sizeof(asn1_intmax));
assert(sizeof(unsigned int) <= sizeof(asn1_uintmax));
if (xlen < 0)
return EINVAL;
return EINVAL;
return EINVAL;
} else {
return EINVAL;
return EINVAL;
}
return ASN1_MISSING_FIELD;
break;
}
case field_normal:
{
const void *dataptr;
const struct atype_info *a;
unsigned int length;
if (retval) {
return retval;
}
break;
}
case field_string:
{
const struct atype_info *a;
unsigned int length;
assert(sizeof(int) <= sizeof(asn1_intmax));
assert(sizeof(unsigned int) <= sizeof(asn1_uintmax));
if (xlen < 0)
return EINVAL;
return EINVAL;
} else {
return EINVAL;
}
/* Error - negative or out of size_t range. */
return EINVAL;
return ASN1_MISSING_FIELD;
/*
* Currently our string encoders want "unsigned int" for
* lengths.
*/
return EINVAL;
if (retval) {
return retval;
}
break;
}
default:
abort();
}
unsigned int length;
&length);
if (retval) {
return retval;
}
}
return 0;
}
static asn1_error_code
unsigned int optional,
unsigned int *retlen)
{
size_t i;
unsigned int sum = 0;
for (i = nfields; i > 0; i--) {
unsigned int length;
int present;
if (f->opt == -1)
present = 1;
present = 1;
else
present = 0;
if (present) {
}
}
return 0;
}
static asn1_error_code
unsigned int *retlen)
{
unsigned int optional;
unsigned int sum = 0;
else
/*
* In this case, none of the field descriptors should indicate
* that we examine any bits of this value.
*/
optional = 0;
{
unsigned int length;
}
{
unsigned int length;
}
return 0;
}
static asn1_error_code
const struct atype_info *eltinfo,
unsigned int *retlen)
{
unsigned int sum = 0;
int i;
for (i = seqlen-1; i >= 0; i--) {
const void *eltptr;
unsigned int length;
const struct atype_info *a = eltinfo;
}
{
unsigned int length;
}
return 0;
}
const struct atype_info *a)
{
unsigned int length;
krb5_data *d;
return ASN1_MISSING_FIELD;
if (retval)
return retval;
if (retval)
goto cleanup;
if (retval)
goto cleanup;
*code = d;
return retval;
}