Module: OpenSSL::ASN1::TaggedASN1Data
- Included in:
- Constructive, Primitive
- Defined in:
- lib/openssl/asn1.rb
Instance Attribute Summary collapse
-
#tagging ⇒ Object
May be used as a hint for encoding a value either implicitly or explicitly by setting it either to
:IMPLICIT
or to:EXPLICIT
.
Instance Method Summary collapse
-
#initialize(value, tag = nil, tagging = nil, tag_class = nil) ⇒ Object
:call-seq: OpenSSL::ASN1::Primitive.new(value [, tag, tagging, tag_class ]) => Primitive.
Instance Attribute Details
#tagging ⇒ Object
May be used as a hint for encoding a value either implicitly or explicitly by setting it either to :IMPLICIT
or to :EXPLICIT
. tagging is not set when a ASN.1 structure is parsed using OpenSSL::ASN1.decode.
83 84 85 |
# File 'lib/openssl/asn1.rb', line 83 def tagging @tagging end |
Instance Method Details
#initialize(value, tag = nil, tagging = nil, tag_class = nil) ⇒ Object
:call-seq:
OpenSSL::ASN1::Primitive.new(value [, tag, tagging, tag_class ]) => Primitive
value: is mandatory.
tag: optional, may be specified for tagged values. If no tag is specified, the UNIVERSAL tag corresponding to the Primitive sub-class is used by default.
tagging: may be used as an encoding hint to encode a value either explicitly or implicitly, see ASN1 for possible values.
tag_class: if tag and tagging are nil
then this is set to :UNIVERSAL
by default. If either tag or tagging are set then :CONTEXT_SPECIFIC
is used as the default. For possible values please cf. ASN1.
Example
int = OpenSSL::ASN1::Integer.new(42)
zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT)
private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE)
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/openssl/asn1.rb', line 107 def initialize(value, tag = nil, tagging = nil, tag_class = nil) tag ||= ASN1.take_default_tag(self.class) raise ASN1Error, "must specify tag number" unless tag if tagging raise ASN1Error, "invalid tagging method" unless tagging.is_a?(Symbol) end tag_class ||= tagging ? :CONTEXT_SPECIFIC : :UNIVERSAL raise ASN1Error, "invalid tag class" unless tag_class.is_a?(Symbol) @tagging = tagging super(value ,tag, tag_class) end |