Go to the documentation of this file.
19 #if !defined(ASN_DISABLE_PRINT_SUPPORT)
26 #if !defined(ASN_DISABLE_BER_SUPPORT)
33 #if !defined(ASN_DISABLE_XER_SUPPORT)
40 #if !defined(ASN_DISABLE_JER_SUPPORT)
47 #if !defined(ASN_DISABLE_OER_SUPPORT)
54 #if !defined(ASN_DISABLE_UPER_SUPPORT)
61 #if !defined(ASN_DISABLE_APER_SUPPORT)
68 #if !defined(ASN_DISABLE_RFILL_SUPPORT)
84 #if !defined(ASN_DISABLE_OER_SUPPORT)
87 #if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT)
90 #if !defined(ASN_DISABLE_JER_SUPPORT)
107 uint8_t *buf = st->
buf;
108 uint8_t *buf_end = st->
buf + st->
size;
125 if(plainOrXEROrJER == 0)
128 else if (plainOrXEROrJER == 1)
131 else if (plainOrXEROrJER == 2)
135 ASN_DEBUG(
"ASN.1 forbids dealing with "
136 "unknown value of ENUMERATED type");
151 ASN_DEBUG(
"ASN.1 forbids dealing with "
152 "unknown value of ENUMERATED type");
159 for(p = scratch; buf < buf_end; buf++) {
160 const char *
const h2c =
"0123456789ABCDEF";
161 if((p - scratch) >= (ssize_t)(
sizeof(scratch) - 4)) {
163 if(cb(scratch, p - scratch, app_key) < 0)
165 wrote += p - scratch;
168 *p++ = h2c[*buf >> 4];
169 *p++ = h2c[*buf & 0x0F];
175 wrote += p - scratch;
176 return (cb(scratch, p - scratch, app_key) < 0) ? -1 : wrote;
181 long a = *(
const long *)kp;
185 else if(a == b)
return 0;
191 int count = specs ? specs->
map_count : 0;
205 value = (uintmax_t)(-1);
211 for(; b < end; b++) {
212 value = (value << 8) | *b;
224 if(!iptr || !iptr->
buf || !lptr) {
234 if(size >
sizeof(intmax_t)) {
235 uint8_t *end1 = end - 1;
243 for(; b < end1; b++) {
245 case 0x00:
if((b[1] & 0x80) == 0)
continue;
break;
246 case 0xff:
if((b[1] & 0x80) != 0)
continue;
break;
252 if(size >
sizeof(intmax_t)) {
276 if(!iptr || !iptr->
buf || !lptr) {
286 for(; size >
sizeof(value); b++, size--) {
295 for(value = 0; b < end; b++)
296 value = (value << 8) | *b;
309 if(value <= ((~(uintmax_t)0) >> 1)) {
313 buf = (uint8_t *)
MALLOC(1 +
sizeof(value));
316 end = buf + (
sizeof(value) + 1);
318 for(b = buf + 1, shr = (
sizeof(value) - 1) * 8; b < end; shr -= 8, b++)
319 *b = (uint8_t)(value >> shr);
323 st->
size = 1 +
sizeof(value);
332 volatile uint8_t *pstart;
333 volatile uint8_t *pend1;
334 int littleEndian = 1;
342 buf = (uint8_t *)(
long *)
MALLOC(
sizeof(value));
345 if(*(
char *)&littleEndian) {
346 pstart = (uint8_t *)&value +
sizeof(value) - 1;
347 pend1 = (uint8_t *)&value;
350 pstart = (uint8_t *)&value;
351 pend1 = pstart +
sizeof(value) - 1;
361 for(p = pstart; p != pend1; p += add) {
363 case 0x00:
if((*(p+add) & 0x80) == 0)
366 case 0xff:
if((*(p+add) & 0x80))
373 for(bp = buf, pend1 += add; p != pend1; p += add)
387 if(v < LONG_MIN || v > LONG_MAX) {
426 if(v < INT64_MIN || v > INT64_MAX) {
458 if(value <= INT64_MAX)
461 buf = (uint8_t *)
MALLOC(1 +
sizeof(value));
464 end = buf + (
sizeof(value) + 1);
466 for(b = buf + 1, shr = (
sizeof(value)-1)*8; b < end; shr -= 8, b++)
467 *b = (uint8_t)(value >> shr);
471 st->
size = 1 +
sizeof(value);
480 volatile uint8_t *pstart;
481 volatile uint8_t *pend1;
482 int littleEndian = 1;
490 buf = (uint8_t *)
MALLOC(
sizeof(value));
493 if(*(
char *)&littleEndian) {
494 pstart = (uint8_t *)&value +
sizeof(value) - 1;
495 pend1 = (uint8_t *)&value;
498 pstart = (uint8_t *)&value;
499 pend1 = pstart +
sizeof(value) - 1;
509 for(p = pstart; p != pend1; p += add) {
511 case 0x00:
if((*(p+add) & 0x80) == 0)
514 case 0xff:
if((*(p+add) & 0x80))
521 for(pstart = p, bp = buf, pend1 += add; p != pend1; p += add)
542 const intmax_t asn1_intmax_max = ((~(uintmax_t)0) >> 1);
543 const intmax_t upper_boundary = asn1_intmax_max / 10;
544 intmax_t last_digit_max = asn1_intmax_max % 10;
561 for(value = 0; str < (*end); str++) {
562 if(*str >= 0x30 && *str <= 0x39) {
564 if(value < upper_boundary) {
565 value = value * 10 + d;
566 }
else if(value == upper_boundary) {
567 if(d <= last_digit_max) {
569 value = value * 10 + d;
572 value = -value * 10 - d;
578 if(*str >= 0x30 && *str <= 0x39) {
581 *intp = sign * value;
596 *intp = sign * value;
602 *intp = sign * value;
616 const uintmax_t asn1_uintmax_max = ((~(uintmax_t)0));
617 const uintmax_t upper_boundary = asn1_uintmax_max / 10;
618 uintmax_t last_digit_max = asn1_uintmax_max % 10;
633 for(value = 0; str < (*end); str++) {
634 if(*str >= 0x30 && *str <= 0x39) {
635 unsigned int d = *str -
'0';
636 if(value < upper_boundary) {
637 value = value * 10 + d;
638 }
else if(value == upper_boundary) {
639 if(d <= last_digit_max) {
640 value = value * 10 + d;
645 if(*str >= 0x30 && *str <= 0x39) {
684 if(value >= LONG_MIN && value <= LONG_MAX) {
691 if(value >= LONG_MIN && value <= LONG_MAX) {
699 assert(!
"Unreachable");
714 if(value <= ULONG_MAX) {
721 if(value <= ULONG_MAX) {
729 assert(!
"Unreachable");
743 int sign_a = (a->
buf[0] & 0x80) ? -1 : 1;
744 int sign_b = (b->
buf[0] & 0x80) ? -1 : 1;
746 if(sign_a < sign_b)
return -1;
747 if(sign_a > sign_b)
return 1;
756 return sign_a * memcmp(a->
buf, b->
buf, a->
size);
758 int sign = (a->
buf[0] & 0x80) ? -1 : 1;
761 int sign = (a->
buf[0] & 0x80) ? -1 : 1;
766 }
else if(!a && !b) {
793 a = *aptr =
CALLOC(1,
sizeof(*a));
int INTEGER_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const void *bptr)
int asn_ulong2INTEGER(INTEGER_t *st, unsigned long value)
int INTEGER_copy(const asn_TYPE_descriptor_t *td, void **aptr, const void *bptr)
enum asn_strtox_result_e asn_strtoimax_lim(const char *str, const char **end, intmax_t *intp)
asn_TYPE_descriptor_t asn_DEF_INTEGER
int asn_imax2INTEGER(INTEGER_t *st, intmax_t value)
enum asn_strtox_result_e asn_strtol_lim(const char *str, const char **end, long *lp)
int asn_umax2INTEGER(INTEGER_t *st, uintmax_t value)
const asn_INTEGER_enum_map_t * INTEGER_map_value2enum(const asn_INTEGER_specifics_t *specs, long value)
@ ASN_TAG_CLASS_UNIVERSAL
ber_type_decoder_f ber_decode_primitive
enum asn_strtox_result_e asn_strtoumax_lim(const char *str, const char **end, uintmax_t *uintp)
int asn_INTEGER2long(const INTEGER_t *iptr, long *l)
#define CALLOC(nmemb, size)
int asn_INTEGER2ulong(const INTEGER_t *iptr, unsigned long *l)
jer_type_encoder_f INTEGER_encode_jer
asn_random_fill_f INTEGER_random_fill
int asn_int642INTEGER(INTEGER_t *st, int64_t value)
per_type_decoder_f INTEGER_decode_uper
xer_type_decoder_f INTEGER_decode_xer
int asn_uint642INTEGER(INTEGER_t *st, uint64_t value)
asn_TYPE_operation_t asn_OP_INTEGER
xer_type_encoder_f INTEGER_encode_xer
per_type_encoder_f INTEGER_encode_uper
ssize_t INTEGER__dump(const asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_bytes_f *cb, void *app_key, int plainOrXEROrJER)
int asn_INTEGER2imax(const INTEGER_t *iptr, intmax_t *lptr)
asn_constr_check_f asn_generic_no_constraint
int asn_INTEGER2int64(const INTEGER_t *st, int64_t *value)
jer_type_decoder_f INTEGER_decode_jer
der_type_encoder_f INTEGER_encode_der
int asn_INTEGER2uint64(const INTEGER_t *st, uint64_t *value)
static const ber_tlv_tag_t asn_DEF_INTEGER_tags[]
per_type_decoder_f INTEGER_decode_aper
oer_type_decoder_f INTEGER_decode_oer
int() asn_app_consume_bytes_f(const void *buffer, size_t size, void *application_specific_key)
ssize_t asn__format_to_callback(int(*cb)(const void *, size_t, void *key), void *key, const char *fmt,...)
enum asn_strtox_result_e asn_strtoul_lim(const char *str, const char **end, unsigned long *ulp)
per_type_encoder_f INTEGER_encode_aper
int asn_INTEGER2umax(const INTEGER_t *iptr, uintmax_t *lptr)
static int INTEGER__compar_value2enum(const void *kp, const void *am)
const asn_INTEGER_enum_map_t * value2enum
asn_struct_print_f INTEGER_print
oer_type_encoder_f INTEGER_encode_oer
int asn_long2INTEGER(INTEGER_t *st, long value)
static intmax_t asn__integer_convert(const uint8_t *b, const uint8_t *end)
etsi_its_cam_ts_coding
Author(s): Jean-Pierre Busch
, Guido Küppers , Lennart Reiher
autogenerated on Sun May 18 2025 02:21:23