Method: OpenSSL::ASN1.traverse
- Defined in:
- ossl_asn1.c
.OpenSSL::ASN1.traverse(asn1) ⇒ nil
If a block is given, it prints out each of the elements encountered. Block parameters are (in that order):
-
depth: The recursion depth, plus one with each constructed value being encountered (Integer)
-
offset: Current byte offset (Integer)
-
header length: Combined length in bytes of the Tag and Length headers. (Integer)
-
length: The overall remaining length of the entire data (Integer)
-
constructed: Whether this value is constructed or not (Boolean)
-
tag_class: Current tag class (Symbol)
-
tag: The current tag number (Integer)
Example
der = File.binread('asn1data.der')
OpenSSL::ASN1.traverse(der) do | depth, offset, header_len, length, constructed, tag_class, tag|
puts "Depth: #{depth} Offset: #{offset} Length: #{length}"
puts "Header length: #{header_len} Tag: #{tag} Tag class: #{tag_class} Constructed: #{constructed}"
end
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 |
# File 'ossl_asn1.c', line 929
static VALUE
ossl_asn1_traverse(VALUE self, VALUE obj)
{
unsigned char *p;
VALUE tmp;
long len, read = 0, offset = 0;
obj = ossl_to_der_if_possible(obj);
tmp = rb_str_new4(StringValue(obj));
p = (unsigned char *)RSTRING_PTR(tmp);
len = RSTRING_LEN(tmp);
ossl_asn1_decode0(&p, len, &offset, 0, 1, &read);
RB_GC_GUARD(tmp);
int_ossl_decode_sanity_check(len, read, offset);
return Qnil;
}
|