Class: OpenSSL::ASN1::Constructive
- Includes:
- Enumerable
- Defined in:
- ossl_asn1.c
Instance Method Summary collapse
Constructor Details
#initialize(*args) ⇒ Object
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 |
# File 'ossl_asn1.c', line 866 static VALUE ossl_asn1_initialize(int argc, VALUE *argv, VALUE self) { VALUE value, tag, tagging, tag_class; rb_scan_args(argc, argv, "13", &value, &tag, &tagging, &tag_class); if(argc > 1){ if(NIL_P(tag)) ossl_raise(eASN1Error, "must specify tag number"); if(NIL_P(tagging)) tagging = ID2SYM(sEXPLICIT); if(!SYMBOL_P(tagging)) ossl_raise(eASN1Error, "invalid tag default"); if(NIL_P(tag_class)) tag_class = ID2SYM(sCONTEXT_SPECIFIC); if(!SYMBOL_P(tag_class)) ossl_raise(eASN1Error, "invalid tag class"); if(SYM2ID(tagging) == sIMPLICIT && NUM2INT(tag) > 31) ossl_raise(eASN1Error, "tag number for Universal too large"); } else{ tag = INT2NUM(ossl_asn1_default_tag(self)); tagging = Qnil; tag_class = ID2SYM(sUNIVERSAL); } ossl_asn1_set_tag(self, tag); ossl_asn1_set_value(self, value); ossl_asn1_set_tagging(self, tagging); ossl_asn1_set_tag_class(self, tag_class); return self; } |
Instance Method Details
#each ⇒ Object
996 997 998 999 1000 1001 |
# File 'ossl_asn1.c', line 996 static VALUE ossl_asn1cons_each(VALUE self) { rb_ary_each(ossl_asn1_get_value(self)); return self; } |
#to_der ⇒ Object
962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 |
# File 'ossl_asn1.c', line 962 static VALUE ossl_asn1cons_to_der(VALUE self) { int tag, tn, tc, explicit; long seq_len, length; unsigned char *p; VALUE value, str; tag = ossl_asn1_default_tag(self); tn = NUM2INT(ossl_asn1_get_tag(self)); tc = ossl_asn1_tag_class(self); explicit = ossl_asn1_is_explicit(self); value = join_der(ossl_asn1_get_value(self)); seq_len = ASN1_object_size(1, RSTRING(value)->len, tag); length = ASN1_object_size(1, seq_len, tn); str = rb_str_new(0, length); p = RSTRING(str)->ptr; if(tc == V_ASN1_UNIVERSAL) ASN1_put_object(&p, 1, RSTRING(value)->len, tn, tc); else{ if(explicit){ ASN1_put_object(&p, 1, seq_len, tn, tc); ASN1_put_object(&p, 1, RSTRING(value)->len, tag, V_ASN1_UNIVERSAL); } else ASN1_put_object(&p, 1, RSTRING(value)->len, tn, tc); } memcpy(p, RSTRING(value)->ptr, RSTRING(value)->len); p += RSTRING(value)->len; ossl_str_adjust(str, p); return str; } |