2N/A/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2N/A * Copyright 1994, 2003 by the Massachusetts Institute of Technology. 2N/A * All Rights Reserved. 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 * 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/* ASN.1 primitive decoders */ 2N/A long n = 0;
/* initialize to keep gcc happy */ 2N/A n = (
0x80 & o) ? -
1 : 0;
/* grab sign bit */ 2N/A else if (
length >
sizeof (
long) +
1)
/* allow extra octet for positive */ 2N/A * asn1_decode_maybe_unsigned 2N/A * This is needed because older releases of MIT krb5 have signed 2N/A * sequence numbers. We want to accept both signed and unsigned 2N/A * sequence numbers, in the range -2^31..2^32-1, mapping negative 2N/A * numbers into their positive equivalents in the same way that C's 2N/A * normal integer conversions do, i.e., would preserve bits on a 2N/A * two's-complement architecture. 2N/A /* Accounts for u_long width not being a multiple of 8. */ 2N/A n = (o &
0x80) ? ~0
UL : 0
UL;
/* grab sign bit */ 2N/A * Skip leading zero or 0xFF octets to humor non-compliant encoders. 2N/A if (n == 0 && o == 0)
2N/A if (n == ~0
UL && o ==
0xff)
2N/A /* Time encoding: YYYYMMDDhhmmssZ */ 2N/A if (s[0] ==
'1' && !
memcmp(
"19700101000000Z", s,
15)) {