diff options
Diffstat (limited to 'lib/xml')
| -rw-r--r-- | lib/xml/kit/certificate.rb | 2 | ||||
| -rw-r--r-- | lib/xml/kit/decryption.rb | 10 | ||||
| -rw-r--r-- | lib/xml/kit/templatable.rb | 4 |
3 files changed, 5 insertions, 11 deletions
diff --git a/lib/xml/kit/certificate.rb b/lib/xml/kit/certificate.rb index 46df7d6..559979f 100644 --- a/lib/xml/kit/certificate.rb +++ b/lib/xml/kit/certificate.rb @@ -7,9 +7,7 @@ module Xml # {include:file:spec/xml/kit/certificate_spec.rb} class Certificate include Templatable - # rubocop:disable Metrics/LineLength BASE64_FORMAT = %r(\A([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?\Z).freeze - # rubocop:enable Metrics/LineLength BEGIN_CERT = /-----BEGIN CERTIFICATE-----/.freeze END_CERT = /-----END CERTIFICATE-----/.freeze # The use can be `:signing` or `:encryption`. Use `nil` for both. diff --git a/lib/xml/kit/decryption.rb b/lib/xml/kit/decryption.rb index 98535bc..0a9aa29 100644 --- a/lib/xml/kit/decryption.rb +++ b/lib/xml/kit/decryption.rb @@ -56,12 +56,10 @@ module Xml def symmetric_key_from(encrypted_key, attempts = private_keys.count) cipher, algorithm = cipher_and_algorithm_from(encrypted_key) private_keys.each do |private_key| - begin - attempts -= 1 - return to_plaintext(cipher, private_key, algorithm) - rescue OpenSSL::PKey::RSAError - raise if attempts.zero? - end + attempts -= 1 + return to_plaintext(cipher, private_key, algorithm) + rescue OpenSSL::PKey::RSAError + raise if attempts.zero? end raise DecryptionError, private_keys end diff --git a/lib/xml/kit/templatable.rb b/lib/xml/kit/templatable.rb index 0f53325..3fd2daa 100644 --- a/lib/xml/kit/templatable.rb +++ b/lib/xml/kit/templatable.rb @@ -76,9 +76,7 @@ module Xml # @abstract # @since 0.3.0 def asymmetric_cipher(algorithm: Crypto::RsaCipher::ALGORITHM) - unless encryption_certificate - raise Xml::Kit::Error, 'encryption_certificate is not specified.' - end + raise Xml::Kit::Error, 'encryption_certificate is not specified.' unless encryption_certificate @asymmetric_cipher ||= Crypto.cipher_for( algorithm, |
