rasn1 0.16.0 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rasn1/errors.rb +6 -0
- data/lib/rasn1/model.rb +9 -2
- data/lib/rasn1/tracer.rb +6 -0
- data/lib/rasn1/types/any.rb +6 -0
- data/lib/rasn1/types/base.rb +7 -0
- data/lib/rasn1/types/bit_string.rb +6 -0
- data/lib/rasn1/types/bmp_string.rb +6 -0
- data/lib/rasn1/types/boolean.rb +6 -0
- data/lib/rasn1/types/choice.rb +6 -0
- data/lib/rasn1/types/constrained.rb +6 -0
- data/lib/rasn1/types/constructed.rb +6 -0
- data/lib/rasn1/types/enumerated.rb +6 -0
- data/lib/rasn1/types/generalized_time.rb +6 -0
- data/lib/rasn1/types/ia5string.rb +6 -0
- data/lib/rasn1/types/integer.rb +6 -0
- data/lib/rasn1/types/null.rb +6 -0
- data/lib/rasn1/types/numeric_string.rb +6 -0
- data/lib/rasn1/types/object_id.rb +6 -0
- data/lib/rasn1/types/octet_string.rb +6 -0
- data/lib/rasn1/types/primitive.rb +6 -0
- data/lib/rasn1/types/printable_string.rb +6 -0
- data/lib/rasn1/types/sequence.rb +6 -0
- data/lib/rasn1/types/sequence_of.rb +6 -0
- data/lib/rasn1/types/set.rb +6 -0
- data/lib/rasn1/types/set_of.rb +6 -0
- data/lib/rasn1/types/universal_string.rb +6 -0
- data/lib/rasn1/types/utc_time.rb +6 -0
- data/lib/rasn1/types/utf8_string.rb +6 -0
- data/lib/rasn1/types/visible_string.rb +6 -0
- data/lib/rasn1/types.rb +6 -0
- data/lib/rasn1/version.rb +7 -1
- data/lib/rasn1/wrapper.rb +6 -0
- data/lib/rasn1.rb +23 -14
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da1e2001517b21898280f0c865be1f0ca74c350d536d2cf80253291819e4536b
|
4
|
+
data.tar.gz: 2becfcf1810e777d9a4dc2f497f1a6fdd67e2dae319f3d15100d66a4566ce410
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2671492ba54d676699a6238ecfd95703b8f2ebbe5cf40adea249f3ef394b1476d4a03bb6da419349753b5ffe05d25c93bdc25aa6614ec5676f2de9b8147dea78
|
7
|
+
data.tar.gz: 3524a58800943b251980b78e5935f1af88a3e5d84ee209bfd910447c00142661f07d4067ffd48892dd767409a92b0dcaca5598e0078520e6b8996d7ab466e909
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[](https://badge.fury.io/rb/rasn1)
|
2
|
-
[](https://ci.codeberg.org/repos/15057)
|
3
3
|
|
4
4
|
# Rasn1
|
5
5
|
|
data/lib/rasn1/errors.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
# Base error class
|
5
11
|
class Error < StandardError; end
|
data/lib/rasn1/model.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
# @abstract
|
5
11
|
# {Model} class is a base class to define ASN.1 models.
|
@@ -378,6 +384,7 @@ module RASN1
|
|
378
384
|
def initialize(args={})
|
379
385
|
@elements = {}
|
380
386
|
generate_root(args)
|
387
|
+
args.delete(:name)
|
381
388
|
lazy_initialize(args) unless args.empty?
|
382
389
|
end
|
383
390
|
|
@@ -386,7 +393,7 @@ module RASN1
|
|
386
393
|
# @param [Symbol] name
|
387
394
|
# @return [Model, Types::Base, Wrapper]
|
388
395
|
# @overload [](idx)
|
389
|
-
# Access an element of root element by its index. Root element must be a {Sequence} or {SequenceOf}.
|
396
|
+
# Access an element of root element by its index. Root element must be a {Types::Sequence} or {Types::SequenceOf}.
|
390
397
|
# @param [Integer] idx
|
391
398
|
# @return [Model, Types::Base, Wrapper]
|
392
399
|
def [](name_or_idx)
|
@@ -561,7 +568,7 @@ module RASN1
|
|
561
568
|
end
|
562
569
|
|
563
570
|
# Initialize an sequence element from an array
|
564
|
-
# @param [Array]
|
571
|
+
# @param [Array] ary
|
565
572
|
# @return [void]
|
566
573
|
def lazy_initialize_array(ary)
|
567
574
|
raise Error, 'Only sequence types may be initialized with an array' unless SEQUENCE_TYPES.any? { |klass| root.is_a?(klass) }
|
data/lib/rasn1/tracer.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
# @private
|
5
11
|
class Tracer
|
data/lib/rasn1/types/any.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 ANY: accepts any types
|
data/lib/rasn1/types/base.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# @abstract This is base class for all ASN.1 types.
|
@@ -95,6 +101,7 @@ module RASN1
|
|
95
101
|
# Parse a DER or BER string
|
96
102
|
# @param [String] der_or_ber string to parse
|
97
103
|
# @param [Hash] options
|
104
|
+
# @return [Base]
|
98
105
|
# @option options [Boolean] :ber if +true+, parse a BER string, else a DER one
|
99
106
|
# @note More options are supported. See {Base#initialize}.
|
100
107
|
def self.parse(der_or_ber, options={})
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 Bit String
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 BmpString
|
data/lib/rasn1/types/boolean.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 Boolean
|
data/lib/rasn1/types/choice.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# A ASN.1 CHOICE is a choice between different types.
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# Mixin to add constraints on a RASN1 type.
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# @abstract This class SHOULD be used as base class for all ASN.1 primitive
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 Enumerated
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
require 'strptime'
|
4
10
|
|
5
11
|
module RASN1
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 IA5 String
|
data/lib/rasn1/types/integer.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 Integer
|
data/lib/rasn1/types/null.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 Null
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 Numeric String
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 Object ID
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 Octet String
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# @abstract This class SHOULD be used as base class for all ASN.1 primitive
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 Printable String
|
data/lib/rasn1/types/sequence.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 sequence
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 SEQUENCE OF
|
data/lib/rasn1/types/set.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 set
|
data/lib/rasn1/types/set_of.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 SET OF
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 UniversalString
|
data/lib/rasn1/types/utc_time.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
require 'date'
|
4
10
|
|
5
11
|
module RASN1
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# ASN.1 UTF8 String
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
module Types
|
5
11
|
# Create VisibleString as a Constrained subclass of IA5String
|
data/lib/rasn1/types.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
require_relative 'types/constrained'
|
4
10
|
|
5
11
|
module RASN1
|
data/lib/rasn1/version.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
module RASN1
|
4
10
|
# RASN1 version number
|
5
|
-
VERSION = '0.16.
|
11
|
+
VERSION = '0.16.2'
|
6
12
|
end
|
data/lib/rasn1/wrapper.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
require 'delegate'
|
4
10
|
|
5
11
|
module RASN1
|
data/lib/rasn1.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# This file is part of RASN1
|
4
|
+
# See https://codeberg.org/lemontree55/rasn1 for more informations
|
5
|
+
# Copyright (C) 2016-2024 Sylvain Daubert <sylvain.daubert@laposte.net>
|
6
|
+
# Copyright (C) 2024 LemonTree55 <lenontree@proton.me>
|
7
|
+
# This program is published under MIT license.
|
8
|
+
|
3
9
|
require_relative 'rasn1/version'
|
4
10
|
require_relative 'rasn1/errors'
|
5
11
|
require_relative 'rasn1/types'
|
@@ -12,6 +18,7 @@ require_relative 'rasn1/types/visible_string'
|
|
12
18
|
|
13
19
|
# Rasn1 is a pure ruby library to parse, decode and encode ASN.1 data.
|
14
20
|
# @author Sylvain Daubert
|
21
|
+
# @author LemonTree
|
15
22
|
module RASN1
|
16
23
|
# @private
|
17
24
|
CONTAINER_CLASSES = [Types::Sequence, Types::Set].freeze
|
@@ -25,22 +32,24 @@ module RASN1
|
|
25
32
|
# generate {Types::Base} objects.
|
26
33
|
# @param [String] der binary string to parse
|
27
34
|
# @param [Boolean] ber if +true+, decode a BER string, else a DER one
|
28
|
-
# @return [Types::Base]
|
35
|
+
# @return [Types::Base, Array[Types::Base]]
|
29
36
|
def self.parse(der, ber: false) # rubocop:disable Metrics/AbcSize
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
result = []
|
38
|
+
until der.nil? || der.empty?
|
39
|
+
type = Types.id2type(der)
|
40
|
+
size = type.parse!(der, ber: ber)
|
41
|
+
|
42
|
+
if CONTAINER_CLASSES.include?(type.class)
|
43
|
+
RASN1.tracer.tracing_level += 1 unless RASN1.tracer.nil?
|
44
|
+
content = self.parse(type.value)
|
45
|
+
type.value = content.is_a?(Array) ? content : [content]
|
46
|
+
RASN1.tracer.tracing_level -= 1 unless RASN1.tracer.nil?
|
40
47
|
end
|
41
|
-
|
42
|
-
|
48
|
+
|
49
|
+
result << type
|
50
|
+
der = der[size..]
|
43
51
|
end
|
44
|
-
|
52
|
+
|
53
|
+
result.size == 1 ? result[0] : result
|
45
54
|
end
|
46
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rasn1
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LemonTree55
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: strptime
|
@@ -70,14 +70,13 @@ files:
|
|
70
70
|
- lib/rasn1/types/visible_string.rb
|
71
71
|
- lib/rasn1/version.rb
|
72
72
|
- lib/rasn1/wrapper.rb
|
73
|
-
homepage: https://
|
73
|
+
homepage: https://codeberg.org/lemontree55/rasn1
|
74
74
|
licenses:
|
75
75
|
- MIT
|
76
76
|
metadata:
|
77
|
-
homepage_uri: https://
|
78
|
-
source_code_uri: https://
|
79
|
-
bug_tracker_uri: https://
|
80
|
-
documentation_uri: https://www.rubydoc.info/gems/rasn1
|
77
|
+
homepage_uri: https://codeberg.org/lemontree55/rasn1
|
78
|
+
source_code_uri: https://codeberg.org/lemontree55/rasn1
|
79
|
+
bug_tracker_uri: https://codeberg.org/lemontree55/rasn1/issues
|
81
80
|
post_install_message:
|
82
81
|
rdoc_options:
|
83
82
|
- "--title"
|