saml-kit 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/saml/kit/version.rb +1 -1
- data/lib/saml/kit/xml_decryption.rb +12 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bf388798a57928e726edb29bf5a4998f43a62139b4cb5da662a73e434b23dae
|
4
|
+
data.tar.gz: 3c5d2bc07e37dcc6f95779bde81cfdff175f5f61929370dcd7fa6950e3614676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee450ff950b85fa7f4d6c6f32a97015eb0cb6ddf530560a243b97a9c5bab3f488f32be5a94bf439614f3d3378eeb8f5bbcbc92d9935d2bdf3f161d08a29ee466
|
7
|
+
data.tar.gz: 81eceb240153a8095a00f82e315b1b623ad3b1c27bb86ce59b2294ebf143d7bc4a57193d2a6ca2a1e31b251e19991d9f0b99d11f914f457972ebc7d27f58a04e
|
data/lib/saml/kit/version.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Saml
|
2
2
|
module Kit
|
3
3
|
class XmlDecryption
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :private_keys
|
5
5
|
|
6
6
|
def initialize(configuration: Saml::Kit.configuration)
|
7
|
-
@
|
7
|
+
@private_keys = configuration.private_keys(use: :encryption)
|
8
8
|
end
|
9
9
|
|
10
10
|
def decrypt(data)
|
@@ -19,7 +19,16 @@ module Saml
|
|
19
19
|
def symmetric_key_from(encrypted_data)
|
20
20
|
encrypted_key = encrypted_data['KeyInfo']['EncryptedKey']
|
21
21
|
cipher_text = Base64.decode64(encrypted_key['CipherData']['CipherValue'])
|
22
|
-
|
22
|
+
attempts = private_keys.count
|
23
|
+
private_keys.each do |private_key|
|
24
|
+
begin
|
25
|
+
attempts -= 1
|
26
|
+
return to_plaintext(cipher_text, private_key, encrypted_key["EncryptionMethod"]['Algorithm'])
|
27
|
+
rescue OpenSSL::PKey::RSAError => error
|
28
|
+
Saml::Kit.logger.error(error)
|
29
|
+
raise if attempts.zero?
|
30
|
+
end
|
31
|
+
end
|
23
32
|
end
|
24
33
|
|
25
34
|
def to_plaintext(cipher_text, symmetric_key, algorithm)
|