summaryrefslogtreecommitdiff
path: root/lib/xml/kit
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2021-01-30 21:37:05 -0700
committermo khan <mo.khan@gmail.com>2021-01-30 21:37:05 -0700
commit9d46474008bcf7945a8c4a479852ccfd3d6fa811 (patch)
treecfeeb0065e0bc25897f117d78af80f8ced148742 /lib/xml/kit
parent2bdb4a1b341160c52a39cc0d339f6f6b4514ad08 (diff)
style: fix linter errorsv0.5.0
Diffstat (limited to 'lib/xml/kit')
-rw-r--r--lib/xml/kit/certificate.rb2
-rw-r--r--lib/xml/kit/decryption.rb10
-rw-r--r--lib/xml/kit/templatable.rb4
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,