fix_cons_encode_inf.diff

Martin Bosslet, 01/26/2011 09:46 AM

Download (2.25 KB)

View differences:

ruby/ext/openssl/ossl_asn1.c (working copy)
1017 1017
    int found_prim = 0;
1018 1018
    long seq_len, length;
1019 1019
    unsigned char *p;
1020
    VALUE value, str, inf_length, ary, example;
1020
    VALUE value, str, inf_length, ary, example = Qnil;
1021 1021

  
1022 1022
    tn = NUM2INT(ossl_asn1_get_tag(self));
1023 1023
    tc = ossl_asn1_tag_class(self);
1024 1024
    inf_length = ossl_asn1_get_infinite_length(self);
1025 1025
    if (inf_length == Qtrue) {
1026 1026
        constructed = 2;
1027
        if (CLASS_OF(self) == cASN1Sequence ||
1028
            CLASS_OF(self) == cASN1Set) {
1027
	if (rb_obj_is_kind_of(self, cASN1Sequence) ||
1028
            rb_obj_is_kind_of(self, cASN1Set)){
1029 1029
            tag = ossl_asn1_default_tag(self);
1030 1030
        }
1031
        else { /*BIT_STRING OR OCTET_STRING*/
1031
	else { /*must be a constructive encoding of a primitive value*/
1032
	    if (!rb_obj_is_kind_of(self, cASN1Constructive)){
1033
		ossl_raise(eASN1Error, "invalid constructed encoding");
1034
                return Qnil; /* dummy */
1035
            }
1032 1036
            ary = ossl_asn1_get_value(self);
1033 1037
            /* Recursively descend until a primitive value is found.
1034 1038
               The overall value of the entire constructed encoding
ruby/test/openssl/test_asn1.rb (working copy)
430 430
    end
431 431
  end
432 432
  
433
  def test_encode_subclass_sequence
434
    sub = Class.new(OpenSSL::ASN1::Sequence)
435
    instance = sub.new([OpenSSL::ASN1::EndOfContent.new])
436
    instance.infinite_length = true
437
    puts instance.to_der
438
  end
439
  
440
  def test_encode_subclass_set
441
    sub = Class.new(OpenSSL::ASN1::Set)
442
    instance = sub.new([OpenSSL::ASN1::EndOfContent.new])
443
    instance.infinite_length = true
444
    puts instance.to_der
445
  end
446
  
433 447
end if defined?(OpenSSL)