hanko_xml 0.1.0-x86_64-linux

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.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +44 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +222 -0
  5. data/THIRD_PARTY_LICENSES.md +392 -0
  6. data/dependencies.yml +87 -0
  7. data/lib/hanko_xml/3.1/hanko_xml.so +0 -0
  8. data/lib/hanko_xml/3.2/hanko_xml.so +0 -0
  9. data/lib/hanko_xml/3.3/hanko_xml.so +0 -0
  10. data/lib/hanko_xml/3.4/hanko_xml.so +0 -0
  11. data/lib/hanko_xml/algorithms.rb +228 -0
  12. data/lib/hanko_xml/dom.rb +137 -0
  13. data/lib/hanko_xml/errors.rb +132 -0
  14. data/lib/hanko_xml/exc-c14n.xsd +26 -0
  15. data/lib/hanko_xml/input.rb +50 -0
  16. data/lib/hanko_xml/key.rb +213 -0
  17. data/lib/hanko_xml/key_info.rb +67 -0
  18. data/lib/hanko_xml/native_version.rb +75 -0
  19. data/lib/hanko_xml/nokogiri_ext.rb +34 -0
  20. data/lib/hanko_xml/placement.rb +127 -0
  21. data/lib/hanko_xml/policy.rb +502 -0
  22. data/lib/hanko_xml/reference.rb +49 -0
  23. data/lib/hanko_xml/signature_info.rb +134 -0
  24. data/lib/hanko_xml/signed_document.rb +155 -0
  25. data/lib/hanko_xml/signer.rb +572 -0
  26. data/lib/hanko_xml/template.rb +150 -0
  27. data/lib/hanko_xml/transform.rb +87 -0
  28. data/lib/hanko_xml/verification.rb +377 -0
  29. data/lib/hanko_xml/verifier.rb +694 -0
  30. data/lib/hanko_xml/version.rb +5 -0
  31. data/lib/hanko_xml/xades/verifier.rb +319 -0
  32. data/lib/hanko_xml/xades.rb +287 -0
  33. data/lib/hanko_xml/xml.rb +93 -0
  34. data/lib/hanko_xml/xmldsig-core-schema.xsd +332 -0
  35. data/lib/hanko_xml.rb +122 -0
  36. data/sig/hanko_xml/key.rbs +48 -0
  37. data/sig/hanko_xml/native.rbs +12 -0
  38. data/sig/hanko_xml/native_version.rbs +13 -0
  39. data/sig/hanko_xml/nokogiri_ext.rbs +23 -0
  40. data/sig/hanko_xml/placement.rbs +27 -0
  41. data/sig/hanko_xml/policy.rbs +83 -0
  42. data/sig/hanko_xml/reference.rbs +36 -0
  43. data/sig/hanko_xml/signed_document.rbs +66 -0
  44. data/sig/hanko_xml/signer.rbs +50 -0
  45. data/sig/hanko_xml/template.rbs +41 -0
  46. data/sig/hanko_xml/verification.rbs +100 -0
  47. data/sig/hanko_xml/verifier.rbs +45 -0
  48. data/sig/hanko_xml/xades.rbs +70 -0
  49. data/sig/hanko_xml.rbs +62 -0
  50. metadata +104 -0
@@ -0,0 +1,83 @@
1
+ module HankoXml
2
+ class Policy
3
+ type limit = Integer | Float
4
+
5
+ FIELDS: Array[Symbol]
6
+ STRICT_DEFAULTS: Hash[Symbol, untyped]
7
+
8
+ attr_reader signature_methods: Array[Symbol | String]
9
+ attr_reader digest_methods: Array[Symbol | String]
10
+ attr_reader canonicalization_methods: Array[Symbol | String]
11
+ attr_reader transforms: Array[Symbol | String]
12
+ attr_reader allow_external_references: bool
13
+ attr_reader allow_retrieval_method: bool
14
+ attr_reader allow_same_document_xpointer: bool
15
+ attr_reader max_references: limit
16
+ attr_reader require_references: bool
17
+ attr_reader require_signed_root: bool
18
+ attr_reader reject_duplicate_ids: bool
19
+ attr_reader max_document_size: limit
20
+ attr_reader max_transforms_per_reference: limit
21
+ attr_reader min_rsa_key_bits: Integer
22
+ attr_reader min_ec_key_bits: Integer
23
+ attr_reader min_dsa_key_bits: Integer
24
+ attr_reader allow_hmac: bool
25
+ attr_reader check_certificate_validity: bool
26
+ attr_reader clock_skew: Numeric
27
+ attr_reader require_signing_key_usage: bool
28
+ attr_reader schema: Symbol | String | Nokogiri::XML::Schema | nil
29
+
30
+ def self.strict: () -> instance
31
+ def self.fragment: () -> instance
32
+ def self.legacy_sha1: () -> instance
33
+ def self.xades: () -> instance
34
+ def self.interop: () -> instance
35
+ def self.permissive: () -> instance
36
+
37
+ def initialize: (
38
+ ?signature_methods: Array[Symbol | String],
39
+ ?digest_methods: Array[Symbol | String],
40
+ ?canonicalization_methods: Array[Symbol | String],
41
+ ?transforms: Array[Symbol | String],
42
+ ?allow_external_references: bool,
43
+ ?allow_retrieval_method: bool,
44
+ ?allow_same_document_xpointer: bool,
45
+ ?max_references: limit,
46
+ ?require_references: bool,
47
+ ?require_signed_root: bool,
48
+ ?reject_duplicate_ids: bool,
49
+ ?max_document_size: limit,
50
+ ?max_transforms_per_reference: limit,
51
+ ?min_rsa_key_bits: Integer,
52
+ ?min_ec_key_bits: Integer,
53
+ ?min_dsa_key_bits: Integer,
54
+ ?allow_hmac: bool,
55
+ ?check_certificate_validity: bool,
56
+ ?clock_skew: Numeric,
57
+ ?require_signing_key_usage: bool,
58
+ ?schema: Symbol | String | Nokogiri::XML::Schema | nil
59
+ ) -> void
60
+
61
+ def with: (**untyped overrides) -> instance
62
+ def to_h: () -> Hash[Symbol, untyped]
63
+
64
+ def violations: (
65
+ HankoXml::SignatureInfo signature_info,
66
+ ?document: Nokogiri::XML::Document?,
67
+ ?id_attributes: Array[String | [String, String]]?,
68
+ ?xml_bytes: String?
69
+ ) -> Array[HankoXml::PolicyError]
70
+
71
+ def enforce!: (
72
+ HankoXml::SignatureInfo signature_info,
73
+ ?document: Nokogiri::XML::Document?,
74
+ ?id_attributes: Array[String | [String, String]]?,
75
+ ?xml_bytes: String?
76
+ ) -> void
77
+
78
+ def enforce_document_size!: (Integer bytesize) -> void
79
+ def allows?: (Symbol slot, String | Symbol uri_or_name) -> bool
80
+ def enforce_algorithm!: (Symbol slot, String | Symbol uri_or_name) -> void
81
+ def enforce_key_size!: (Array[OpenSSL::PKey::PKey | OpenSSL::X509::Certificate] | OpenSSL::PKey::PKey | OpenSSL::X509::Certificate keys) -> void
82
+ end
83
+ end
@@ -0,0 +1,36 @@
1
+ module HankoXml
2
+ class Transform
3
+ EXC_C14N_NS: String
4
+
5
+ attr_reader name: Symbol?
6
+ attr_reader uri: String
7
+ attr_reader xpath: String?
8
+ attr_reader inclusive_prefixes: Array[String]
9
+
10
+ def self.exc_c14n: (?inclusive_prefixes: Array[String | Symbol], ?with_comments: bool) -> instance
11
+ def self.c14n: () -> instance
12
+ def self.enveloped_signature: () -> instance
13
+ def self.coerce: (instance | Symbol | String input) -> instance
14
+
15
+ def initialize: (String | Symbol algorithm, ?xpath: String?, ?inclusive_prefixes: Array[String | Symbol]) -> void
16
+ def enveloped_signature?: () -> bool
17
+ def secure?: () -> bool
18
+ end
19
+
20
+ class Reference
21
+ attr_reader uri: String
22
+ attr_reader transforms: Array[Transform]
23
+ attr_reader digest_method: Symbol | String
24
+ attr_reader id: String?
25
+ attr_reader type: String?
26
+
27
+ def self.coerce: (instance | String | Hash[Symbol, untyped] input) -> instance
28
+
29
+ def initialize: (?uri: String?, ?transforms: Array[Transform | Symbol | String], ?digest_method: Symbol | String,
30
+ ?id: String?, ?type: String?) -> void
31
+ def digest_method_uri: () -> String?
32
+ def enveloped?: () -> bool
33
+ def fragment?: () -> bool
34
+ def target_id: () -> String?
35
+ end
36
+ end
@@ -0,0 +1,66 @@
1
+ module HankoXml
2
+ class SignedDocument
3
+ READ_METHODS: Array[Symbol]
4
+ MUTATORS: Array[Symbol]
5
+
6
+ # nil when signed without Nokogiri (bytes only).
7
+ attr_reader document: Nokogiri::XML::Document?
8
+
9
+ def self.from_bytes: (String bytes) -> instance
10
+ def initialize: (Nokogiri::XML::Document document) -> void
11
+ def to_xml: (?declaration: bool) -> String
12
+ def to_s: () -> String
13
+ def bytes: () -> String
14
+ def write_to: (_Writer io, ?declaration: bool) -> untyped
15
+ def signatures: () -> Nokogiri::XML::NodeSet
16
+ # Every keyword of Verifier#initialize (certificate:, store:, policy:, schema:, signature:, ...).
17
+ def valid?: (**untyped kwargs) -> bool
18
+ def inspect: () -> String
19
+
20
+ # Read-only Nokogiri methods, delegated to #document (READ_METHODS).
21
+ # Without Nokogiri they raise NokogiriRequired.
22
+ def at: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
23
+ def at_css: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
24
+ def at_xpath: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
25
+ def css: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
26
+ def search: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
27
+ def xpath: (*untyped args, **untyped kwargs) ?{ (*untyped) -> untyped } -> untyped
28
+ def root: () -> untyped
29
+ def encoding: () -> String?
30
+ def errors: () -> Array[untyped]
31
+ def namespaces: () -> Hash[String, String]
32
+ def children: () -> untyped
33
+ def version: () -> String?
34
+ def url: () -> String?
35
+
36
+ # Mutators (MUTATORS): each raises FrozenSignatureError (S-17).
37
+ def <<: (*untyped) -> bot
38
+ def add_child: (*untyped) -> bot
39
+ def add_next_sibling: (*untyped) -> bot
40
+ def add_previous_sibling: (*untyped) -> bot
41
+ def after: (*untyped) -> bot
42
+ def before: (*untyped) -> bot
43
+ def children=: (*untyped) -> bot
44
+ def content=: (*untyped) -> bot
45
+ def inner_html=: (*untyped) -> bot
46
+ def native_content=: (*untyped) -> bot
47
+ def parent=: (*untyped) -> bot
48
+ def remove: (*untyped) -> bot
49
+ def remove_attribute: (*untyped) -> bot
50
+ def replace: (*untyped) -> bot
51
+ def root=: (*untyped) -> bot
52
+ def set_attribute: (*untyped) -> bot
53
+ def []=: (*untyped) -> bot
54
+ def delete: (*untyped) -> bot
55
+ def encoding=: (*untyped) -> bot
56
+ def unlink: (*untyped) -> bot
57
+ def add_namespace: (*untyped) -> bot
58
+ def add_namespace_definition: (*untyped) -> bot
59
+ def default_namespace=: (*untyped) -> bot
60
+ def do_xinclude: (*untyped) -> bot
61
+ def canonicalize!: (*untyped) -> bot
62
+ def remove_namespaces!: (*untyped) -> bot
63
+ def swap: (*untyped) -> bot
64
+ def wrap: (*untyped) -> bot
65
+ end
66
+ end
@@ -0,0 +1,50 @@
1
+ module HankoXml
2
+ class Signer
3
+ # The setters work only inside the Signer.new block: the Signer is frozen
4
+ # when #initialize returns, after which they raise FrozenError.
5
+ attr_accessor key: Key
6
+ attr_accessor certificate: Key?
7
+ attr_accessor certificates: Array[Key]
8
+ attr_accessor signature_method: Symbol | String
9
+ attr_accessor digest_method: Symbol | String
10
+ attr_accessor canonicalization_method: Symbol | String
11
+ attr_accessor placement: Placement
12
+ attr_accessor references: Array[Reference]
13
+ def key_info=: (Array[KeyInfo::Clause] clauses) -> Array[KeyInfo::Clause]
14
+ attr_accessor id_attributes: Array[String | [String, String]]
15
+ attr_accessor namespaces: Hash[String | Symbol, String]
16
+ attr_accessor signature_id: String?
17
+ attr_accessor policy: Policy
18
+ attr_reader template_mode: Symbol
19
+
20
+ def initialize: (
21
+ key: Key | OpenSSL::PKey::PKey | String | _ToPath,
22
+ ?certificate: (Key | OpenSSL::X509::Certificate | String | _ToPath)?,
23
+ ?certificates: Array[Key | OpenSSL::X509::Certificate | String | _ToPath],
24
+ ?signature_method: Symbol | String,
25
+ ?canonicalization_method: Symbol | String,
26
+ ?digest_method: Symbol | String,
27
+ ?references: Array[Reference | String | Hash[Symbol, untyped]],
28
+ ?key_info: Array[Symbol | Hash[Symbol, String]],
29
+ ?placement: Placement | Symbol,
30
+ ?id_attributes: Array[String | [String, String]],
31
+ ?namespaces: Hash[String | Symbol, String],
32
+ ?signature_id: String?,
33
+ ?policy: Policy,
34
+ ?template: Symbol
35
+ ) ?{ (self) -> void } -> void
36
+
37
+ def sign: (HankoXml::input doc_or_xml, ?force: bool, ?signature: Integer?) -> HankoXml::SignedDocument
38
+ def sign!: (Nokogiri::XML::Node | Nokogiri::XML::Document doc_or_xml, ?force: bool, ?signature: Integer?) -> (Nokogiri::XML::Node | Nokogiri::XML::Document)
39
+ def template: (HankoXml::input doc_or_xml) -> Nokogiri::XML::Node
40
+ def reference: (?String? uri, **untyped kwargs) -> Array[Reference]
41
+ def key_info: (*Symbol | Hash[Symbol, String] clauses, ?name: String?) -> Array[KeyInfo::Clause]
42
+ | () -> Array[KeyInfo::Clause]
43
+ def to_h: () -> Hash[Symbol, untyped]
44
+ def inspect: () -> String
45
+
46
+ private
47
+ def node_signed?: (Nokogiri::XML::Node sig_node) -> bool
48
+ def write_back_signature: (Nokogiri::XML::Document doc, String signed_bytes, Integer index, Nokogiri::XML::Node caller_sig_node) -> void
49
+ end
50
+ end
@@ -0,0 +1,41 @@
1
+ module HankoXml
2
+ class Template
3
+ # Builds the unsigned <ds:Signature> for +config+ (a Signer), in +doc+'s
4
+ # namespace context. Needs Nokogiri.
5
+ def self.build: (Nokogiri::XML::Document doc, Signer config) -> Nokogiri::XML::Node
6
+ def initialize: (Nokogiri::XML::Document doc, Signer config) -> void
7
+ def build: () -> Nokogiri::XML::Node
8
+ end
9
+
10
+ module Algorithms
11
+ type slot = :canonicalization | :digest | :signature | :transform
12
+
13
+ class Entry < Struct[untyped]
14
+ attr_accessor slot: Symbol
15
+ attr_accessor name: Symbol
16
+ attr_accessor uri: String
17
+ attr_accessor secure: bool
18
+ def secure?: () -> bool
19
+ end
20
+
21
+ # Name/URI lookup for one algorithm slot.
22
+ class Table
23
+ def register: (Symbol | String name, String uri, secure: bool, ?replace: bool) -> Entry
24
+ def []: (Symbol | String name_or_uri) -> Entry?
25
+ def uri_for: (Symbol | String name_or_uri) -> String?
26
+ def name_for: (String uri) -> Symbol?
27
+ def secure?: (Symbol | String name_or_uri) -> bool
28
+ def names: () -> Array[Symbol]
29
+ end
30
+
31
+ def self.canonicalization: () -> Table
32
+ def self.digest: () -> Table
33
+ def self.signature: () -> Table
34
+ def self.transform: () -> Table
35
+
36
+ def self.register: (slot | String slot, Symbol | String name, String uri, secure: bool, ?replace: bool) -> Entry
37
+ def self.uri_for: (slot | String slot, Symbol | String name_or_uri) -> String?
38
+ def self.name_for: (slot | String slot, String uri) -> Symbol?
39
+ def self.secure?: (slot | String slot, Symbol | String name_or_uri) -> bool
40
+ end
41
+ end
@@ -0,0 +1,100 @@
1
+ module HankoXml
2
+ # What <SignedInfo> claims, from Native.inspect_sig: URIs as Strings.
3
+ # Only its readers are listed: it reaches callers as Verification#signed_info
4
+ # / #signature_info and as Policy#violations' argument, and its constructors
5
+ # are @api private.
6
+ class SignatureInfo
7
+ class ReferenceInfo < Struct[untyped]
8
+ attr_accessor uri: String?
9
+ attr_accessor digest_method: String?
10
+ attr_accessor transforms: Array[String]
11
+ attr_accessor id: String?
12
+ attr_accessor type: String?
13
+ attr_accessor xpath_filters: Array[Hash[Symbol, untyped]]
14
+
15
+ def digest_method_name: () -> Symbol?
16
+ def transform_names: () -> Array[Symbol?]
17
+ def fragment?: () -> bool
18
+ def external?: () -> bool
19
+ def document_uri: () -> String
20
+ def same_document_xpointer?: () -> bool
21
+ def xpath_filter2?: () -> bool
22
+ def signature_exclusion: () -> (:all | :root_children)?
23
+ end
24
+
25
+ attr_reader signature_method: String?
26
+ attr_reader canonicalization_method: String?
27
+ attr_reader signature_count: Integer
28
+ attr_reader key_names: Array[String]
29
+ attr_reader certificates: Array[String]
30
+ attr_reader references: Array[ReferenceInfo]
31
+
32
+ def retrieval_method?: () -> bool
33
+ def signature_method_name: () -> Symbol?
34
+ def canonicalization_method_name: () -> Symbol?
35
+ end
36
+
37
+ class Verification
38
+ class Reference
39
+ attr_reader uri: String
40
+ attr_reader node: Nokogiri::XML::Node?
41
+ attr_reader digest_method: Symbol?
42
+ attr_reader transforms: Array[Symbol?]
43
+ attr_reader errors: Array[DigestMismatch]
44
+ attr_reader signature_exclusion: (:all | :root_children)?
45
+ def valid?: () -> bool
46
+ def enveloped?: () -> bool
47
+ def signature_exclusions: () -> Array[:this | :all | :root_children]
48
+ def to_h: () -> Hash[Symbol, untyped]
49
+ end
50
+
51
+ type algorithm = Symbol | String
52
+
53
+ attr_reader valid: bool
54
+ attr_reader errors: Array[Error]
55
+ attr_reader signature_info: SignatureInfo?
56
+ attr_reader signature_node: Nokogiri::XML::Node?
57
+ attr_reader document: Nokogiri::XML::Document?
58
+ attr_reader signature_element_index: Integer?
59
+ attr_reader certificate: OpenSSL::X509::Certificate?
60
+ attr_reader id_attributes: Array[String | [String, String]]
61
+ attr_reader namespaces: Hash[String, String]
62
+ attr_reader resolver: untyped
63
+ attr_reader references: Array[Reference]
64
+ attr_reader reference_element_indexes: Array[Integer?]?
65
+ attr_reader reference_valid: Array[bool?]?
66
+
67
+ def initialize: (
68
+ valid: bool,
69
+ errors: Array[Error],
70
+ signature_info: SignatureInfo?,
71
+ signature_node: Nokogiri::XML::Node?,
72
+ document: Nokogiri::XML::Document?,
73
+ ?certificate: OpenSSL::X509::Certificate?,
74
+ ?id_attributes: Array[String | [String, String]]?,
75
+ ?resolver: untyped,
76
+ ?reference_element_indexes: Array[Integer?]?,
77
+ ?reference_valid: Array[bool?]?,
78
+ ?namespaces: Hash[String | Symbol, String]?,
79
+ ?signature_element_index: Integer?,
80
+ ?certificate_chain: Array[OpenSSL::X509::Certificate]?,
81
+ ?root_signature: bool?,
82
+ ?trusted: bool
83
+ ) -> void
84
+
85
+ def valid?: () -> bool
86
+ def signature_method: () -> algorithm?
87
+ def canonicalization_method: () -> algorithm?
88
+ def digest_methods: () -> Array[algorithm]
89
+ def signed?: (Nokogiri::XML::Node node) -> bool
90
+ def signed_nodes: () -> Array[Nokogiri::XML::Node]
91
+ def trusted?: () -> bool
92
+ def signed_info: () -> SignatureInfo?
93
+ def certificate_chain: () -> Array[OpenSSL::X509::Certificate]
94
+ def key_info: () -> KeyInfo::Parsed?
95
+ def covers_root?: () -> bool
96
+ def partial?: () -> bool
97
+ def at_signed: (String xpath, ?Hash[String | Symbol, String]? ns) -> Nokogiri::XML::Node
98
+ def signed: (String xpath, ?Hash[String | Symbol, String]? ns) -> Array[Nokogiri::XML::Node]
99
+ end
100
+ end
@@ -0,0 +1,45 @@
1
+ module HankoXml
2
+ class Verifier
3
+ DEFAULT_SCHEMA_PATH: String
4
+
5
+ # §6.2: a String, a path-like object, an IO, or a Nokogiri document or node.
6
+ type input = HankoXml::input
7
+
8
+ def self.default_schema: () -> Nokogiri::XML::Schema
9
+
10
+ # #103: integrity only; takes every keyword of #initialize but the trust sources.
11
+ def self.without_trust_verification: (**untyped options) -> Verifier
12
+ def without_trust?: () -> bool
13
+
14
+ attr_reader policy: Policy
15
+ attr_reader id_attributes: Array[String | [String, String]]
16
+ attr_reader namespaces: Hash[String, String]
17
+ attr_reader signature: Symbol | Integer | String | nil
18
+ attr_reader verification_time: Time?
19
+ attr_reader schema: Symbol | String | Nokogiri::XML::Schema | nil
20
+ attr_reader referenced_documents: Hash[String, String]
21
+ attr_reader resolver: untyped
22
+
23
+ def initialize: (
24
+ ?certificate: (Key | OpenSSL::X509::Certificate | String | _ToPath)?,
25
+ ?certificates: Array[Key | OpenSSL::X509::Certificate | String | _ToPath]?,
26
+ ?store: OpenSSL::X509::Store?,
27
+ ?key: (Key | OpenSSL::PKey::PKey | String | _ToPath)?,
28
+ ?keys: Hash[String, Key | OpenSSL::X509::Certificate | String | _ToPath]?,
29
+ ?policy: Policy,
30
+ ?id_attributes: Array[String | [String, String]],
31
+ ?resolver: untyped,
32
+ ?namespaces: Hash[String, String],
33
+ ?signature: Symbol | Integer | String | nil,
34
+ ?verification_time: Time?,
35
+ ?schema: Symbol | String | Nokogiri::XML::Schema | nil,
36
+ ?referenced_documents: Hash[String, String | Nokogiri::XML::Document],
37
+ ?certificate_subject: (String | OpenSSL::X509::Name)?
38
+ ) -> void
39
+
40
+ def verify: (input xml) -> Verification
41
+ def verify!: (input xml, ?allow_untrusted: bool) -> Verification
42
+ def valid?: (input xml) -> bool
43
+ def verify_all: (input xml) -> Array[Verification]
44
+ end
45
+ end
@@ -0,0 +1,70 @@
1
+ module HankoXml
2
+ module Xades
3
+ NS: String
4
+ LEGACY_NAMESPACES: Array[String]
5
+ NAMESPACES: Array[String]
6
+ SIGNED_PROPERTIES_TYPE: String
7
+ VERSIONED_SIGNED_PROPERTIES_TYPES: Hash[String, String]
8
+
9
+ class SignaturePolicy
10
+ attr_reader identifier: String
11
+ attr_reader digest_value: String
12
+ attr_reader digest_method: Symbol | String
13
+ attr_reader description: String?
14
+
15
+ def initialize: (identifier: String, digest_value: String, ?digest_method: Symbol | String, ?description: String?) -> void
16
+ end
17
+
18
+ class DataObjectFormat
19
+ attr_reader mime_type: String?
20
+ attr_reader description: String?
21
+ attr_reader encoding: String?
22
+
23
+ def initialize: (?mime_type: String?, ?description: String?, ?encoding: String?) -> void
24
+ end
25
+
26
+ class Signer < HankoXml::Signer
27
+ attr_reader signing_time: Time?
28
+ attr_reader signature_policy: (SignaturePolicy | :implied)?
29
+ attr_reader claimed_roles: Array[String]
30
+ attr_reader data_object_format: DataObjectFormat?
31
+
32
+ def initialize: (
33
+ ?certificate: (Key | OpenSSL::X509::Certificate | String | _ToPath)?,
34
+ ?signing_time: Time?,
35
+ ?signature_policy: (SignaturePolicy | Hash[Symbol, untyped] | :implied)?,
36
+ ?claimed_roles: Array[String],
37
+ ?data_object_format: (DataObjectFormat | Hash[Symbol, untyped])?,
38
+ ?signature_id: String?,
39
+ ?template: Symbol,
40
+ **untyped
41
+ ) ?{ (self) -> void } -> void
42
+
43
+ def signed_properties_id: () -> String
44
+ end
45
+ end
46
+ end
47
+
48
+ module HankoXml
49
+ class XadesError < VerificationError
50
+ end
51
+
52
+ module Xades
53
+ class SignedProperties
54
+ attr_reader signing_time: Time?
55
+ attr_reader signature_policy: (SignaturePolicy | :implied)?
56
+ attr_reader claimed_roles: Array[String]
57
+ attr_reader data_object_formats: Array[Hash[Symbol, String?]]
58
+ end
59
+
60
+ class Verification < HankoXml::Verification
61
+ attr_reader signed_properties: SignedProperties?
62
+ end
63
+
64
+ class Verifier < HankoXml::Verifier
65
+ def initialize: (?signature_policy: (SignaturePolicy | Hash[Symbol, untyped] | :implied)?, **untyped) -> void
66
+ def verify: (untyped xml) -> Verification
67
+ def verify_all: (untyped xml) -> Array[Verification]
68
+ end
69
+ end
70
+ end
data/sig/hanko_xml.rbs ADDED
@@ -0,0 +1,62 @@
1
+ module HankoXml
2
+ VERSION: String
3
+ NS: Hash[String, String]
4
+
5
+ class Error < StandardError
6
+ PRIVATE_KEY_PEM: Regexp
7
+ FILTERED: String
8
+
9
+ attr_reader xmlsec_errors: Array[String]
10
+ attr_accessor signature_node: Nokogiri::XML::Node?
11
+
12
+ def self.filter: (untyped value) -> String?
13
+ def initialize: (?untyped message, ?xmlsec_errors: Array[String], ?signature_node: Nokogiri::XML::Node?) -> void
14
+ def xmlsec_errors=: (Array[String] lines) -> Array[String]
15
+ end
16
+
17
+ class ConfigurationError < Error end
18
+ class PolicyError < ConfigurationError end
19
+ class PlacementError < ConfigurationError end
20
+ class NokogiriRequired < ConfigurationError end
21
+ class SchemaError < ConfigurationError end
22
+ class ParseError < Error end
23
+ class KeyLoadError < Error end
24
+ class ReferenceError < Error
25
+ attr_accessor reference_uri: String?
26
+ end
27
+ class SigningError < Error end
28
+
29
+ class VerificationError < Error end
30
+ class SignatureInvalid < VerificationError end
31
+ class SignatureMissing < VerificationError end
32
+ class MultipleSignatures < VerificationError end
33
+ class UntrustedCertificate < VerificationError end
34
+ class CertificateExpired < VerificationError end
35
+ class DigestMismatch < VerificationError
36
+ attr_accessor reference_uri: String?
37
+ end
38
+ class ResolutionMismatch < VerificationError end
39
+
40
+ class NotSignedError < Error end
41
+ class FrozenSignatureError < Error end
42
+ class NativeError < Error end
43
+ class NativeVersionMismatch < NativeError end
44
+
45
+ def self.nokogiri?: () -> bool
46
+ def self.capabilities: () -> Hash[Symbol, bool]
47
+ # §6.2: a String of markup, a path-like object, an IO, or a Nokogiri document or node.
48
+ type input = String | _ToPath | _Reader | Nokogiri::XML::Node | Nokogiri::XML::Document
49
+
50
+ def self.sign: (input doc_or_xml, **untyped kwargs) -> HankoXml::SignedDocument
51
+ def self.sign!: (Nokogiri::XML::Node | Nokogiri::XML::Document doc, **untyped kwargs) -> (Nokogiri::XML::Node | Nokogiri::XML::Document)
52
+ def self.valid?: (input xml, **untyped kwargs) -> bool
53
+ def self.verify!: (input xml, **untyped kwargs) -> HankoXml::Verification
54
+ def self.signature_present?: (input xml) -> bool
55
+ def self.zero_copy_available?: () -> bool
56
+ def self.parse: (String | IO | _ToPath source) -> Nokogiri::XML::Document
57
+ def self.serialize: (Nokogiri::XML::Document | Nokogiri::XML::Node doc) -> String
58
+ end
59
+
60
+ # Alias
61
+ Xmlsec: singleton(HankoXml)
62
+
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hanko_xml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: x86_64-linux
6
+ authors:
7
+ - Danimar Ribeiro
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2026-10-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: hanko_xml signs and verifies XML-DSig signatures by binding to libxmlsec1
14
+ through a Rust extension built with Magnus and rb-sys. It works with Nokogiri documents
15
+ when Nokogiri is loaded, and verifies plain bytes without it.
16
+ email:
17
+ - danimaribeiro@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - CHANGELOG.md
23
+ - LICENSE.txt
24
+ - README.md
25
+ - THIRD_PARTY_LICENSES.md
26
+ - dependencies.yml
27
+ - lib/hanko_xml.rb
28
+ - lib/hanko_xml/3.1/hanko_xml.so
29
+ - lib/hanko_xml/3.2/hanko_xml.so
30
+ - lib/hanko_xml/3.3/hanko_xml.so
31
+ - lib/hanko_xml/3.4/hanko_xml.so
32
+ - lib/hanko_xml/algorithms.rb
33
+ - lib/hanko_xml/dom.rb
34
+ - lib/hanko_xml/errors.rb
35
+ - lib/hanko_xml/exc-c14n.xsd
36
+ - lib/hanko_xml/input.rb
37
+ - lib/hanko_xml/key.rb
38
+ - lib/hanko_xml/key_info.rb
39
+ - lib/hanko_xml/native_version.rb
40
+ - lib/hanko_xml/nokogiri_ext.rb
41
+ - lib/hanko_xml/placement.rb
42
+ - lib/hanko_xml/policy.rb
43
+ - lib/hanko_xml/reference.rb
44
+ - lib/hanko_xml/signature_info.rb
45
+ - lib/hanko_xml/signed_document.rb
46
+ - lib/hanko_xml/signer.rb
47
+ - lib/hanko_xml/template.rb
48
+ - lib/hanko_xml/transform.rb
49
+ - lib/hanko_xml/verification.rb
50
+ - lib/hanko_xml/verifier.rb
51
+ - lib/hanko_xml/version.rb
52
+ - lib/hanko_xml/xades.rb
53
+ - lib/hanko_xml/xades/verifier.rb
54
+ - lib/hanko_xml/xml.rb
55
+ - lib/hanko_xml/xmldsig-core-schema.xsd
56
+ - sig/hanko_xml.rbs
57
+ - sig/hanko_xml/key.rbs
58
+ - sig/hanko_xml/native.rbs
59
+ - sig/hanko_xml/native_version.rbs
60
+ - sig/hanko_xml/nokogiri_ext.rbs
61
+ - sig/hanko_xml/placement.rbs
62
+ - sig/hanko_xml/policy.rbs
63
+ - sig/hanko_xml/reference.rbs
64
+ - sig/hanko_xml/signed_document.rbs
65
+ - sig/hanko_xml/signer.rbs
66
+ - sig/hanko_xml/template.rbs
67
+ - sig/hanko_xml/verification.rbs
68
+ - sig/hanko_xml/verifier.rbs
69
+ - sig/hanko_xml/xades.rbs
70
+ homepage: https://github.com/danimaribeiro/HankoXml
71
+ licenses:
72
+ - MIT
73
+ metadata:
74
+ homepage_uri: https://github.com/danimaribeiro/HankoXml
75
+ source_code_uri: https://github.com/danimaribeiro/HankoXml
76
+ changelog_uri: https://github.com/danimaribeiro/HankoXml/blob/main/CHANGELOG.md
77
+ bug_tracker_uri: https://github.com/danimaribeiro/HankoXml/issues
78
+ documentation_uri: https://github.com/danimaribeiro/HankoXml#readme
79
+ rubygems_mfa_required: 'true'
80
+ xmlsec1_version_requirement: ">= 1.2.30, < 1.4"
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '3.1'
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: 3.5.dev
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: 3.3.11
98
+ requirements: []
99
+ rubygems_version: 3.5.23
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: XML digital signature signing and verification for Ruby via a Rust extension
103
+ calling libxmlsec1.
104
+ test_files: []