/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
*/
/* Coding Buffer Implementation */
/*
* Implementation
*
* Encoding mode
*
* The encoding buffer is filled from bottom (lowest address) to top
* (highest address). This makes it easier to expand the buffer,
* since realloc preserves the existing portion of the buffer.
*
* Note: Since ASN.1 encoding must be done in reverse, this means
* that you can't simply memcpy out the buffer data, since it will be
* backwards. You need to reverse-iterate through it, instead.
*
* ***This decision may have been a mistake. In practice, the
* implementation will probably be tuned such that reallocation is
* rarely necessary. Also, the realloc probably has recopy the
* buffer itself, so we don't really gain that much by avoiding an
* explicit copy of the buffer. --Keep this in mind for future reference.
*
*
* Decoding mode
*
* The decoding buffer is in normal order and is created by wrapping
* an asn1buf around a krb5_data structure.
*/
/*
* Abstraction Function
*
* Programs should use just pointers to asn1buf's (e.g. asn1buf *mybuf).
* These pointers must always point to a valid, allocated asn1buf
* structure or be NULL.
*
* The contents of the asn1buf represent an octet string. This string
* begins at base and continues to the octet immediately preceding next.
* If next == base or mybuf == NULL, then the asn1buf represents an empty
* octet string.
*/
/*
* Representation Invariant
*
* Pointers to asn1buf's must always point to a valid, allocated
* asn1buf structure or be NULL.
*
* base points to a valid, allocated octet array or is NULL
* bound, if non-NULL, points to the last valid octet
* next >= base
* next <= bound+2 (i.e. next should be able to step just past the bound,
* but no further. (The bound should move out in response
* to being crossed by next.))
*/
#define ASN1BUF_OMIT_INLINE_FUNCS
#include "asn1buf.h"
#include <stdio.h>
#include "asn1_get.h"
#ifdef USE_VALGRIND
#include <valgrind/memcheck.h>
#else
#endif
#if !defined(__GNUC__) || defined(CONFIG_SMALL)
/*
* Declare private procedures as static if they're not used for inline
* expansion of other stuff elsewhere.
*/
static unsigned int asn1buf_free(const asn1buf *);
#endif
{
return 0;
}
{
return 0;
}
{
if (!indef) {
} else /* constructed indefinite */
return 0;
}
{
if (!seqindef) {
/* sequence was encoded as definite length */
if (retval)
return retval;
} else {
/* We have just read the EOC octets. */
}
return 0;
}
{
taginfo t;
int nestlevel;
if (!indef) {
else
return ASN1_OVERRUN;
}
while (nestlevel > 0) {
return ASN1_OVERRUN;
if (!t.indef) {
else
return ASN1_OVERRUN;
}
if (t.indef)
nestlevel++;
nestlevel--; /* got an EOC encoding */
}
return 0;
}
void
{
}
}
#ifdef asn1buf_insert_octet
#endif
{
return 0;
}
{
unsigned int length;
const char *s = sv;
return 0;
}
{
return 0;
}
{
unsigned int i;
if (len == 0) {
*s = 0;
return 0;
}
if (*s == NULL)
return ENOMEM;
for (i=0; i<len; i++)
return 0;
}
{
unsigned int i;
if (len == 0) {
*s = 0;
return 0;
}
for (i=0; i<len; i++)
return 0;
}
int
{
int remain;
/*
* Two 0 octets means the end of an indefinite encoding.
*/
return 0;
else return remain;
}
{
unsigned int i;
krb5_data *d;
if (d == NULL)
return ENOMEM;
free(d);
return ENOMEM;
}
for (i=0; i < d->length; i++)
*code = d;
return 0;
}
/*
* These parse and unparse procedures should be moved out. They're
* useful only for debugging and superfluous in the production
* version.
*/
{
free(*s);
*s = strdup("<NULL>");
*s = strdup("<EMPTY>");
} else {
unsigned int i;
(*s)[length] = '\0';
for (i=0; i<length; i++) ;
/* OLDDECLARG( (*s)[i] = , (buf->base)[length-i-1]) */
}
return 0;
}
{
((d)<=15 ? ('A'+(d)-10) : \
'X'))
free(*s);
*s = strdup("<NULL>");
*s = strdup("<EMPTY>");
} else {
int i;
for (i = length-1; i >= 0; i--) {
}
}
return 0;
}
/****************************************************************/
/* Private Procedures */
static int
{
}
unsigned int
{
}
{
return 0;
}
{
/* Solaris Kerberos */
int next_offset;
int bound_offset;
else
return EINVAL;
if (inc < STANDARD_INCREMENT)
return 0;
}
int
{
}