From 156876237d3a6888ca59a81397e83728c7f99e4a Mon Sep 17 00:00:00 2001 From: Alberto Leiva Popper Date: Sun, 21 Apr 2024 13:14:02 -0600 Subject: [PATCH] ASN.1: Remove random_fills Unused code. Don't know what it's for. --- src/asn1/asn1c/ANY.c | 1 - src/asn1/asn1c/BIT_STRING.c | 72 -------------- src/asn1/asn1c/BIT_STRING.h | 1 - src/asn1/asn1c/BOOLEAN.c | 36 ------- src/asn1/asn1c/BOOLEAN.h | 1 - src/asn1/asn1c/GeneralizedTime.c | 33 ------- src/asn1/asn1c/GeneralizedTime.h | 1 - src/asn1/asn1c/IA5String.c | 1 - src/asn1/asn1c/INTEGER.c | 73 -------------- src/asn1/asn1c/INTEGER.h | 1 - src/asn1/asn1c/Makefile.include | 2 - src/asn1/asn1c/NULL.c | 25 ----- src/asn1/asn1c/NULL.h | 1 - src/asn1/asn1c/OBJECT_IDENTIFIER.c | 67 ------------- src/asn1/asn1c/OBJECT_IDENTIFIER.h | 1 - src/asn1/asn1c/OCTET_STRING.c | 145 ---------------------------- src/asn1/asn1c/OCTET_STRING.h | 5 - src/asn1/asn1c/OPEN_TYPE.c | 1 - src/asn1/asn1c/UTCTime.c | 34 ------- src/asn1/asn1c/UTCTime.h | 1 - src/asn1/asn1c/asn_application.c | 17 ---- src/asn1/asn1c/asn_application.h | 2 - src/asn1/asn1c/asn_random_fill.c | 59 ----------- src/asn1/asn1c/asn_random_fill.h | 56 ----------- src/asn1/asn1c/constr_CHOICE.c | 56 ----------- src/asn1/asn1c/constr_CHOICE.h | 1 - src/asn1/asn1c/constr_SEQUENCE.c | 69 ------------- src/asn1/asn1c/constr_SEQUENCE.h | 1 - src/asn1/asn1c/constr_SEQUENCE_OF.c | 1 - src/asn1/asn1c/constr_SEQUENCE_OF.h | 1 - src/asn1/asn1c/constr_SET_OF.c | 88 ----------------- src/asn1/asn1c/constr_SET_OF.h | 1 - src/asn1/asn1c/constr_TYPE.h | 2 - 33 files changed, 856 deletions(-) delete mode 100644 src/asn1/asn1c/asn_random_fill.c delete mode 100644 src/asn1/asn1c/asn_random_fill.h diff --git a/src/asn1/asn1c/ANY.c b/src/asn1/asn1c/ANY.c index 90a8fc2c..f48c9783 100644 --- a/src/asn1/asn1c/ANY.c +++ b/src/asn1/asn1c/ANY.c @@ -19,7 +19,6 @@ asn_TYPE_operation_t asn_OP_ANY = { OCTET_STRING_decode_ber, OCTET_STRING_encode_der, ANY_encode_xer, - 0, /* Random fill is not defined for ANY type */ 0 /* Use generic outmost tag fetcher */ }; asn_TYPE_descriptor_t asn_DEF_ANY = { diff --git a/src/asn1/asn1c/BIT_STRING.c b/src/asn1/asn1c/BIT_STRING.c index cd9636dc..8e311a87 100644 --- a/src/asn1/asn1c/BIT_STRING.c +++ b/src/asn1/asn1c/BIT_STRING.c @@ -27,7 +27,6 @@ asn_TYPE_operation_t asn_OP_BIT_STRING = { OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ BIT_STRING_encode_xer, - BIT_STRING_random_fill, 0 /* Use generic outmost tag fetcher */ }; asn_TYPE_descriptor_t asn_DEF_BIT_STRING = { @@ -287,74 +286,3 @@ BIT_STRING_compare(const asn_TYPE_descriptor_t *td, const void *aptr, return 1; } } - -asn_random_fill_result_t -BIT_STRING_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, - const asn_encoding_constraints_t *constraints, - size_t max_length) { - const asn_OCTET_STRING_specifics_t *specs = - td->specifics ? (const asn_OCTET_STRING_specifics_t *)td->specifics - : &asn_SPC_BIT_STRING_specs; - asn_random_fill_result_t result_ok = {ARFILL_OK, 1}; - asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0}; - asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0}; - static unsigned lengths[] = {0, 1, 2, 3, 4, 8, - 126, 127, 128, 16383, 16384, 16385, - 65534, 65535, 65536, 65537}; - uint8_t *buf; - uint8_t *bend; - uint8_t *b; - size_t rnd_bits, rnd_len; - BIT_STRING_t *st; - - if(max_length == 0) return result_skipped; - - switch(specs->subvariant) { - case ASN_OSUBV_ANY: - return result_failed; - case ASN_OSUBV_BIT: - break; - default: - break; - } - - /* Figure out how far we should go */ - rnd_bits = lengths[asn_random_between( - 0, sizeof(lengths) / sizeof(lengths[0]) - 1)]; - if(rnd_bits >= max_length) { - rnd_bits = asn_random_between(0, max_length - 1); - } - - rnd_len = (rnd_bits + 7) / 8; - buf = CALLOC(1, rnd_len + 1); - if(!buf) return result_failed; - - bend = &buf[rnd_len]; - - for(b = buf; b < bend; b++) { - *(uint8_t *)b = asn_random_between(0, 255); - } - *b = 0; /* Zero-terminate just in case. */ - - if(*sptr) { - st = *sptr; - FREEMEM(st->buf); - } else { - st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size)); - if(!st) { - FREEMEM(buf); - return result_failed; - } - } - - st->buf = buf; - st->size = rnd_len; - st->bits_unused = (8 - (rnd_bits & 0x7)) & 0x7; - if(st->bits_unused) { - assert(st->size > 0); - st->buf[st->size-1] &= 0xff << st->bits_unused; - } - - result_ok.length = st->size; - return result_ok; -} diff --git a/src/asn1/asn1c/BIT_STRING.h b/src/asn1/asn1c/BIT_STRING.h index acac92a8..0176dde7 100644 --- a/src/asn1/asn1c/BIT_STRING.h +++ b/src/asn1/asn1c/BIT_STRING.h @@ -24,7 +24,6 @@ asn_struct_print_f BIT_STRING_print; /* Human-readable output */ asn_struct_compare_f BIT_STRING_compare; asn_constr_check_f BIT_STRING_constraint; xer_type_encoder_f BIT_STRING_encode_xer; -asn_random_fill_f BIT_STRING_random_fill; #define BIT_STRING_free OCTET_STRING_free #define BIT_STRING_decode_ber OCTET_STRING_decode_ber diff --git a/src/asn1/asn1c/BOOLEAN.c b/src/asn1/asn1c/BOOLEAN.c index f4e80182..b0fdef44 100644 --- a/src/asn1/asn1c/BOOLEAN.c +++ b/src/asn1/asn1c/BOOLEAN.c @@ -19,7 +19,6 @@ asn_TYPE_operation_t asn_OP_BOOLEAN = { BOOLEAN_decode_ber, BOOLEAN_encode_der, BOOLEAN_encode_xer, - BOOLEAN_random_fill, 0 /* Use generic outmost tag fetcher */ }; asn_TYPE_descriptor_t asn_DEF_BOOLEAN = { @@ -220,38 +219,3 @@ BOOLEAN_compare(const asn_TYPE_descriptor_t *td, const void *aptr, return 1; } } - -asn_random_fill_result_t -BOOLEAN_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, - const asn_encoding_constraints_t *constraints, - size_t max_length) { - asn_random_fill_result_t result_ok = {ARFILL_OK, 1}; - asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0}; - asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0}; - BOOLEAN_t *st = *sptr; - - if(max_length == 0) return result_skipped; - - if(st == NULL) { - st = (BOOLEAN_t *)(*sptr = CALLOC(1, sizeof(*st))); - if(st == NULL) { - return result_failed; - } - } - - /* Simulate booleans that are sloppily set and biased. */ - switch(asn_random_between(0, 7)) { - case 0: - case 1: - case 2: - *st = 0; break; - case 3: *st = -1; break; - case 4: *st = 1; break; - case 5: *st = INT_MIN; break; - case 6: *st = INT_MAX; break; - default: - *st = asn_random_between(INT_MIN, INT_MAX); - break; - } - return result_ok; -} diff --git a/src/asn1/asn1c/BOOLEAN.h b/src/asn1/asn1c/BOOLEAN.h index bb9e8a85..0f5f8532 100644 --- a/src/asn1/asn1c/BOOLEAN.h +++ b/src/asn1/asn1c/BOOLEAN.h @@ -23,7 +23,6 @@ asn_struct_compare_f BOOLEAN_compare; ber_type_decoder_f BOOLEAN_decode_ber; der_type_encoder_f BOOLEAN_encode_der; xer_type_encoder_f BOOLEAN_encode_xer; -asn_random_fill_f BOOLEAN_random_fill; #define BOOLEAN_constraint asn_generic_no_constraint diff --git a/src/asn1/asn1c/GeneralizedTime.c b/src/asn1/asn1c/GeneralizedTime.c index 6b5ad9e3..f8efc307 100644 --- a/src/asn1/asn1c/GeneralizedTime.c +++ b/src/asn1/asn1c/GeneralizedTime.c @@ -59,7 +59,6 @@ asn_TYPE_operation_t asn_OP_GeneralizedTime = { OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ GeneralizedTime_encode_der, GeneralizedTime_encode_xer, - GeneralizedTime_random_fill, 0 /* Use generic outmost tag fetcher */ }; asn_TYPE_descriptor_t asn_DEF_GeneralizedTime = { @@ -476,38 +475,6 @@ asn_time2GT_frac(GeneralizedTime_t *opt_gt, const struct tm *tm, int frac_value, return opt_gt; } -asn_random_fill_result_t -GeneralizedTime_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, - const asn_encoding_constraints_t *constraints, - size_t max_length) { - asn_random_fill_result_t result_ok = {ARFILL_OK, 1}; - asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0}; - asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0}; - static const char *values[] = { - "19700101000000", "19700101000000-0000", "19700101000000+0000", - "19700101000000Z", "19700101000000.3Z", "19821106210623.3", - "19821106210629.3Z", "19691106210827.3-0500", "19821106210629.456", - }; - size_t rnd = asn_random_between(0, sizeof(values)/sizeof(values[0])-1); - - (void)constraints; - - if(max_length < sizeof("yyyymmddhhmmss") && !*sptr) { - return result_skipped; - } - - if(*sptr) { - if(OCTET_STRING_fromBuf(*sptr, values[rnd], -1) != 0) { - if(!sptr) return result_failed; - } - } else { - *sptr = OCTET_STRING_new_fromBuf(td, values[rnd], -1); - if(!sptr) return result_failed; - } - - return result_ok; -} - int GeneralizedTime_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const void *bptr) { diff --git a/src/asn1/asn1c/GeneralizedTime.h b/src/asn1/asn1c/GeneralizedTime.h index 7a8ad1bb..5a974f4b 100644 --- a/src/asn1/asn1c/GeneralizedTime.h +++ b/src/asn1/asn1c/GeneralizedTime.h @@ -19,7 +19,6 @@ asn_struct_compare_f GeneralizedTime_compare; asn_constr_check_f GeneralizedTime_constraint; der_type_encoder_f GeneralizedTime_encode_der; xer_type_encoder_f GeneralizedTime_encode_xer; -asn_random_fill_f GeneralizedTime_random_fill; #define GeneralizedTime_free OCTET_STRING_free #define GeneralizedTime_decode_ber OCTET_STRING_decode_ber diff --git a/src/asn1/asn1c/IA5String.c b/src/asn1/asn1c/IA5String.c index a99387d6..29a9df29 100644 --- a/src/asn1/asn1c/IA5String.c +++ b/src/asn1/asn1c/IA5String.c @@ -19,7 +19,6 @@ asn_TYPE_operation_t asn_OP_IA5String = { OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ OCTET_STRING_encode_der, OCTET_STRING_encode_xer_utf8, - OCTET_STRING_random_fill, 0 /* Use generic outmost tag fetcher */ }; asn_TYPE_descriptor_t asn_DEF_IA5String = { diff --git a/src/asn1/asn1c/INTEGER.c b/src/asn1/asn1c/INTEGER.c index fac951db..2d6d0dfa 100644 --- a/src/asn1/asn1c/INTEGER.c +++ b/src/asn1/asn1c/INTEGER.c @@ -22,7 +22,6 @@ asn_TYPE_operation_t asn_OP_INTEGER = { ber_decode_primitive, INTEGER_encode_der, INTEGER_encode_xer, - INTEGER_random_fill, 0 /* Use generic outmost tag fetcher */ }; asn_TYPE_descriptor_t asn_DEF_INTEGER = { @@ -711,75 +710,3 @@ INTEGER_compare(const asn_TYPE_descriptor_t *td, const void *aptr, } } - -asn_random_fill_result_t -INTEGER_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, - const asn_encoding_constraints_t *constraints, - size_t max_length) { - const asn_INTEGER_specifics_t *specs = - (const asn_INTEGER_specifics_t *)td->specifics; - asn_random_fill_result_t result_ok = {ARFILL_OK, 1}; - asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0}; - asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0}; - INTEGER_t *st = *sptr; - const asn_INTEGER_enum_map_t *emap; - size_t emap_len; - intmax_t value; - int find_inside_map; - - if(max_length == 0) return result_skipped; - - if(st == NULL) { - st = (INTEGER_t *)CALLOC(1, sizeof(*st)); - if(st == NULL) { - return result_failed; - } - } - - if(specs) { - emap = specs->value2enum; - emap_len = specs->map_count; - if(specs->strict_enumeration) { - find_inside_map = emap_len > 0; - } else { - find_inside_map = emap_len ? asn_random_between(0, 1) : 0; - } - } else { - emap = 0; - emap_len = 0; - find_inside_map = 0; - } - - if(find_inside_map) { - assert(emap_len > 0); - value = emap[asn_random_between(0, emap_len - 1)].nat_value; - } else { - static const long variants[] = { - -65536, -65535, -65534, -32769, -32768, -32767, -16385, -16384, - -16383, -257, -256, -255, -254, -129, -128, -127, - -126, -1, 0, 1, 126, 127, 128, 129, - 254, 255, 256, 257, 16383, 16384, 16385, 32767, - 32768, 32769, 65534, 65535, 65536, 65537}; - if(specs && specs->field_unsigned) { - assert(variants[18] == 0); - value = variants[asn_random_between( - 18, sizeof(variants) / sizeof(variants[0]) - 1)]; - } else { - value = variants[asn_random_between( - 0, sizeof(variants) / sizeof(variants[0]) - 1)]; - } - } - - if(asn_imax2INTEGER(st, value)) { - if(st == *sptr) { - ASN_STRUCT_RESET(*td, st); - } else { - ASN_STRUCT_FREE(*td, st); - } - return result_failed; - } else { - *sptr = st; - result_ok.length = st->size; - return result_ok; - } -} diff --git a/src/asn1/asn1c/INTEGER.h b/src/asn1/asn1c/INTEGER.h index 9367d05f..acc07ce3 100644 --- a/src/asn1/asn1c/INTEGER.h +++ b/src/asn1/asn1c/INTEGER.h @@ -38,7 +38,6 @@ asn_struct_print_f INTEGER_print; asn_struct_compare_f INTEGER_compare; der_type_encoder_f INTEGER_encode_der; xer_type_encoder_f INTEGER_encode_xer; -asn_random_fill_f INTEGER_random_fill; /*********************************** * Some handy conversion routines. * diff --git a/src/asn1/asn1c/Makefile.include b/src/asn1/asn1c/Makefile.include index 01e1d9f8..5043095d 100644 --- a/src/asn1/asn1c/Makefile.include +++ b/src/asn1/asn1c/Makefile.include @@ -162,8 +162,6 @@ ASN_MODULE_HDRS+=asn1/asn1c/asn_system.h ASN_MODULE_HDRS+=asn1/asn1c/asn_codecs.h ASN_MODULE_HDRS+=asn1/asn1c/asn_internal.h ASN_MODULE_SRCS+=asn1/asn1c/asn_internal.c -ASN_MODULE_HDRS+=asn1/asn1c/asn_random_fill.h -ASN_MODULE_SRCS+=asn1/asn1c/asn_random_fill.c ASN_MODULE_SRCS+=asn1/asn1c/OCTET_STRING.c ASN_MODULE_HDRS+=asn1/asn1c/BIT_STRING.h ASN_MODULE_SRCS+=asn1/asn1c/BIT_STRING.c diff --git a/src/asn1/asn1c/NULL.c b/src/asn1/asn1c/NULL.c index 70f1e249..2811a846 100644 --- a/src/asn1/asn1c/NULL.c +++ b/src/asn1/asn1c/NULL.c @@ -19,7 +19,6 @@ asn_TYPE_operation_t asn_OP_NULL = { NULL_decode_ber, NULL_encode_der, /* Special handling of DER encoding */ NULL_encode_xer, - NULL_random_fill, 0 /* Use generic outmost tag fetcher */ }; asn_TYPE_descriptor_t asn_DEF_NULL = { @@ -146,27 +145,3 @@ NULL_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, return (cb("", 8, app_key) < 0) ? -1 : 0; } } - -asn_random_fill_result_t -NULL_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, - const asn_encoding_constraints_t *constr, - size_t max_length) { - asn_random_fill_result_t result_ok = {ARFILL_OK, 1}; - asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0}; - asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0}; - NULL_t *st = *sptr; - - (void)td; - (void)constr; - - if(max_length == 0) return result_skipped; - - if(st == NULL) { - st = (NULL_t *)(*sptr = CALLOC(1, sizeof(*st))); - if(st == NULL) { - return result_failed; - } - } - - return result_ok; -} diff --git a/src/asn1/asn1c/NULL.h b/src/asn1/asn1c/NULL.h index f6b877aa..f93bd4ae 100644 --- a/src/asn1/asn1c/NULL.h +++ b/src/asn1/asn1c/NULL.h @@ -22,7 +22,6 @@ asn_struct_compare_f NULL_compare; ber_type_decoder_f NULL_decode_ber; der_type_encoder_f NULL_encode_der; xer_type_encoder_f NULL_encode_xer; -asn_random_fill_f NULL_random_fill; #define NULL_constraint asn_generic_no_constraint diff --git a/src/asn1/asn1c/OBJECT_IDENTIFIER.c b/src/asn1/asn1c/OBJECT_IDENTIFIER.c index 00a9d867..c964c809 100644 --- a/src/asn1/asn1c/OBJECT_IDENTIFIER.c +++ b/src/asn1/asn1c/OBJECT_IDENTIFIER.c @@ -23,7 +23,6 @@ asn_TYPE_operation_t asn_OP_OBJECT_IDENTIFIER = { ber_decode_primitive, der_encode_primitive, OBJECT_IDENTIFIER_encode_xer, - OBJECT_IDENTIFIER_random_fill, 0 /* Use generic outmost tag fetcher */ }; asn_TYPE_descriptor_t asn_DEF_OBJECT_IDENTIFIER = { @@ -509,69 +508,3 @@ OBJECT_IDENTIFIER_parse_arcs(const char *oid_text, ssize_t oid_txt_length, errno = EINVAL; /* Broken OID */ return -1; } - -/* - * Generate values from the list of interesting values, or just a random - * value up to the upper limit. - */ -static asn_oid_arc_t -OBJECT_IDENTIFIER__biased_random_arc(asn_oid_arc_t upper_bound) { - const asn_oid_arc_t values[] = {0, 1, 127, 128, 129, 254, 255, 256}; - size_t idx; - - switch(asn_random_between(0, 2)) { - case 0: - idx = asn_random_between(0, sizeof(values) / sizeof(values[0]) - 1); - if(values[idx] < upper_bound) { - return values[idx]; - } - /* Fall through */ - case 1: - return asn_random_between(0, upper_bound); - case 2: - default: - return upper_bound; - } -} - -asn_random_fill_result_t -OBJECT_IDENTIFIER_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, - const asn_encoding_constraints_t *constraints, - size_t max_length) { - asn_random_fill_result_t result_ok = {ARFILL_OK, 1}; - asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0}; - asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0}; - OBJECT_IDENTIFIER_t *st; - asn_oid_arc_t arcs[5]; - size_t arcs_len = asn_random_between(2, 5); - size_t i; - - (void)constraints; - - if(max_length < arcs_len) return result_skipped; - - if(*sptr) { - st = *sptr; - } else { - st = CALLOC(1, sizeof(*st)); - } - - arcs[0] = asn_random_between(0, 2); - arcs[1] = OBJECT_IDENTIFIER__biased_random_arc( - arcs[0] <= 1 ? 39 : (ASN_OID_ARC_MAX - 80)); - for(i = 2; i < arcs_len; i++) { - arcs[i] = OBJECT_IDENTIFIER__biased_random_arc(ASN_OID_ARC_MAX); - } - - if(OBJECT_IDENTIFIER_set_arcs(st, arcs, arcs_len)) { - if(st != *sptr) { - ASN_STRUCT_FREE(*td, st); - } - return result_failed; - } - - *sptr = st; - - result_ok.length = st->size; - return result_ok; -} diff --git a/src/asn1/asn1c/OBJECT_IDENTIFIER.h b/src/asn1/asn1c/OBJECT_IDENTIFIER.h index c210cb5b..78fcecd8 100644 --- a/src/asn1/asn1c/OBJECT_IDENTIFIER.h +++ b/src/asn1/asn1c/OBJECT_IDENTIFIER.h @@ -21,7 +21,6 @@ asn_struct_print_f OBJECT_IDENTIFIER_print; asn_constr_check_f OBJECT_IDENTIFIER_constraint; der_type_encoder_f OBJECT_IDENTIFIER_encode_der; xer_type_encoder_f OBJECT_IDENTIFIER_encode_xer; -asn_random_fill_f OBJECT_IDENTIFIER_random_fill; #define OBJECT_IDENTIFIER_free ASN__PRIMITIVE_TYPE_free #define OBJECT_IDENTIFIER_compare OCTET_STRING_compare diff --git a/src/asn1/asn1c/OCTET_STRING.c b/src/asn1/asn1c/OCTET_STRING.c index ecd17f83..377c8fcd 100644 --- a/src/asn1/asn1c/OCTET_STRING.c +++ b/src/asn1/asn1c/OCTET_STRING.c @@ -28,7 +28,6 @@ asn_TYPE_operation_t asn_OP_OCTET_STRING = { OCTET_STRING_decode_ber, OCTET_STRING_encode_der, OCTET_STRING_encode_xer, - OCTET_STRING_random_fill, 0 /* Use generic outmost tag fetcher */ }; asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = { @@ -940,147 +939,3 @@ OCTET_STRING_compare(const asn_TYPE_descriptor_t *td, const void *aptr, } } - -/* - * Biased function for randomizing character values around their limits. - */ -static uint32_t -OCTET_STRING__random_char(unsigned long lb, unsigned long ub) { - assert(lb <= ub); - switch(asn_random_between(0, 16)) { - case 0: - if(lb < ub) return lb + 1; - /* Fall through */ - case 1: - return lb; - case 2: - if(lb < ub) return ub - 1; - /* Fall through */ - case 3: - return ub; - default: - return asn_random_between(lb, ub); - } -} - - -size_t -OCTET_STRING_random_length_constrained( - const asn_TYPE_descriptor_t *td, - const asn_encoding_constraints_t *constraints, size_t max_length) { - const unsigned lengths[] = {0, 1, 2, 3, 4, 8, - 126, 127, 128, 16383, 16384, 16385, - 65534, 65535, 65536, 65537}; - size_t rnd_len; - - /* Figure out how far we should go */ - rnd_len = lengths[asn_random_between( - 0, sizeof(lengths) / sizeof(lengths[0]) - 1)]; - - if(rnd_len > max_length) { - rnd_len = asn_random_between(0, max_length); - } - - return rnd_len; -} - -asn_random_fill_result_t -OCTET_STRING_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, - const asn_encoding_constraints_t *constraints, - size_t max_length) { - const asn_OCTET_STRING_specifics_t *specs = td->specifics - ? (const asn_OCTET_STRING_specifics_t *)td->specifics - : &asn_SPC_OCTET_STRING_specs; - asn_random_fill_result_t result_ok = {ARFILL_OK, 1}; - asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0}; - asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0}; - unsigned int unit_bytes = 1; - unsigned long clb = 0; /* Lower bound on char */ - unsigned long cub = 255; /* Higher bound on char value */ - uint8_t *buf; - uint8_t *bend; - uint8_t *b; - size_t rnd_len; - OCTET_STRING_t *st; - - if(max_length == 0 && !*sptr) return result_skipped; - - switch(specs->subvariant) { - default: - case ASN_OSUBV_ANY: - return result_failed; - case ASN_OSUBV_BIT: - /* Handled by BIT_STRING itself. */ - return result_failed; - case ASN_OSUBV_STR: - unit_bytes = 1; - clb = 0; - cub = 255; - break; - case ASN_OSUBV_U16: - unit_bytes = 2; - clb = 0; - cub = 65535; - break; - case ASN_OSUBV_U32: - unit_bytes = 4; - clb = 0; - cub = 0x10FFFF; - break; - } - - if(!constraints) - constraints = &td->encoding_constraints; - - rnd_len = - OCTET_STRING_random_length_constrained(td, constraints, max_length); - - buf = CALLOC(unit_bytes, rnd_len + 1); - if(!buf) return result_failed; - - bend = &buf[unit_bytes * rnd_len]; - - switch(unit_bytes) { - case 1: - for(b = buf; b < bend; b += unit_bytes) { - *(uint8_t *)b = OCTET_STRING__random_char(clb, cub); - } - *(uint8_t *)b = 0; - break; - case 2: - for(b = buf; b < bend; b += unit_bytes) { - uint32_t code = OCTET_STRING__random_char(clb, cub); - b[0] = code >> 8; - b[1] = code; - } - *(uint16_t *)b = 0; - break; - case 4: - for(b = buf; b < bend; b += unit_bytes) { - uint32_t code = OCTET_STRING__random_char(clb, cub); - b[0] = code >> 24; - b[1] = code >> 16; - b[2] = code >> 8; - b[3] = code; - } - *(uint32_t *)b = 0; - break; - } - - if(*sptr) { - st = *sptr; - FREEMEM(st->buf); - } else { - st = (OCTET_STRING_t *)(*sptr = CALLOC(1, specs->struct_size)); - if(!st) { - FREEMEM(buf); - return result_failed; - } - } - - st->buf = buf; - st->size = unit_bytes * rnd_len; - - result_ok.length = st->size; - return result_ok; -} diff --git a/src/asn1/asn1c/OCTET_STRING.h b/src/asn1/asn1c/OCTET_STRING.h index d12b5a61..c0568750 100644 --- a/src/asn1/asn1c/OCTET_STRING.h +++ b/src/asn1/asn1c/OCTET_STRING.h @@ -33,7 +33,6 @@ ber_type_decoder_f OCTET_STRING_decode_ber; der_type_encoder_f OCTET_STRING_encode_der; xer_type_encoder_f OCTET_STRING_encode_xer; xer_type_encoder_f OCTET_STRING_encode_xer_utf8; -asn_random_fill_f OCTET_STRING_random_fill; #define OCTET_STRING_constraint asn_generic_no_constraint @@ -85,8 +84,4 @@ typedef struct asn_OCTET_STRING_specifics_s { extern asn_OCTET_STRING_specifics_t asn_SPC_OCTET_STRING_specs; -size_t OCTET_STRING_random_length_constrained( - const asn_TYPE_descriptor_t *, const asn_encoding_constraints_t *, - size_t max_length); - #endif /* _OCTET_STRING_H_ */ diff --git a/src/asn1/asn1c/OPEN_TYPE.c b/src/asn1/asn1c/OPEN_TYPE.c index b7c51929..fb167a92 100644 --- a/src/asn1/asn1c/OPEN_TYPE.c +++ b/src/asn1/asn1c/OPEN_TYPE.c @@ -14,7 +14,6 @@ asn_TYPE_operation_t asn_OP_OPEN_TYPE = { OPEN_TYPE_decode_ber, OPEN_TYPE_encode_der, OPEN_TYPE_encode_xer, - 0, /* Random fill is not supported for open type */ 0, /* Use generic outmost tag fetcher */ }; diff --git a/src/asn1/asn1c/UTCTime.c b/src/asn1/asn1c/UTCTime.c index b96b27e0..4e45451b 100644 --- a/src/asn1/asn1c/UTCTime.c +++ b/src/asn1/asn1c/UTCTime.c @@ -27,7 +27,6 @@ asn_TYPE_operation_t asn_OP_UTCTime = { OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ OCTET_STRING_encode_der, /* Implemented in terms of OCTET STRING */ UTCTime_encode_xer, - UTCTime_random_fill, 0 /* Use generic outmost tag fetcher */ }; asn_TYPE_descriptor_t asn_DEF_UTCTime = { @@ -166,39 +165,6 @@ asn_time2UT(UTCTime_t *opt_ut, const struct tm *tm) { return (UTCTime_t *)gt; } - -asn_random_fill_result_t -UTCTime_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, - const asn_encoding_constraints_t *constraints, - size_t max_length) { - asn_random_fill_result_t result_ok = {ARFILL_OK, 1}; - asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0}; - asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0}; - static const char *values[] = { - "700101000000", "700101000000-0000", "700101000000+0000", - "700101000000Z", "821106210623", "691106210827-0500", - "821106210629Z", - }; - size_t rnd = asn_random_between(0, sizeof(values)/sizeof(values[0])-1); - - (void)constraints; - - if(max_length < sizeof("yymmddhhmmss") && !*sptr) { - return result_skipped; - } - - if(*sptr) { - if(OCTET_STRING_fromBuf(*sptr, values[rnd], -1) != 0) { - if(!sptr) return result_failed; - } - } else { - *sptr = OCTET_STRING_new_fromBuf(td, values[rnd], -1); - if(!sptr) return result_failed; - } - - return result_ok; -} - int UTCTime_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const void *bptr) { diff --git a/src/asn1/asn1c/UTCTime.h b/src/asn1/asn1c/UTCTime.h index 2b035282..25f308e7 100644 --- a/src/asn1/asn1c/UTCTime.h +++ b/src/asn1/asn1c/UTCTime.h @@ -18,7 +18,6 @@ asn_struct_print_f UTCTime_print; asn_struct_compare_f UTCTime_compare; asn_constr_check_f UTCTime_constraint; xer_type_encoder_f UTCTime_encode_xer; -asn_random_fill_f UTCTime_random_fill; #define UTCTime_free OCTET_STRING_free #define UTCTime_decode_ber OCTET_STRING_decode_ber diff --git a/src/asn1/asn1c/asn_application.c b/src/asn1/asn1c/asn_application.c index d2ca1c18..1106160f 100644 --- a/src/asn1/asn1c/asn_application.c +++ b/src/asn1/asn1c/asn_application.c @@ -261,10 +261,6 @@ asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx, } break; - case ATS_RANDOM: - errno = ENOENT; /* Randomization doesn't make sense on output. */ - ASN__ENCODE_FAILED; - case ATS_BER: /* BER is a superset of DER. */ /* Fall through. */ @@ -310,19 +306,6 @@ asn_decode(const asn_codec_ctx_t *opt_codec_ctx, errno = ENOENT; ASN__DECODE_FAILED; - case ATS_RANDOM: - if(!td->op->random_fill) { - ASN__DECODE_FAILED; - } else { - if(asn_random_fill(td, sptr, 16000) == 0) { - asn_dec_rval_t ret = {RC_OK, 0}; - return ret; - } else { - ASN__DECODE_FAILED; - } - } - break; - case ATS_DER: case ATS_BER: return ber_decode(opt_codec_ctx, td, sptr, buffer, size); diff --git a/src/asn1/asn1c/asn_application.h b/src/asn1/asn1c/asn_application.h index 94c3407a..8382ca80 100644 --- a/src/asn1/asn1c/asn_application.h +++ b/src/asn1/asn1c/asn_application.h @@ -20,8 +20,6 @@ enum asn_transfer_syntax { ATS_INVALID = 0, /* Plaintext output (not conforming to any standard), for debugging. */ ATS_NONSTANDARD_PLAINTEXT, - /* Returns a randomly generatede structure. */ - ATS_RANDOM, /* * X.690: * BER: Basic Encoding Rules. diff --git a/src/asn1/asn1c/asn_random_fill.c b/src/asn1/asn1c/asn_random_fill.c deleted file mode 100644 index 3323641b..00000000 --- a/src/asn1/asn1c/asn_random_fill.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2017 Lev Walkin . - * All rights reserved. - * Redistribution and modifications are permitted subject to BSD license. - */ - -#include - -#include "asn1/asn1c/asn_internal.h" -#include "asn1/asn1c/asn_random_fill.h" -#include "asn1/asn1c/constr_TYPE.h" - -int -asn_random_fill(const struct asn_TYPE_descriptor_s *td, void **struct_ptr, - size_t length) { - - if(td && td->op->random_fill) { - asn_random_fill_result_t res = - td->op->random_fill(td, struct_ptr, 0, length); - return (res.code == ARFILL_OK) ? 0 : -1; - } else { - return -1; - } -} - -static uintmax_t -asn__intmax_range(intmax_t lb, intmax_t ub) { - assert(lb <= ub); - if((ub < 0) == (lb < 0)) { - return ub - lb; - } else if(lb < 0) { - return 1 + ((uintmax_t)ub + (uintmax_t)-(lb + 1)); - } else { - assert(!"Unreachable"); - return 0; - } -} - -intmax_t -asn_random_between(intmax_t lb, intmax_t rb) { - if(lb == rb) { - return lb; - } else { - const uintmax_t intmax_max = ((~(uintmax_t)0) >> 1); - uintmax_t range = asn__intmax_range(lb, rb); - uintmax_t value = 0; - uintmax_t got_entropy = 0; - - assert(RAND_MAX > 0xffffff); /* Seen 7ffffffd! */ - assert(range < intmax_max); - - for(; got_entropy < range;) { - got_entropy = (got_entropy << 24) | 0xffffff; - value = (value << 24) | (random() % 0xffffff); - } - - return lb + (intmax_t)(value % (range + 1)); - } -} diff --git a/src/asn1/asn1c/asn_random_fill.h b/src/asn1/asn1c/asn_random_fill.h deleted file mode 100644 index e5383b2a..00000000 --- a/src/asn1/asn1c/asn_random_fill.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017 Lev Walkin . All rights reserved. - * Redistribution and modifications are permitted subject to BSD license. - */ -#ifndef ASN_RANDOM_FILL -#define ASN_RANDOM_FILL - -#include -#include -#include -#include -#include -#include -#include - -/* Forward declarations */ -struct asn_TYPE_descriptor_s; -struct asn_encoding_constraints_s; - -/* - * Initialize a structure with random data according to the type specification - * and optional member constraints. - * ARGUMENTS: - * (max_length) - See (approx_max_length_limit). - * (memb_constraints) - Member constraints, if exist. - * In case the return differs from ARFILL_OK, the (struct_ptr) contents - * and (current_length) value remain in their original state. - */ -typedef struct asn_random_fill_result_s { - enum { - ARFILL_FAILED = -1, /* System error (memory?) */ - ARFILL_OK = 0, /* Initialization succeeded */ - ARFILL_SKIPPED = 1 /* Not done due to (length?) constraint */ - } code; - size_t length; /* Approximate number of bytes created. */ -} asn_random_fill_result_t; -typedef asn_random_fill_result_t(asn_random_fill_f)( - const struct asn_TYPE_descriptor_s *td, void **struct_ptr, - const struct asn_encoding_constraints_s *memb_constraints, - size_t max_length); - -/* - * Returns 0 if the structure was properly initialized, -1 otherwise. - * The (approx_max_length_limit) specifies the approximate limit of the - * resulting structure in units closely resembling bytes. The actual result - * might be several times larger or smaller than the length limit. - */ -int asn_random_fill(const struct asn_TYPE_descriptor_s *td, void **struct_ptr, - size_t approx_max_length_limit); - -/* - * Returns a random number between min and max. - */ -intmax_t asn_random_between(intmax_t min, intmax_t max); - -#endif /* ASN_RANDOM_FILL */ diff --git a/src/asn1/asn1c/constr_CHOICE.c b/src/asn1/asn1c/constr_CHOICE.c index 2f017b78..05039e2e 100644 --- a/src/asn1/asn1c/constr_CHOICE.c +++ b/src/asn1/asn1c/constr_CHOICE.c @@ -837,61 +837,6 @@ CHOICE_variant_set_presence(const asn_TYPE_descriptor_t *td, void *sptr, return 0; } - -asn_random_fill_result_t -CHOICE_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, - const asn_encoding_constraints_t *constr, - size_t max_length) { - const asn_CHOICE_specifics_t *specs = - (const asn_CHOICE_specifics_t *)td->specifics; - asn_random_fill_result_t res; - asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0}; - asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0}; - const asn_TYPE_member_t *elm; - unsigned present; - void *memb_ptr; /* Pointer to the member */ - void **memb_ptr2; /* Pointer to that pointer */ - void *st = *sptr; - - if(max_length == 0) return result_skipped; - - (void)constr; - - if(st == NULL) { - st = CALLOC(1, specs->struct_size); - if(st == NULL) { - return result_failed; - } - } - - present = asn_random_between(1, td->elements_count); - elm = &td->elements[present - 1]; - - if(elm->flags & ATF_POINTER) { - /* Member is a pointer to another structure */ - memb_ptr2 = (void **)((char *)st + elm->memb_offset); - } else { - memb_ptr = (char *)st + elm->memb_offset; - memb_ptr2 = &memb_ptr; - } - - res = elm->type->op->random_fill(elm->type, memb_ptr2, - &elm->encoding_constraints, max_length); - _set_present_idx(st, specs->pres_offset, specs->pres_size, present); - if(res.code == ARFILL_OK) { - *sptr = st; - } else { - if(st == *sptr) { - ASN_STRUCT_RESET(*td, st); - } else { - ASN_STRUCT_FREE(*td, st); - } - } - - return res; -} - - asn_TYPE_operation_t asn_OP_CHOICE = { CHOICE_free, CHOICE_print, @@ -899,6 +844,5 @@ asn_TYPE_operation_t asn_OP_CHOICE = { CHOICE_decode_ber, CHOICE_encode_der, CHOICE_encode_xer, - CHOICE_random_fill, CHOICE_outmost_tag }; diff --git a/src/asn1/asn1c/constr_CHOICE.h b/src/asn1/asn1c/constr_CHOICE.h index a9490d93..f8101e8a 100644 --- a/src/asn1/asn1c/constr_CHOICE.h +++ b/src/asn1/asn1c/constr_CHOICE.h @@ -39,7 +39,6 @@ ber_type_decoder_f CHOICE_decode_ber; der_type_encoder_f CHOICE_encode_der; xer_type_encoder_f CHOICE_encode_xer; asn_outmost_tag_f CHOICE_outmost_tag; -asn_random_fill_f CHOICE_random_fill; extern asn_TYPE_operation_t asn_OP_CHOICE; /* diff --git a/src/asn1/asn1c/constr_SEQUENCE.c b/src/asn1/asn1c/constr_SEQUENCE.c index ccc4c8c1..ce2ea37e 100644 --- a/src/asn1/asn1c/constr_SEQUENCE.c +++ b/src/asn1/asn1c/constr_SEQUENCE.c @@ -868,74 +868,5 @@ asn_TYPE_operation_t asn_OP_SEQUENCE = { SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_encode_xer, - SEQUENCE_random_fill, 0 /* Use generic outmost tag fetcher */ }; - - -asn_random_fill_result_t -SEQUENCE_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, - const asn_encoding_constraints_t *constr, - size_t max_length) { - const asn_SEQUENCE_specifics_t *specs = - (const asn_SEQUENCE_specifics_t *)td->specifics; - asn_random_fill_result_t result_ok = {ARFILL_OK, 0}; - asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0}; - asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0}; - void *st = *sptr; - size_t edx; - - if(max_length == 0) return result_skipped; - - (void)constr; - - if(st == NULL) { - st = CALLOC(1, specs->struct_size); - if(st == NULL) { - return result_failed; - } - } - - for(edx = 0; edx < td->elements_count; edx++) { - const asn_TYPE_member_t *elm = &td->elements[edx]; - void *memb_ptr; /* Pointer to the member */ - void **memb_ptr2; /* Pointer to that pointer */ - asn_random_fill_result_t tmpres; - - if(elm->optional && asn_random_between(0, 4) == 2) { - /* Sometimes decide not to fill the optional value */ - continue; - } - - if(elm->flags & ATF_POINTER) { - /* Member is a pointer to another structure */ - memb_ptr2 = (void **)((char *)st + elm->memb_offset); - } else { - memb_ptr = (char *)st + elm->memb_offset; - memb_ptr2 = &memb_ptr; - } - - tmpres = elm->type->op->random_fill( - elm->type, memb_ptr2, &elm->encoding_constraints, - max_length > result_ok.length ? max_length - result_ok.length : 0); - switch(tmpres.code) { - case ARFILL_OK: - result_ok.length += tmpres.length; - continue; - case ARFILL_SKIPPED: - assert(!(elm->flags & ATF_POINTER) || *memb_ptr2 == NULL); - continue; - case ARFILL_FAILED: - if(st == *sptr) { - ASN_STRUCT_RESET(*td, st); - } else { - ASN_STRUCT_FREE(*td, st); - } - return tmpres; - } - } - - *sptr = st; - - return result_ok; -} diff --git a/src/asn1/asn1c/constr_SEQUENCE.h b/src/asn1/asn1c/constr_SEQUENCE.h index 52e6c071..e90c821d 100644 --- a/src/asn1/asn1c/constr_SEQUENCE.h +++ b/src/asn1/asn1c/constr_SEQUENCE.h @@ -39,7 +39,6 @@ asn_constr_check_f SEQUENCE_constraint; ber_type_decoder_f SEQUENCE_decode_ber; der_type_encoder_f SEQUENCE_encode_der; xer_type_encoder_f SEQUENCE_encode_xer; -asn_random_fill_f SEQUENCE_random_fill; extern asn_TYPE_operation_t asn_OP_SEQUENCE; #endif /* _CONSTR_SEQUENCE_H_ */ diff --git a/src/asn1/asn1c/constr_SEQUENCE_OF.c b/src/asn1/asn1c/constr_SEQUENCE_OF.c index b0eedc01..34d9e4ce 100644 --- a/src/asn1/asn1c/constr_SEQUENCE_OF.c +++ b/src/asn1/asn1c/constr_SEQUENCE_OF.c @@ -175,6 +175,5 @@ asn_TYPE_operation_t asn_OP_SEQUENCE_OF = { SEQUENCE_OF_decode_ber, SEQUENCE_OF_encode_der, SEQUENCE_OF_encode_xer, - SEQUENCE_OF_random_fill, 0 /* Use generic outmost tag fetcher */ }; diff --git a/src/asn1/asn1c/constr_SEQUENCE_OF.h b/src/asn1/asn1c/constr_SEQUENCE_OF.h index cc288f29..fb15dd97 100644 --- a/src/asn1/asn1c/constr_SEQUENCE_OF.h +++ b/src/asn1/asn1c/constr_SEQUENCE_OF.h @@ -21,6 +21,5 @@ extern asn_TYPE_operation_t asn_OP_SEQUENCE_OF; #define SEQUENCE_OF_print SET_OF_print #define SEQUENCE_OF_constraint SET_OF_constraint #define SEQUENCE_OF_decode_ber SET_OF_decode_ber -#define SEQUENCE_OF_random_fill SET_OF_random_fill #endif /* _CONSTR_SET_OF_H_ */ diff --git a/src/asn1/asn1c/constr_SET_OF.c b/src/asn1/asn1c/constr_SET_OF.c index e0cb57f8..ef4b3fee 100644 --- a/src/asn1/asn1c/constr_SET_OF.c +++ b/src/asn1/asn1c/constr_SET_OF.c @@ -822,93 +822,5 @@ asn_TYPE_operation_t asn_OP_SET_OF = { SET_OF_decode_ber, SET_OF_encode_der, SET_OF_encode_xer, - SET_OF_random_fill, 0 /* Use generic outmost tag fetcher */ }; - - -asn_random_fill_result_t -SET_OF_random_fill(const asn_TYPE_descriptor_t *td, void **sptr, - const asn_encoding_constraints_t *constraints, - size_t max_length) { - const asn_SET_OF_specifics_t *specs = - (const asn_SET_OF_specifics_t *)td->specifics; - asn_random_fill_result_t res_ok = {ARFILL_OK, 0}; - asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0}; - asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0}; - const asn_TYPE_member_t *elm = td->elements; - void *st = *sptr; - long max_elements = 5; - long slb = 0; /* Lower size bound */ - long sub = 0; /* Upper size bound */ - size_t rnd_len; - - if(max_length == 0) return result_skipped; - - if(st == NULL) { - st = (*sptr = CALLOC(1, specs->struct_size)); - if(st == NULL) { - return result_failed; - } - } - - switch(asn_random_between(0, 6)) { - case 0: max_elements = 0; break; - case 1: max_elements = 1; break; - case 2: max_elements = 5; break; - case 3: max_elements = max_length; break; - case 4: max_elements = max_length / 2; break; - case 5: max_elements = max_length / 4; break; - default: break; - } - sub = slb + max_elements; - - /* Bias towards edges of allowed space */ - switch(asn_random_between(-1, 4)) { - default: - case -1: - case 0: - rnd_len = asn_random_between(slb, sub); - break; - case 1: - if(slb < sub) { - rnd_len = asn_random_between(slb + 1, sub); - break; - } - /* Fall through */ - case 2: - rnd_len = asn_random_between(slb, slb); - break; - case 3: - if(slb < sub) { - rnd_len = asn_random_between(slb, sub - 1); - break; - } - /* Fall through */ - case 4: - rnd_len = asn_random_between(sub, sub); - break; - } - - for(; rnd_len > 0; rnd_len--) { - asn_anonymous_set_ *list = _A_SET_FROM_VOID(st); - void *ptr = 0; - asn_random_fill_result_t tmpres = elm->type->op->random_fill( - elm->type, &ptr, &elm->encoding_constraints, - (max_length > res_ok.length ? max_length - res_ok.length : 0) - / rnd_len); - switch(tmpres.code) { - case ARFILL_OK: - ASN_SET_ADD(list, ptr); - res_ok.length += tmpres.length; - break; - case ARFILL_SKIPPED: - break; - case ARFILL_FAILED: - assert(ptr == 0); - return tmpres; - } - } - - return res_ok; -} diff --git a/src/asn1/asn1c/constr_SET_OF.h b/src/asn1/asn1c/constr_SET_OF.h index 785b2c0c..ee09914e 100644 --- a/src/asn1/asn1c/constr_SET_OF.h +++ b/src/asn1/asn1c/constr_SET_OF.h @@ -28,7 +28,6 @@ asn_constr_check_f SET_OF_constraint; ber_type_decoder_f SET_OF_decode_ber; der_type_encoder_f SET_OF_encode_der; xer_type_encoder_f SET_OF_encode_xer; -asn_random_fill_f SET_OF_random_fill; extern asn_TYPE_operation_t asn_OP_SET_OF; #endif /* CONSTR_SET_OF_H */ diff --git a/src/asn1/asn1c/constr_TYPE.h b/src/asn1/asn1c/constr_TYPE.h index 26b3fa59..e1d9c982 100644 --- a/src/asn1/asn1c/constr_TYPE.h +++ b/src/asn1/asn1c/constr_TYPE.h @@ -34,7 +34,6 @@ typedef struct asn_struct_ctx_s { #include "asn1/asn1c/der_encoder.h" /* Distinguished Encoding Rules encoder */ #include "asn1/asn1c/xer_encoder.h" /* Encoder into XER (XML, text) */ #include "asn1/asn1c/constraints.h" /* Subtype constraints support */ -#include "asn1/asn1c/asn_random_fill.h" /* Random structures support */ /* * Free the structure according to its specification. @@ -132,7 +131,6 @@ typedef struct asn_TYPE_operation_s { ber_type_decoder_f *ber_decoder; /* Generic BER decoder */ der_type_encoder_f *der_encoder; /* Canonical DER encoder */ xer_type_encoder_f *xer_encoder; /* [Canonical] XER encoder */ - asn_random_fill_f *random_fill; /* Initialize with a random value */ asn_outmost_tag_f *outmost_tag; /* */ } asn_TYPE_operation_t; -- 2.47.3