Sha256: 0eb760e59716d5e22d4d3be863f4be602f11169d4b2b420a10ab4f621c04bf82

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

module PolyPseudo
  module PseudoId
    def self.from_asn1(encoded)
      asn1 = OpenSSL::ASN1.decode(Base64.decode64(encoded))

      case asn1.value[0].value.to_s
      when /\A.*1\.2\.1\Z/
        Identity.from_asn1(asn1)
      when /\A.*1\.2\.2\Z/
        Pseudonym.from_asn1(asn1)
      when /\A.*1\.2\.3\Z/
        Identity.from_asn1(asn1.value[1].value[0])
      when /\A.*1\.2\.4\Z/
        Pseudonym.from_asn1(asn1.value[1].value[0])
      else
        raise "Invalid type"
      end
    end

    attr_reader :type, :schema_version, :schema_key_version, :creator, :recipient, :recipient_key_set_version, :point_1, :point_2, :point_3

    def initialize(attributes)
      @type                      = attributes["Type"]
      @schema_version            = attributes["SchemaVersion"]
      @schema_key_version        = attributes["SchemaKeyVersion"]
      @recipient                 = attributes["Creator"]
      @recipient                 = attributes["Recipient"]
      @recipient_key_set_version = attributes["RecipientKeySetVersion"]
      @point_1                   = attributes["Point1"]
      @point_2                   = attributes["Point2"]
      @point_3                   = attributes["Point3"]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
poly_pseudo-0.2.0 lib/poly_pseudo/pseudo_id.rb