From 1f9708e7ae8189ad61a3f1b1cb9b6aa247f05b6e Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Thu, 12 Sep 2019 06:57:59 +0500 Subject: [PATCH] Rename attribute RSAPublicKey#private_key_pem_key to #private_key_pem_secret --- .../staffs/x509_certificates/private_keys_controller.rb | 2 +- app/controllers/staffs/x509_certificates_controller.rb | 2 +- app/interactors/create_rsa_keys.rb | 2 +- app/interactors/decrypt_rsa_private_key.rb | 2 +- app/models/rsa_public_key.rb | 2 +- .../create_rsa_keys_and_x509_self_signed_certificate_spec.rb | 2 +- spec/interactors/create_rsa_keys_spec.rb | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/staffs/x509_certificates/private_keys_controller.rb b/app/controllers/staffs/x509_certificates/private_keys_controller.rb index 36f380c..ef47221 100644 --- a/app/controllers/staffs/x509_certificates/private_keys_controller.rb +++ b/app/controllers/staffs/x509_certificates/private_keys_controller.rb @@ -30,7 +30,7 @@ private end def set_secret - @rsa_public_key.private_key_pem_key = + @rsa_public_key.private_key_pem_secret = Base64.urlsafe_decode64 params[:private_key_secret] end end diff --git a/app/controllers/staffs/x509_certificates_controller.rb b/app/controllers/staffs/x509_certificates_controller.rb index 0c8859e..4503cb3 100644 --- a/app/controllers/staffs/x509_certificates_controller.rb +++ b/app/controllers/staffs/x509_certificates_controller.rb @@ -38,7 +38,7 @@ class Staffs::X509CertificatesController < ApplicationController redirect_to staff_x509_certificate_url( result.certificate, private_key_secret: Base64.urlsafe_encode64( - result.public_key.private_key_pem_key, + result.public_key.private_key_pem_secret, ), ) end diff --git a/app/interactors/create_rsa_keys.rb b/app/interactors/create_rsa_keys.rb index c1c42f9..08e58f6 100644 --- a/app/interactors/create_rsa_keys.rb +++ b/app/interactors/create_rsa_keys.rb @@ -15,7 +15,7 @@ class CreateRSAKeys bits: BITS, public_key_pem: @pkey.public_key.to_pem.freeze, private_key_pem_iv: @iv, - private_key_pem_key: @key, + private_key_pem_secret: @key, private_key_pem_ciphertext: @ciphertext, ) end diff --git a/app/interactors/decrypt_rsa_private_key.rb b/app/interactors/decrypt_rsa_private_key.rb index 087fac0..45a733b 100644 --- a/app/interactors/decrypt_rsa_private_key.rb +++ b/app/interactors/decrypt_rsa_private_key.rb @@ -19,6 +19,6 @@ private @cipher.decrypt @cipher.iv = context.public_key.private_key_pem_iv - @cipher.key = context.public_key.private_key_pem_key + @cipher.key = context.public_key.private_key_pem_secret end end diff --git a/app/models/rsa_public_key.rb b/app/models/rsa_public_key.rb index 6f3caf9..42f29ce 100644 --- a/app/models/rsa_public_key.rb +++ b/app/models/rsa_public_key.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class RSAPublicKey < ApplicationRecord - attr_accessor :private_key_pem_key + attr_accessor :private_key_pem_secret ############### # Validations # diff --git a/spec/interactors/create_rsa_keys_and_x509_self_signed_certificate_spec.rb b/spec/interactors/create_rsa_keys_and_x509_self_signed_certificate_spec.rb index e0e8690..3025906 100644 --- a/spec/interactors/create_rsa_keys_and_x509_self_signed_certificate_spec.rb +++ b/spec/interactors/create_rsa_keys_and_x509_self_signed_certificate_spec.rb @@ -40,6 +40,6 @@ RSpec.describe CreateRSAKeysAndX509SelfSignedCertificate do end specify do - expect(subject.public_key.private_key_pem_key).not_to be_blank + expect(subject.public_key.private_key_pem_secret).not_to be_blank end end diff --git a/spec/interactors/create_rsa_keys_spec.rb b/spec/interactors/create_rsa_keys_spec.rb index 166837f..3d44354 100644 --- a/spec/interactors/create_rsa_keys_spec.rb +++ b/spec/interactors/create_rsa_keys_spec.rb @@ -26,7 +26,7 @@ RSpec.describe CreateRSAKeys do end specify do - expect(subject.public_key.private_key_pem_key).not_to be_blank + expect(subject.public_key.private_key_pem_secret).not_to be_blank end specify do @@ -55,7 +55,7 @@ RSpec.describe CreateRSAKeys do cipher = OpenSSL::Cipher::AES256.new cipher.decrypt cipher.iv = subject.public_key.private_key_pem_iv - cipher.key = subject.public_key.private_key_pem_key + cipher.key = subject.public_key.private_key_pem_secret cleartext = [ cipher.update(subject.public_key.private_key_pem_ciphertext),