class RASN1::Types::PrintableString

ASN.1 Printable String @author Sylvain Daubert

Constants

ID

PrintableString id value

Public Class Methods

type() click to toggle source

Get ASN.1 type @return [String]

# File lib/rasn1/types/printable_string.rb, line 13
def self.type
  'PrintableString'
end

Private Instance Methods

check_characters() click to toggle source
# File lib/rasn1/types/printable_string.rb, line 29
def check_characters
  m = @value.to_s.match(%r{([^a-zA-Z0-9 '=()+,\-./:?])})
  raise ASN1Error, "PRINTABLE STRING #{@name}: invalid character: '#{m[1]}'" if m
end
der_to_value(der, ber: false) click to toggle source
Calls superclass method
# File lib/rasn1/types/printable_string.rb, line 24
def der_to_value(der, ber: false)
  super
  check_characters
end
value_to_der() click to toggle source
# File lib/rasn1/types/printable_string.rb, line 19
def value_to_der
  check_characters
  @value.to_s.force_encoding('BINARY')
end