2N/A/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2N/A * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A/* Coding Buffer Implementation */ 2N/A * The encoding buffer is filled from bottom (lowest address) to top 2N/A * (highest address). This makes it easier to expand the buffer, 2N/A * since realloc preserves the existing portion of the buffer. 2N/A * Note: Since ASN.1 encoding must be done in reverse, this means 2N/A * that you can't simply memcpy out the buffer data, since it will be 2N/A * backwards. You need to reverse-iterate through it, instead. 2N/A * ***This decision may have been a mistake. In practice, the 2N/A * implementation will probably be tuned such that reallocation is 2N/A * rarely necessary. Also, the realloc probably has recopy the 2N/A * buffer itself, so we don't really gain that much by avoiding an 2N/A * explicit copy of the buffer. --Keep this in mind for future reference. 2N/A * The decoding buffer is in normal order and is created by wrapping 2N/A * an asn1buf around a krb5_data structure. 2N/A * Abstraction Function 2N/A * Programs should use just pointers to asn1buf's (e.g. asn1buf *mybuf). 2N/A * These pointers must always point to a valid, allocated asn1buf 2N/A * structure or be NULL. 2N/A * The contents of the asn1buf represent an octet string. This string 2N/A * begins at base and continues to the octet immediately preceding next. 2N/A * If next == base or mybuf == NULL, then the asn1buf represents an empty 2N/A * Representation Invariant 2N/A * Pointers to asn1buf's must always point to a valid, allocated 2N/A * asn1buf structure or be NULL. 2N/A * base points to a valid, allocated octet array or is NULL 2N/A * bound, if non-NULL, points to the last valid octet 2N/A * next <= bound+2 (i.e. next should be able to step just past the bound, 2N/A * but no further. (The bound should move out in response 2N/A * to being crossed by next.)) 2N/A * Declare private procedures as static if they're not used for inline 2N/A * expansion of other stuff elsewhere. 2N/A }
else /* constructed indefinite */ 2N/A /* sequence was encoded as definite length */ 2N/A /* We have just read the EOC octets. */ 2N/A * Two 0 octets means the end of an indefinite encoding. 2N/A * These parse and unparse procedures should be moved out. They're 2N/A * useful only for debugging and superfluous in the production 2N/A/* OLDDECLARG( (*s)[i] = , (buf->base)[length-i-1]) */ 2N/A ((d)<=
15 ? (
'A'+(d)-
10) : \
2N/A/****************************************************************/ 2N/A/* Private Procedures */ 2N/A /* Solaris Kerberos */