module OpenSSL::ASN1::TaggedASN1Data
Attributes
tagging[RW]
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
.
Public Class Methods
OpenSSL::ASN1::Primitive.new(value [, tag, tagging, tag_class ]) → Primitive
click to toggle source
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)
Calls superclass method
# 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