Method: Krypt::ASN1::ASN1Data#infinite_length=

Defined in:
ext/krypt/core/krypt_asn1.c

#infinite_length=(bool) ⇒ Boolean

  • bool: either true or false, depending on whether the value shall be

encoded using infinite length encoding or not

Set a Boolean indicating whether the encoding shall be infinite length or not. In DER, every value has a finite length associated with it. But in scenarios where large amounts of data need to be transferred, it might be desirable to have some kind of streaming support available. For example, huge OCTET STRINGs are preferably sent in smaller-sized chunks, each at a time. This is possible in BER by setting the length bytes of an encoding to zero and thus indicating that the following value will be sent in chunks. Infinite length encodings are always constructed. The end of such a stream of chunks is indicated by sending a EndOfContents value. SETs and SEQUENCEs may use an infinite length encoding, but also primitive types such as e.g. OCTET STRINGS or BIT STRINGS may leverage this functionality (cf. ITU-T X.690).

Returns:

  • (Boolean)


776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
# File 'ext/krypt/core/krypt_asn1.c', line 776

static VALUE
krypt_asn1_data_set_inf_length(VALUE self, VALUE inf_length)
{
    krypt_asn1_data *data;
    krypt_asn1_header *header;
    int new_inf;

    int_asn1_data_get(self, data);

    header = data->object->header;
    new_inf = RTEST(inf_length) ? 1 : 0;
    if (header->is_infinite == new_inf)
  return inf_length;

    header->is_infinite = new_inf;
    int_invalidate_length(header);
    
    int_asn1_data_set_modified(data, 1);
    int_asn1_data_set_infinite_length(self, new_inf ? Qtrue : Qfalse);

    return inf_length;
}