xml-kit 0.2.0 → 0.3.0

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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -2
  3. data/.travis.yml +1 -2
  4. data/README.md +14 -22
  5. data/bin/cibuild +1 -1
  6. data/lib/xml/kit.rb +3 -0
  7. data/lib/xml/kit/certificate.rb +8 -4
  8. data/lib/xml/kit/crypto/oaep_cipher.rb +4 -1
  9. data/lib/xml/kit/crypto/rsa_cipher.rb +3 -1
  10. data/lib/xml/kit/crypto/symmetric_cipher.rb +15 -6
  11. data/lib/xml/kit/crypto/unknown_cipher.rb +6 -1
  12. data/lib/xml/kit/decryption.rb +19 -9
  13. data/lib/xml/kit/document.rb +5 -4
  14. data/lib/xml/kit/encrypted_data.rb +50 -0
  15. data/lib/xml/kit/encrypted_key.rb +34 -0
  16. data/lib/xml/kit/encryption.rb +14 -11
  17. data/lib/xml/kit/fingerprint.rb +1 -1
  18. data/lib/xml/kit/key_info.rb +40 -0
  19. data/lib/xml/kit/key_info/key_value.rb +17 -0
  20. data/lib/xml/kit/key_info/retrieval_method.rb +17 -0
  21. data/lib/xml/kit/key_info/rsa_key_value.rb +13 -0
  22. data/lib/xml/kit/key_pair.rb +9 -2
  23. data/lib/xml/kit/self_signed_certificate.rb +17 -2
  24. data/lib/xml/kit/signature.rb +10 -1
  25. data/lib/xml/kit/signatures.rb +6 -1
  26. data/lib/xml/kit/templatable.rb +59 -13
  27. data/lib/xml/kit/templates/certificate.builder +1 -5
  28. data/lib/xml/kit/templates/encrypted_data.builder +9 -0
  29. data/lib/xml/kit/templates/encrypted_key.builder +9 -0
  30. data/lib/xml/kit/templates/key_info.builder +14 -0
  31. data/lib/xml/kit/templates/key_value.builder +5 -0
  32. data/lib/xml/kit/templates/retrieval_method.builder +3 -0
  33. data/lib/xml/kit/templates/rsa_key_value.builder +6 -0
  34. data/lib/xml/kit/version.rb +1 -1
  35. data/xml-kit.gemspec +0 -1
  36. metadata +15 -20
  37. data/.rubocop_todo.yml +0 -22
  38. data/lib/xml/kit/templates/encryption.builder +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03f1eb698452e6bde1528e6899c935996309a1b0e4fdec3995ad04d8401b71e4
4
- data.tar.gz: d52d39605ff43af034bf4a913faa35757a34d2abc82f9aca970683132015229d
3
+ metadata.gz: 672d735085855f16805b7406db39b904cca1e04be940d8a9bb0512ddb441c94d
4
+ data.tar.gz: 6dd14f85bde17fae00b6b2fb3c0a70d32db6bdf8d9534053eddebcea2afa3b09
5
5
  SHA512:
6
- metadata.gz: 91ab2b253526d12fc2495afc4261b4ceb8861d4644dd0ae5fcea226d7413df058001cdb6f8e6cb40a63254bcb6546f9a86fd5e9472e41818a1003ac5834442e0
7
- data.tar.gz: ac71bd4d5416fadfa85763ed40839cd0e5e33ff2e4fd05ea98e3cdc8d0e29225e528614b33e7cbb1a8ac77b171e991973875b9cf7a53dc01817024d169f2dd4a
6
+ metadata.gz: 91479a0d7f9dd674d0b509e332c5d4de11ec9d6dc5e4a53ba5abf1b0724ffd30effd04ea4986e68d0a8d5db7de5169f72cc24dccea472dc7cf4df8cf1b57e366
7
+ data.tar.gz: 2a516669b6c6fcaa56a8a216f701da707547876aaee04df7efbfdb06da0a32b80dc3d1055b5d933aff022b423b9992cf3f4bc4fc95c5060f9a4200983d00cbf6
data/.rubocop.yml CHANGED
@@ -1,5 +1,3 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
1
  require:
4
2
  - rubocop/cop/internal_affairs
5
3
  - rubocop-rspec
@@ -59,8 +57,10 @@ Metrics/ModuleLength:
59
57
  - 'spec/**/*.rb'
60
58
 
61
59
  Metrics/LineLength:
60
+ IgnoredPatterns: ['(\A|\s)#']
62
61
  Exclude:
63
62
  - 'spec/**/*.rb'
63
+ - 'lib/xml/kit/templates/*.builder'
64
64
 
65
65
  Naming/FileName:
66
66
  Exclude:
@@ -95,3 +95,7 @@ RSpec/NestedGroups:
95
95
 
96
96
  RSpec/SubjectStub:
97
97
  Enabled: false
98
+
99
+ Style/DoubleNegation:
100
+ Exclude:
101
+ - 'lib/xml/kit/certificate.rb'
data/.travis.yml CHANGED
@@ -1,11 +1,10 @@
1
1
  sudo: false
2
2
  language: ruby
3
- cache: bundler
4
3
  rvm:
5
4
  - 2.2.9
6
5
  - 2.3.6
7
6
  - 2.4.3
8
- - 2.5.0
7
+ - 2.5.3
9
8
  script:
10
9
  - bin/cibuild
11
10
  - bin/lint
data/README.md CHANGED
@@ -5,8 +5,7 @@
5
5
  [![Build Status](https://travis-ci.org/saml-kit/xml-kit.svg?branch=master)](https://travis-ci.org/saml-kit/xml-kit)
6
6
  [![Security](https://hakiri.io/github/saml-kit/xml-kit/master.svg)](https://hakiri.io/github/saml-kit/xml-kit/master)
7
7
 
8
- Xml::Kit is a toolkit for working with XML. It supports adding [XML
9
- Digital Signatures](https://www.w3.org/TR/xmldsig-core/)
8
+ Xml::Kit is a toolkit for working with XML. It supports adding [XML Digital Signatures](https://www.w3.org/TR/xmldsig-core/)
10
9
  and [XML Encryption](https://www.w3.org/TR/2002/REC-xmlenc-core-20021210/Overview.html).
11
10
 
12
11
  ## Installation
@@ -29,11 +28,12 @@ Or install it yourself as:
29
28
 
30
29
  ```builder
31
30
  # ./templates/item.builder
31
+
32
32
  xml.instruct!
33
33
  xml.Item ID: id do
34
34
  signature_for reference_id: id, xml: xml
35
35
  xml.Encrypted do
36
- encryption_for xml: xml do |encrypted_xml|
36
+ encrypt_data_for xml: xml do |encrypted_xml|
37
37
  encrypted_xml.EncryptMe do
38
38
  encrypted_xml.Secret "secret"
39
39
  end
@@ -48,12 +48,12 @@ require 'xml/kit'
48
48
  class Item
49
49
  include ::Xml::Kit::Templatable
50
50
 
51
- def initialize
51
+ attr_reader :id
52
+
53
+ def initialize(signing_key_pair, encryption_certificate)
52
54
  @id = ::Xml::Kit::Id.generate
53
- @signing_key_pair = ::Xml::Kit::KeyPair.generate(use: :signing)
54
- @embed_signature = true
55
- @encrypt = true
56
- @encryption_certificate = ::Xml::Kit::KeyPair.generate(use: :encryption).certificate
55
+ sign_with(signing_key_pair)
56
+ encrypt_with(encryption_certificate)
57
57
  end
58
58
 
59
59
  def template_path
@@ -62,7 +62,9 @@ class Item
62
62
  end
63
63
  end
64
64
 
65
- puts Item.new.to_xml
65
+ signing_key_pair = ::Xml::Kit::KeyPair.generate(use: :signing)
66
+ encryption_certificate = ::Xml::Kit::KeyPair.generate(use: :encryption).certificate
67
+ puts Item.new(signing_key_pair, encryption_certificate).to_xml
66
68
  ```
67
69
 
68
70
  This will produce something like the following:
@@ -86,8 +88,7 @@ This will produce something like the following:
86
88
  <SignatureValue>ZCSx4dad704jz0Z6rCMsnOs/oyVH3YBeEF9wtk2UFmWBW+VfhoBKw7N50GnzmAGCHyI6zajRPdff5i6UMDz3fOzh7rlROnqW0TXoG77xPiIfqJswCKE/4LzzBLrEHVbdUz90U8n0M1Ahbesrt+pbf/NkJghpvDhJW+w6oho7dyU6k57C5D//kTaSb7DvKte3a7/o8xWvPRztQhYekK+RyWjK9k/lU4WEXk5rGbx+QrD9rgIXBQOdcSjOtUosZJADz7uFod6AWRak246U62Xahz8JxE/1N22LhZY9whvB7s+c76f1Uv44NtF87D0P8UXs0TVx2jsnhEwLsT7DPQ6jDg==</SignatureValue>
87
89
  <KeyInfo>
88
90
  <X509Data>
89
- <X509Certificate>MIIDQTCCAimgAwIBAgIBADANBgkqhkiG9w0BAQsFADBkMQswCQYDVQQGEwJDQTEQMA4GA1UECAwHQWxiZXJ0YTEQMA4GA1UEBwwHQ2FsZ2FyeTEPMA0GA1UECgwGWG1sS2l0MQ8wDQYDVQQLDAZYbWxLaXQxDzANBgNVBAMMBlhtbEtpdDAeFw0xNzEyMzAxOTM1MjZaFw0xODAxMjkwNzAwMDBaMGQxCzAJBgNVBAYTAkNBMRAwDgYDVQQIDAdBbGJlcnRhMRAwDgYDVQQHDAdDYWxnYXJ5MQ8wDQYDVQQKDAZYbWxLaXQxDzANBgNVBAsMBlhtbEtpdDEPMA0GA1UEAwwGWG1sS2l0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz8yvaY1zvqiSTpDc0vFgS00N0R05ytanViNy0YrcAvLH2njvLOYi8e5lWAjCUzoWTe6FMJQySIHuzr9NvZztlQBp5tydmxDsOFQ3DrBhiqtyafdCd5s8OQz1CekavgToTOm5VdZEWLD7HSCFvHXeuiS/zwEh4yYpJBAERtsSaYxT7L1wNggxc6F6UEfF1vwrGxMNH/OUi4okeS773esXeRlP5fHyMUvVC70KHauSYt/kjNR8/WuZBOY8/kFv3XiErf0PNSAYhyGHozabv8hJ2Bho0+HR12P6Xv+qKXFlDnMeAOHy23eShuUpCEBaEPAG4o8w4g/lrn0nJ+e9XrYaNQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQCWybi6buMD75KBCcyd5aRtSKavYoDaZlzuohKh4z1HEzHS/fbpbxVQOrfXtuawZjNxcn62LFIe/w68EImzYkAss8LKojRcaKnIeF1/3Pzo6qfnmFpaecfYvX3ZTtw9JPOd4chy2X2WFAUMRscjSvjNvTBzFOXg60F0UMDnWOWMbc5Di/aZD8r2s/RDE3QxcUou8QhBMc2nYw77mQsXBnWmBeUA2aGP
90
- 8OG/fOgtBKkZnNF8gx7wuodbYSmKAfFGx8+CGtnkwNr4/hXgd1qg5KmsAx+9VYozCjGKSkVUIqC5khy6N+1Pb5jMKrMQ+QU9zGhylWoJ2jiK65hzUUVUESIB</X509Certificate>
91
+ <X509Certificate>MIIDQTCCAimgAwIBAgIBADANBgkqhkiG9w0BAQsFADBkMQswCQYDVQQGEwJDQTEQMA4GA1UECAwHQWxiZXJ0YTEQMA4GA1UEBwwHQ2FsZ2FyeTEPMA0GA1UECgwGWG1sS2l0MQ8wDQYDVQQLDAZYbWxLaXQxDzANBgNVBAMMBlhtbEtpdDAeFw0xNzEyMzAxOTM1MjZaFw0xODAxMjkwNzAwMDBaMGQxCzAJBgNVBAYTAkNBMRAwDgYDVQQIDAdBbGJlcnRhMRAwDgYDVQQHDAdDYWxnYXJ5MQ8wDQYDVQQKDAZYbWxLaXQxDzANBgNVBAsMBlhtbEtpdDEPMA0GA1UEAwwGWG1sS2l0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz8yvaY1zvqiSTpDc0vFgS00N0R05ytanViNy0YrcAvLH2njvLOYi8e5lWAjCUzoWTe6FMJQySIHuzr9NvZztlQBp5tydmxDsOFQ3DrBhiqtyafdCd5s8OQz1CekavgToTOm5VdZEWLD7HSCFvHXeuiS/zwEh4yYpJBAERtsSaYxT7L1wNggxc6F6UEfF1vwrGxMNH/OUi4okeS773esXeRlP5fHyMUvVC70KHauSYt/kjNR8/WuZBOY8/kFv3XiErf0PNSAYhyGHozabv8hJ2Bho0+HR12P6Xv+qKXFlDnMeAOHy23eShuUpCEBaEPAG4o8w4g/lrn0nJ+e9XrYaNQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQCWybi6buMD75KBCcyd5aRtSKavYoDaZlzuohKh4z1HEzHS/fbpbxVQOrfXtuawZjNxcn62LFIe/w68EImzYkAss8LKojRcaKnIeF1/3Pzo6qfnmFpaecfYvX3ZTtw9JPOd4chy2X2WFAUMRscjSvjNvTBzFOXg60F0UMDnWOWMbc5Di/aZD8r2s/RDE3QxcUou8QhBMc2nYw77mQsXBnWmBeUA2aGP8OG/fOgtBKkZnNF8gx7wuodbYSmKAfFGx8+CGtnkwNr4/hXgd1qg5KmsAx+9VYozCjGKSkVUIqC5khy6N+1Pb5jMKrMQ+QU9zGhylWoJ2jiK65hzUUVUESIB</X509Certificate>
91
92
  </X509Data>
92
93
  </KeyInfo>
93
94
  </Signature>
@@ -98,21 +99,12 @@ This will produce something like the following:
98
99
  <EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
99
100
  <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
100
101
  <CipherData>
101
- <CipherValue>rBJwm+gmL6eUHBZDXs2swIL3DiZ+MfmBPpM52eF0RWFtZv/gutY02KlsFLlm
102
- jc+DO7X5p9l1Br67FjGJrTdfSSqHf35cS1cioyaKLtgniSrD7Hf9d8qIuWt5
103
- 6dLWjmCi21cePMJHhNiFe5yRjFHNp5LZ9dX5hvNXjbn0+p90fj8zlO2TWZv9
104
- atooON3BaYGCezZlmG0bWyEmloqKHiGjqaKtkdeSKJDzoo/AvubDEgz56rin
105
- Cpw26rEOg8BBd/KNfSXyDUifOOzXmn6myq+8+W/FFQ+6y+5SgtsbONRCqe2c
106
- KkNi3fYhilwLxWCaXFjONimEOkeG03yR5QnWhzEOpw==
107
- </CipherValue>
102
+ <CipherValue>rBJwm+gmL6eUHBZDXs2swIL3DiZ+MfmBPpM52eF0RWFtZv/gutY02KlsFLlmjc+DO7X5p9l1Br67FjGJrTdfSSqHf35cS1cioyaKLtgniSrD7Hf9d8qIuWt56dLWjmCi21cePMJHhNiFe5yRjFHNp5LZ9dX5hvNXjbn0+p90fj8zlO2TWZv9atooON3BaYGCezZlmG0bWyEmloqKHiGjqaKtkdeSKJDzoo/AvubDEgz56rinCpw26rEOg8BBd/KNfSXyDUifOOzXmn6myq+8+W/FFQ+6y+5SgtsbONRCqe2cKkNi3fYhilwLxWCaXFjONimEOkeG03yR5QnWhzEOpw==</CipherValue>
108
103
  </CipherData>
109
104
  </EncryptedKey>
110
105
  </KeyInfo>
111
106
  <CipherData>
112
- <CipherValue>45rM0phzM/S/vpiq8Ev+uQZ6WL5qZ8av0UDVzWAlHn6Qr7zWYjHea+NF94lK
113
- pvmTPWQDEnfv2UW8l0VdCLc+51zHjluRE/xJh31Gk3rVuRJtLioSge/N9UM4
114
- 5g901rE9
115
- </CipherValue>
107
+ <CipherValue>45rM0phzM/S/vpiq8Ev+uQZ6WL5qZ8av0UDVzWAlHn6Qr7zWYjHea+NF94lKpvmTPWQDEnfv2UW8l0VdCLc+51zHjluRE/xJh31Gk3rVuRJtLioSge/N9UM45g901rE9</CipherValue>
116
108
  </CipherData>
117
109
  </EncryptedData>
118
110
  </Encrypted>
data/bin/cibuild CHANGED
@@ -17,5 +17,5 @@ export RUBY_HEAP_SLOTS_INCREMENT=400000
17
17
  export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
18
18
 
19
19
  ruby -v
20
- gem install bundler --no-ri --no-rdoc --conservative
20
+ gem install bundler --conservative
21
21
  bin/test
data/lib/xml/kit.rb CHANGED
@@ -19,9 +19,12 @@ require 'xml/kit/crypto'
19
19
  require 'xml/kit/decryption'
20
20
  require 'xml/kit/decryption_error'
21
21
  require 'xml/kit/document'
22
+ require 'xml/kit/encrypted_data'
23
+ require 'xml/kit/encrypted_key'
22
24
  require 'xml/kit/encryption'
23
25
  require 'xml/kit/fingerprint'
24
26
  require 'xml/kit/id'
27
+ require 'xml/kit/key_info'
25
28
  require 'xml/kit/key_pair'
26
29
  require 'xml/kit/self_signed_certificate'
27
30
  require 'xml/kit/signature'
@@ -1,10 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'xml/kit/templatable'
4
+
3
5
  module Xml
4
6
  module Kit
5
- # {include:file:spec/xml/certificate_spec.rb}
7
+ # {include:file:spec/xml/kit/certificate_spec.rb}
6
8
  class Certificate
9
+ include Templatable
10
+ # rubocop:disable Metrics/LineLength
7
11
  BASE64_FORMAT = %r(\A([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?\Z).freeze
12
+ # rubocop:enable Metrics/LineLength
8
13
  BEGIN_CERT = /-----BEGIN CERTIFICATE-----/.freeze
9
14
  END_CERT = /-----END CERTIFICATE-----/.freeze
10
15
  # The use can be `:signing` or `:encryption`. Use `nil` for both.
@@ -109,9 +114,8 @@ module Xml
109
114
  x509.not_before
110
115
  end
111
116
 
112
- def to_xml(pretty: false, xml: ::Builder::XmlMarkup.new)
113
- xml = ::Xml::Kit::Template.new(self).to_xml(xml: xml)
114
- pretty ? Nokogiri::XML(xml).to_xml(indent: 2) : xml
117
+ def key_info
118
+ @key_info ||= KeyInfo.new(x509: x509)
115
119
  end
116
120
 
117
121
  class << self
@@ -8,7 +8,10 @@ module Xml
8
8
  ALGORITHMS = {
9
9
  ALGORITHM => true
10
10
  }.freeze
11
- def initialize(_algorithm, key)
11
+ attr_reader :algorithm, :key
12
+
13
+ def initialize(algorithm, key)
14
+ @algorithm = algorithm
12
15
  @key = key
13
16
  end
14
17
 
@@ -5,8 +5,10 @@ module Xml
5
5
  module Crypto
6
6
  class RsaCipher
7
7
  ALGORITHM = "#{::Xml::Kit::Namespaces::XMLENC}rsa-1_5".freeze
8
+ attr_reader :algorithm, :key
8
9
 
9
- def initialize(_algorithm, key)
10
+ def initialize(algorithm, key)
11
+ @algorithm = algorithm
10
12
  @key = key
11
13
  end
12
14
 
@@ -14,7 +14,7 @@ module Xml
14
14
 
15
15
  attr_reader :algorithm, :key, :padding
16
16
 
17
- def initialize(algorithm, key = nil, padding = nil)
17
+ def initialize(algorithm = DEFAULT_ALGORITHM, key = nil, padding = nil)
18
18
  @algorithm = algorithm
19
19
  @key = key || cipher.random_key
20
20
  @padding = padding
@@ -31,9 +31,10 @@ module Xml
31
31
  end
32
32
 
33
33
  def decrypt(cipher_text)
34
+ bytes = cipher_text.bytes
34
35
  result = default_decrypt(
35
- cipher_text[0...cipher.iv_len],
36
- cipher_text[cipher.iv_len..-1]
36
+ bytes[0...cipher.iv_len],
37
+ bytes[cipher.iv_len..-1]
37
38
  )
38
39
  return result if padding.nil?
39
40
 
@@ -41,14 +42,18 @@ module Xml
41
42
  result[0...-padding_size]
42
43
  end
43
44
 
45
+ def to_s
46
+ algorithm
47
+ end
48
+
44
49
  protected
45
50
 
46
51
  def default_decrypt(initialization_vector, data)
47
52
  cipher.decrypt
48
- cipher.padding = padding unless padding.nil?
53
+ apply_padding_to(cipher)
49
54
  cipher.key = @key
50
- cipher.iv = initialization_vector
51
- cipher.update(data) << cipher.final
55
+ cipher.iv = initialization_vector.pack('c*')
56
+ cipher.update(data.pack('c*')) << cipher.final
52
57
  end
53
58
 
54
59
  private
@@ -56,6 +61,10 @@ module Xml
56
61
  def cipher
57
62
  @cipher ||= OpenSSL::Cipher.new(ALGORITHMS[algorithm])
58
63
  end
64
+
65
+ def apply_padding_to(cipher)
66
+ cipher.padding = padding unless padding.nil?
67
+ end
59
68
  end
60
69
  end
61
70
  end
@@ -4,7 +4,12 @@ module Xml
4
4
  module Kit
5
5
  module Crypto
6
6
  class UnknownCipher
7
- def initialize(algorithm, key); end
7
+ attr_reader :algorithm, :key
8
+
9
+ def initialize(algorithm, key)
10
+ @algorithm = algorithm
11
+ @key = key
12
+ end
8
13
 
9
14
  def self.matches?(_algorithm)
10
15
  true
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Xml
4
4
  module Kit
5
- # {include:file:spec/saml/xml_decryption_spec.rb}
5
+ # {include:file:spec/xml/kit/decryption_spec.rb}
6
6
  class Decryption
7
7
  # The list of private keys to use to attempt to decrypt the document.
8
8
  attr_reader :cipher_registry, :private_keys
@@ -15,8 +15,11 @@ module Xml
15
15
  # Decrypts an EncryptedData section of an XML document.
16
16
  #
17
17
  # @param data [Hash] the XML document converted to a [Hash] using Hash.from_xml.
18
+ # @deprecated Use {#decrypt_hash} instead of this
18
19
  def decrypt(data)
19
- ::Xml::Kit.deprecate('decrypt is deprecated. Use decrypt_xml or decrypt_hash instead.')
20
+ ::Xml::Kit.deprecate(
21
+ 'decrypt is deprecated. Use decrypt_xml or decrypt_hash instead.'
22
+ )
20
23
  decrypt_hash(data)
21
24
  end
22
25
 
@@ -31,11 +34,11 @@ module Xml
31
34
  #
32
35
  # @param hash [Hash] the XML document converted to a [Hash] using Hash.from_xml.
33
36
  def decrypt_hash(hash)
34
- encrypted_data = hash['EncryptedData']
37
+ data = hash['EncryptedData']
35
38
  to_plaintext(
36
- Base64.decode64(encrypted_data['CipherData']['CipherValue']),
37
- symmetric_key_from(encrypted_data),
38
- encrypted_data['EncryptionMethod']['Algorithm']
39
+ Base64.decode64(data['CipherData']['CipherValue']),
40
+ symmetric_key_from(data['KeyInfo']['EncryptedKey']),
41
+ data['EncryptionMethod']['Algorithm']
39
42
  )
40
43
  end
41
44
 
@@ -50,12 +53,12 @@ module Xml
50
53
 
51
54
  private
52
55
 
53
- def symmetric_key_from(encrypted_data, attempts = private_keys.count)
54
- cipher_text = Base64.decode64(encrypted_data['KeyInfo']['EncryptedKey']['CipherData']['CipherValue'])
56
+ def symmetric_key_from(encrypted_key, attempts = private_keys.count)
57
+ cipher, algorithm = cipher_and_algorithm_from(encrypted_key)
55
58
  private_keys.each do |private_key|
56
59
  begin
57
60
  attempts -= 1
58
- return to_plaintext(cipher_text, private_key, encrypted_data['KeyInfo']['EncryptedKey']['EncryptionMethod']['Algorithm'])
61
+ return to_plaintext(cipher, private_key, algorithm)
59
62
  rescue OpenSSL::PKey::RSAError
60
63
  raise if attempts.zero?
61
64
  end
@@ -66,6 +69,13 @@ module Xml
66
69
  def to_plaintext(cipher_text, private_key, algorithm)
67
70
  cipher_registry.cipher_for(algorithm, private_key).decrypt(cipher_text)
68
71
  end
72
+
73
+ def cipher_and_algorithm_from(encrypted_key)
74
+ [
75
+ Base64.decode64(encrypted_key['CipherData']['CipherValue']),
76
+ encrypted_key['EncryptionMethod']['Algorithm']
77
+ ]
78
+ end
69
79
  end
70
80
  end
71
81
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Xml
4
4
  module Kit
5
- # {include:file:spec/saml/xml_spec.rb}
5
+ # {include:file:spec/xml/kit/document_spec.rb}
6
6
  class Document
7
7
  include ActiveModel::Validations
8
8
  NAMESPACES = { "ds": ::Xml::Kit::Namespaces::XMLDSIG }.freeze
@@ -47,9 +47,10 @@ module Xml
47
47
  end
48
48
  end
49
49
 
50
- def invalid_signatures
51
- signed_document = Xmldsig::SignedDocument.new(document, id_attr: 'ID=$uri or @Id')
52
- signed_document.signatures.find_all do |signature|
50
+ def invalid_signatures(id_attr: 'ID=$uri or @Id')
51
+ Xmldsig::SignedDocument
52
+ .new(document, id_attr: id_attr)
53
+ .signatures.find_all do |signature|
53
54
  x509_certificates.all? do |certificate|
54
55
  !signature.valid?(certificate)
55
56
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Xml
4
+ module Kit
5
+ # An implementation of the EncryptedKey element.
6
+ # https://www.w3.org/TR/xmlenc-core1/#sec-EncryptedData
7
+ #
8
+ # @since 0.3.0
9
+ class EncryptedData
10
+ attr_reader :key_info
11
+ attr_reader :symmetric_cipher
12
+ attr_reader :symmetric_cipher_value
13
+
14
+ def initialize(
15
+ raw_xml,
16
+ symmetric_cipher:,
17
+ asymmetric_cipher:,
18
+ key_info: nil
19
+ )
20
+ @symmetric_cipher = symmetric_cipher
21
+ @symmetric_cipher_value = Base64.strict_encode64(
22
+ symmetric_cipher.encrypt(raw_xml)
23
+ )
24
+ @key_info = key_info || create_key_info_for(
25
+ symmetric_cipher,
26
+ asymmetric_cipher
27
+ )
28
+ end
29
+
30
+ def to_xml(xml: ::Builder::XmlMarkup.new)
31
+ ::Xml::Kit::Template.new(self).to_xml(xml: xml)
32
+ end
33
+
34
+ def render(model, options)
35
+ ::Xml::Kit::Template.new(model).to_xml(options)
36
+ end
37
+
38
+ private
39
+
40
+ def create_key_info_for(symmetric_cipher, asymmetric_cipher)
41
+ KeyInfo.new do |x|
42
+ x.encrypted_key = EncryptedKey.new(
43
+ asymmetric_cipher: asymmetric_cipher,
44
+ symmetric_cipher: symmetric_cipher
45
+ )
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xml/kit/templatable'
4
+
5
+ module Xml
6
+ module Kit
7
+ # An implementation of the EncryptedKey element.
8
+ # https://www.w3.org/TR/xmlenc-core1/#sec-EncryptedKey
9
+ #
10
+ # @since 0.3.0
11
+ class EncryptedKey
12
+ include ::Xml::Kit::Templatable
13
+ attr_reader :id
14
+ attr_reader :asymmetric_cipher, :symmetric_cipher
15
+ attr_accessor :key_info
16
+
17
+ def initialize(
18
+ id: Id.generate,
19
+ asymmetric_cipher:,
20
+ symmetric_cipher:,
21
+ key_info: nil
22
+ )
23
+ @id = id
24
+ @asymmetric_cipher = asymmetric_cipher
25
+ @symmetric_cipher = symmetric_cipher
26
+ @key_info = key_info
27
+ end
28
+
29
+ def cipher_value
30
+ Base64.strict_encode64(asymmetric_cipher.encrypt(symmetric_cipher.key))
31
+ end
32
+ end
33
+ end
34
+ end
@@ -2,29 +2,32 @@
2
2
 
3
3
  module Xml
4
4
  module Kit
5
- class Encryption
5
+ # @deprecated Use {#Xml::Kit::EncryptedData} class instead of this
6
+ class Encryption < EncryptedData
6
7
  attr_reader :asymmetric_algorithm
7
- attr_reader :asymmetric_cipher_value
8
8
  attr_reader :symmetric_algorithm
9
9
  attr_reader :symmetric_cipher_value
10
+ attr_reader :key_info
10
11
 
11
12
  def initialize(
12
13
  raw_xml,
13
14
  public_key,
14
- symmetric_algorithm: ::Xml::Kit::Crypto::SymmetricCipher::DEFAULT_ALGORITHM,
15
- asymmetric_algorithm: ::Xml::Kit::Crypto::RsaCipher::ALGORITHM
15
+ symmetric_algorithm: Crypto::SymmetricCipher::DEFAULT_ALGORITHM,
16
+ asymmetric_algorithm: Crypto::RsaCipher::ALGORITHM,
17
+ key_info: nil
16
18
  )
17
19
  @symmetric_algorithm = symmetric_algorithm
18
- symmetric_cipher = symmetric(symmetric_algorithm)
19
- @symmetric_cipher_value = Base64.strict_encode64(symmetric_cipher.encrypt(raw_xml))
20
-
21
20
  @asymmetric_algorithm = asymmetric_algorithm
22
- asymmetric_cipher = asymmetric(asymmetric_algorithm, public_key)
23
- @asymmetric_cipher_value = Base64.strict_encode64(asymmetric_cipher.encrypt(symmetric_cipher.key))
21
+ Xml::Kit.deprecate('Encryption is deprecated. Use EncryptedData.')
22
+ super(raw_xml,
23
+ symmetric_cipher: symmetric(symmetric_algorithm),
24
+ asymmetric_cipher: asymmetric(asymmetric_algorithm, public_key),
25
+ key_info: key_info
26
+ )
24
27
  end
25
28
 
26
- def to_xml(xml: ::Builder::XmlMarkup.new)
27
- ::Xml::Kit::Template.new(self).to_xml(xml: xml)
29
+ def template_path
30
+ Template::TEMPLATES_DIR.join('encrypted_data.builder')
28
31
  end
29
32
 
30
33
  private
@@ -9,7 +9,7 @@ module Xml
9
9
  # puts Xml::Kit::Fingerprint.new(certificate).to_s
10
10
  # # B7:AB:DC:BD:4D:23:58:65:FD:1A:99:0C:5F:89:EA:87:AD:F1:D7:83:34:7A:E9:E4:88:12:DD:46:1F:38:05:93
11
11
  #
12
- # {include:file:spec/saml/fingerprint_spec.rb}
12
+ # {include:file:spec/xml/kit/fingerprint_spec.rb}
13
13
  class Fingerprint
14
14
  # The OpenSSL::X509::Certificate
15
15
  attr_reader :x509
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xml/kit/key_info/key_value'
4
+ require 'xml/kit/key_info/retrieval_method'
5
+ require 'xml/kit/key_info/rsa_key_value'
6
+
7
+ module Xml
8
+ module Kit
9
+ # An implementation of the KeyInfo element.
10
+ # https://www.w3.org/TR/xmldsig-core1/#sec-KeyInfo
11
+ #
12
+ # @since 0.3.0
13
+ class KeyInfo
14
+ include Templatable
15
+ attr_accessor :key_name
16
+ attr_accessor :x509_data
17
+ attr_accessor :encrypted_key
18
+
19
+ def initialize(x509: nil)
20
+ @x509_data = x509
21
+ yield self if block_given?
22
+ end
23
+
24
+ def key_value
25
+ @key_value ||= KeyValue.new
26
+ end
27
+
28
+ def retrieval_method
29
+ @retrieval_method ||= RetrievalMethod.new
30
+ end
31
+
32
+ def subject_key_identifier
33
+ ski = x509_data.extensions.find { |x| x.oid == 'subjectKeyIdentifier' }
34
+ return if ski.nil?
35
+
36
+ Base64.strict_encode64(ski.value)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,17 @@
1
+ module Xml
2
+ module Kit
3
+ class KeyInfo
4
+ # An implementation of the RSAKeyValue element.
5
+ # https://www.w3.org/TR/xmldsig-core1/#sec-KeyValue
6
+ #
7
+ # @since 0.3.0
8
+ class KeyValue
9
+ include Templatable
10
+
11
+ def rsa
12
+ @rsa ||= RSAKeyValue.new
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Xml
2
+ module Kit
3
+ class KeyInfo
4
+ # An implementation of the RSAKeyValue element.
5
+ # https://www.w3.org/TR/xmldsig-core1/#sec-RetrievalMethod
6
+ #
7
+ # @since 0.3.0
8
+ class RetrievalMethod
9
+ attr_accessor :uri, :type
10
+
11
+ def initialize
12
+ @type = "#{Namespaces::XMLENC}EncryptedKey"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ module Xml
2
+ module Kit
3
+ class KeyInfo
4
+ # An implementation of the RSAKeyValue element.
5
+ # https://www.w3.org/TR/xmldsig-core1/#sec-RSAKeyValue
6
+ #
7
+ # @since 0.3.0
8
+ class RSAKeyValue
9
+ attr_accessor :modulus, :exponent
10
+ end
11
+ end
12
+ end
13
+ end
@@ -30,9 +30,16 @@ module Xml
30
30
  # @param use [Symbol] Can be either `:signing` or `:encryption`.
31
31
  # @param passphrase [String] the passphrase to use to encrypt the private key.
32
32
  # @param algorithm [String] the symmetric algorithm to use for encrypting the private key.
33
- def self.generate(use:, passphrase: SecureRandom.uuid, algorithm: ::Xml::Kit::Crypto::SymmetricCipher::DEFAULT_ALGORITHM)
33
+ def self.generate(
34
+ use:,
35
+ passphrase: SecureRandom.uuid,
36
+ algorithm: ::Xml::Kit::Crypto::SymmetricCipher::DEFAULT_ALGORITHM
37
+ )
34
38
  algorithm = ::Xml::Kit::Crypto::SymmetricCipher::ALGORITHMS[algorithm]
35
- certificate, private_key = ::Xml::Kit::SelfSignedCertificate.new.create(algorithm: algorithm, passphrase: passphrase)
39
+ certificate, private_key = SelfSignedCertificate.new.create(
40
+ algorithm: algorithm,
41
+ passphrase: passphrase
42
+ )
36
43
  new(certificate, private_key, passphrase, use)
37
44
  end
38
45
  end
@@ -5,7 +5,11 @@ module Xml
5
5
  class SelfSignedCertificate
6
6
  SUBJECT = '/C=CA/ST=AB/L=Calgary/O=XmlKit/OU=XmlKit/CN=XmlKit'.freeze
7
7
 
8
- def create(algorithm: 'AES-256-CBC', passphrase: nil, key_pair: OpenSSL::PKey::RSA.new(2048))
8
+ def create(
9
+ algorithm: 'AES-256-CBC',
10
+ passphrase: nil,
11
+ key_pair: OpenSSL::PKey::RSA.new(2048)
12
+ )
9
13
  certificate = certificate_for(key_pair.public_key)
10
14
  certificate.sign(key_pair, OpenSSL::Digest::SHA256.new)
11
15
  [certificate.to_pem, export(key_pair, algorithm, passphrase)]
@@ -24,14 +28,25 @@ module Xml
24
28
 
25
29
  def certificate_for(public_key)
26
30
  certificate = OpenSSL::X509::Certificate.new
27
- certificate.subject = certificate.issuer = OpenSSL::X509::Name.parse(SUBJECT)
31
+ certificate.subject =
32
+ certificate.issuer = OpenSSL::X509::Name.parse(SUBJECT)
28
33
  certificate.not_before = Time.now
29
34
  certificate.not_after = certificate.not_before + 30 * 24 * 60 * 60 # 30 days
30
35
  certificate.public_key = public_key
31
36
  certificate.serial = 0x0
32
37
  certificate.version = 2
38
+ apply_ski_extension_to(certificate)
33
39
  certificate
34
40
  end
41
+
42
+ def apply_ski_extension_to(certificate)
43
+ extensions = OpenSSL::X509::ExtensionFactory.new
44
+ extensions.subject_certificate = certificate
45
+ extensions.issuer_certificate = certificate
46
+ certificate.add_extension(
47
+ extensions.create_extension('subjectKeyIdentifier', 'hash', false)
48
+ )
49
+ end
35
50
  end
36
51
  end
37
52
  end
@@ -2,6 +2,10 @@
2
2
 
3
3
  module Xml
4
4
  module Kit
5
+ # An implementation of the Signature element.
6
+ # https://www.w3.org/TR/xmldsig-core1/#sec-Signature
7
+ #
8
+ # @since 0.1.0
5
9
  class Signature
6
10
  SIGNATURE_METHODS = {
7
11
  SHA1: 'http://www.w3.org/2000/09/xmldsig#rsa-sha1',
@@ -23,7 +27,12 @@ module Xml
23
27
  attr_reader :reference_id
24
28
  attr_reader :signature_method
25
29
 
26
- def initialize(reference_id, signature_method: :SH256, digest_method: :SHA256, certificate:)
30
+ def initialize(
31
+ reference_id,
32
+ signature_method: :SH256,
33
+ digest_method: :SHA256,
34
+ certificate:
35
+ )
27
36
  @certificate = certificate
28
37
  @digest_method = DIGEST_METHODS[digest_method]
29
38
  @reference_id = reference_id
@@ -39,7 +39,12 @@ module Xml
39
39
  end
40
40
 
41
41
  # @!visibility private
42
- def self.sign(xml: ::Builder::XmlMarkup.new, key_pair:, signature_method: :SHA256, digest_method: :SHA256)
42
+ def self.sign(
43
+ xml: ::Builder::XmlMarkup.new,
44
+ key_pair:,
45
+ signature_method: :SHA256,
46
+ digest_method: :SHA256
47
+ )
43
48
  signatures = new(
44
49
  key_pair: key_pair,
45
50
  signature_method: signature_method,
@@ -18,21 +18,67 @@ module Xml
18
18
  attr_accessor :encryption_certificate
19
19
 
20
20
  # Returns the generated XML document with an XML Digital Signature and XML Encryption.
21
- def to_xml(xml: ::Builder::XmlMarkup.new)
22
- signatures.complete(render(self, xml: xml))
21
+ def to_xml(xml: ::Builder::XmlMarkup.new, pretty: false)
22
+ result = signatures.complete(render(self, xml: xml))
23
+ pretty ? Nokogiri::XML(result).to_xml(indent: 2) : result
23
24
  end
24
25
 
25
- def encryption_for(xml:)
26
- if encrypt?
27
- temp = ::Builder::XmlMarkup.new
28
- yield temp
29
- ::Xml::Kit::Encryption.new(
30
- signatures.complete(temp.target!),
31
- encryption_certificate.public_key
32
- ).to_xml(xml: xml)
33
- else
34
- yield xml
35
- end
26
+ # Generates an {#Xml::Kit::EncryptedKey} section. https://www.w3.org/TR/xmlenc-core1/#sec-EncryptedKey
27
+ #
28
+ # @since 0.3.0
29
+ # @param xml [Builder::XmlMarkup] the xml builder instance
30
+ # @param id [String] the id of EncryptedKey element
31
+ def encrypt_key_for(xml:, id:)
32
+ ::Xml::Kit::EncryptedKey.new(
33
+ id: id,
34
+ asymmetric_cipher: asymmetric_cipher,
35
+ symmetric_cipher: symmetric_cipher
36
+ ).to_xml(xml: xml)
37
+ end
38
+
39
+ # @deprecated Use {#encrypt_data_for} instead of this
40
+ def encryption_for(*args, &block)
41
+ ::Xml::Kit.deprecate(
42
+ 'encryption_for is deprecated. Use encrypt_data_for instead.'
43
+ )
44
+ encrypt_data_for(*args, &block)
45
+ end
46
+
47
+ # Generates an {#Xml::Kit::EncryptedData} section. https://www.w3.org/TR/xmlenc-core1/#sec-EncryptedData
48
+ #
49
+ # @since 0.3.0
50
+ # @param xml [Builder::XmlMarkup] the xml builder instance
51
+ # @param key_info [Xml::Kit::KeyInfo] the key info to render in the EncryptedData
52
+ def encrypt_data_for(xml:, key_info: nil)
53
+ return yield xml unless encrypt?
54
+
55
+ temp = ::Builder::XmlMarkup.new
56
+ yield temp
57
+ ::Xml::Kit::EncryptedData.new(
58
+ signatures.complete(temp.target!),
59
+ symmetric_cipher: symmetric_cipher,
60
+ asymmetric_cipher: asymmetric_cipher,
61
+ key_info: key_info
62
+ ).to_xml(xml: xml)
63
+ end
64
+
65
+ # Provides a default RSA asymmetric cipher. Can be overridden to provide custom ciphers.
66
+ #
67
+ # @abstract
68
+ # @since 0.3.0
69
+ def asymmetric_cipher(algorithm: Crypto::RsaCipher::ALGORITHM)
70
+ @asymmetric_cipher ||= Crypto.cipher_for(
71
+ algorithm,
72
+ encryption_certificate.public_key
73
+ )
74
+ end
75
+
76
+ # Provides a default aes256-cbc symmetric cipher. Can be overridden to provide custom ciphers.
77
+ #
78
+ # @abstract
79
+ # @since 0.3.0
80
+ def symmetric_cipher
81
+ @symmetric_cipher ||= Crypto::SymmetricCipher.new
36
82
  end
37
83
 
38
84
  def render(model, options)
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  xml.KeyDescriptor use ? { use: use } : {} do
4
- xml.KeyInfo "xmlns": ::Xml::Kit::Namespaces::XMLDSIG do
5
- xml.X509Data do
6
- xml.X509Certificate stripped
7
- end
8
- end
4
+ render key_info, xml: xml
9
5
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ xml.EncryptedData xmlns: ::Xml::Kit::Namespaces::XMLENC do
4
+ xml.EncryptionMethod Algorithm: symmetric_cipher.algorithm
5
+ render key_info, xml: xml
6
+ xml.CipherData do
7
+ xml.CipherValue symmetric_cipher_value
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ xml.EncryptedKey Id: id, xmlns: ::Xml::Kit::Namespaces::XMLENC do
4
+ xml.EncryptionMethod Algorithm: asymmetric_cipher.algorithm
5
+ render(key_info, xml: xml) if key_info
6
+ xml.CipherData do
7
+ xml.CipherValue cipher_value
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ xml.KeyInfo xmlns: ::Xml::Kit::Namespaces::XMLDSIG do
4
+ xml.KeyName key_name if key_name
5
+ render(key_value, xml: xml) if @key_value
6
+ render(retrieval_method, xml: xml) if @retrieval_method
7
+ if x509_data
8
+ xml.X509Data do
9
+ xml.X509SKI subject_key_identifier
10
+ xml.X509Certificate ::Xml::Kit::Certificate.strip(x509_data.to_pem)
11
+ end
12
+ end
13
+ render(encrypted_key, xml: xml) if encrypted_key
14
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ xml.KeyValue do
4
+ render(rsa, xml: xml) if @rsa
5
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ xml.RetrievalMethod xmlns: ::Xml::Kit::Namespaces::XMLDSIG, URI: uri, Type: type
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ xml.RSAKeyValue do
4
+ xml.Modulus modulus
5
+ xml.Exponent exponent
6
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Xml
4
4
  module Kit
5
- VERSION = '0.2.0'.freeze
5
+ VERSION = '0.3.0'.freeze
6
6
  end
7
7
  end
data/xml-kit.gemspec CHANGED
@@ -29,7 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'nokogiri', '>= 1.8.5'
30
30
  spec.add_dependency 'tilt', '>= 1.4.1'
31
31
  spec.add_dependency 'xmldsig', '~> 0.6'
32
- spec.add_development_dependency 'bundler', '~> 1.16'
33
32
  spec.add_development_dependency 'bundler-audit', '~> 0.6'
34
33
  spec.add_development_dependency 'ffaker', '~> 2.7'
35
34
  spec.add_development_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-04 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.6'
83
- - !ruby/object:Gem::Dependency
84
- name: bundler
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.16'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.16'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: bundler-audit
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -203,7 +189,6 @@ files:
203
189
  - ".gitlab-ci.yml"
204
190
  - ".rspec"
205
191
  - ".rubocop.yml"
206
- - ".rubocop_todo.yml"
207
192
  - ".travis.yml"
208
193
  - Gemfile
209
194
  - LICENSE.txt
@@ -225,9 +210,15 @@ files:
225
210
  - lib/xml/kit/decryption.rb
226
211
  - lib/xml/kit/decryption_error.rb
227
212
  - lib/xml/kit/document.rb
213
+ - lib/xml/kit/encrypted_data.rb
214
+ - lib/xml/kit/encrypted_key.rb
228
215
  - lib/xml/kit/encryption.rb
229
216
  - lib/xml/kit/fingerprint.rb
230
217
  - lib/xml/kit/id.rb
218
+ - lib/xml/kit/key_info.rb
219
+ - lib/xml/kit/key_info/key_value.rb
220
+ - lib/xml/kit/key_info/retrieval_method.rb
221
+ - lib/xml/kit/key_info/rsa_key_value.rb
231
222
  - lib/xml/kit/key_pair.rb
232
223
  - lib/xml/kit/namespaces.rb
233
224
  - lib/xml/kit/self_signed_certificate.rb
@@ -236,8 +227,13 @@ files:
236
227
  - lib/xml/kit/templatable.rb
237
228
  - lib/xml/kit/template.rb
238
229
  - lib/xml/kit/templates/certificate.builder
239
- - lib/xml/kit/templates/encryption.builder
230
+ - lib/xml/kit/templates/encrypted_data.builder
231
+ - lib/xml/kit/templates/encrypted_key.builder
232
+ - lib/xml/kit/templates/key_info.builder
233
+ - lib/xml/kit/templates/key_value.builder
240
234
  - lib/xml/kit/templates/nil_class.builder
235
+ - lib/xml/kit/templates/retrieval_method.builder
236
+ - lib/xml/kit/templates/rsa_key_value.builder
241
237
  - lib/xml/kit/templates/signature.builder
242
238
  - lib/xml/kit/version.rb
243
239
  - xml-kit.gemspec
@@ -261,8 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
257
  - !ruby/object:Gem::Version
262
258
  version: '0'
263
259
  requirements: []
264
- rubyforge_project:
265
- rubygems_version: 2.7.6
260
+ rubygems_version: 3.0.2
266
261
  signing_key:
267
262
  specification_version: 4
268
263
  summary: A simple toolkit for working with XML.
data/.rubocop_todo.yml DELETED
@@ -1,22 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2018-03-03 11:50:08 -0700 using RuboCop version 0.52.1.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 2
10
- Metrics/AbcSize:
11
- Max: 18
12
-
13
- # Offense count: 1
14
- Style/DoubleNegation:
15
- Exclude:
16
- - 'lib/xml/kit/certificate.rb'
17
-
18
- # Offense count: 29
19
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
20
- # URISchemes: http, https
21
- Metrics/LineLength:
22
- Max: 141
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- xml.EncryptedData xmlns: ::Xml::Kit::Namespaces::XMLENC do
4
- xml.EncryptionMethod Algorithm: symmetric_algorithm
5
- xml.KeyInfo xmlns: ::Xml::Kit::Namespaces::XMLDSIG do
6
- xml.EncryptedKey xmlns: ::Xml::Kit::Namespaces::XMLENC do
7
- xml.EncryptionMethod Algorithm: asymmetric_algorithm
8
- xml.CipherData do
9
- xml.CipherValue asymmetric_cipher_value
10
- end
11
- end
12
- end
13
- xml.CipherData do
14
- xml.CipherValue symmetric_cipher_value
15
- end
16
- end