Method: Krypt::ASN1::ASN1Data#tag_class=

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

#tag_class=(sym) ⇒ Symbol

  • sym: A Symbol representing the tag class of this ASN1Data.

Must not be nil. See ASN1Data for possible values.

Returns:

  • (Symbol)


704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
# File 'ext/krypt/core/krypt_asn1.c', line 704

static VALUE
krypt_asn1_data_set_tag_class(VALUE self, VALUE tag_class)
{
    krypt_asn1_data *data;
    krypt_asn1_header *header;
    int new_tag_class;
    ID new_tc, old_tc;

    int_asn1_data_get(self, data);

    new_tc = SYM2ID(tag_class);
    old_tc = SYM2ID(int_asn1_data_get_tag_class(self));
    if (new_tc == old_tc)
	return tag_class;
    if (new_tc == sKrypt_TC_EXPLICIT && data->default_tag == -1)
	rb_raise(eKryptASN1Error, "Cannot explicitly tag value with unknown default tag");

    header = data->object->header;
    if ((new_tag_class = krypt_asn1_tag_class_for_id(new_tc)) == KRYPT_ERR)
        rb_raise(eKryptASN1Error, "Cannot set tag class");

    header->tag_class = new_tag_class;
    int_invalidate_tag(header);

    if (data->update_cb)
	data->update_cb(data);

    if (int_asn1_handle_explicit_tagging(self, data, new_tc) == KRYPT_ERR)
	rb_raise(eKryptASN1Error, "Tagging explicitly failed");

    int_asn1_data_set_modified(data, 1);
    int_asn1_data_set_tag_class(self, tag_class);

    return tag_class;
}