Class: Izokatu::Openssl::PrivateKey::Default::Decrypter
- Defined in:
- lib/izokatu/openssl/private_key/default/decrypter.rb
Overview
OpenSSL private key decrypter for non-authenticated ciphers
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_OPTIONS =
Default Openssl::PrivateKey::Default::Decrypter option
{ cipher: 'AES256' }.freeze
Instance Attribute Summary collapse
-
#cipher ⇒ String
readonly
OpenSSL private key cipher.
-
#key ⇒ String
readonly
Key for private key encryption/decryption.
-
#nonce ⇒ String
readonly
Initialization vector for one-time use.
Attributes inherited from Decrypter
#decrypted_data, #decrypter, #encrypted_data
Instance Method Summary collapse
-
#create_decrypter! ⇒ OpenSSL::Cipher
private
Initializing decrypter.
-
#decrypt_data! ⇒ Hash
private
Decrypting data.
-
#initialize(encrypted_data:, cipher:, key:, nonce:) ⇒ Decrypter
constructor
Initialize options for OpenSSL EC decryption.
-
#initialize_decrypter_params! ⇒ Object
private
Initializing decrypter params.
Methods inherited from Decrypter
#import_encrypted_data!, #perform
Methods included from Callable
Constructor Details
#initialize(encrypted_data:, cipher:, key:, nonce:) ⇒ Decrypter
Initialize options for OpenSSL EC decryption
32 33 34 35 36 37 38 39 |
# File 'lib/izokatu/openssl/private_key/default/decrypter.rb', line 32 def initialize(encrypted_data:, cipher:, key:, nonce:) super(encrypted_data: encrypted_data) @cipher = cipher || DEFAULT_OPTIONS[:cipher] @key = key @nonce = nonce create_decrypter! initialize_decrypter_params! end |
Instance Attribute Details
#cipher ⇒ String (readonly)
Returns OpenSSL private key cipher.
12 13 14 |
# File 'lib/izokatu/openssl/private_key/default/decrypter.rb', line 12 def cipher @cipher end |
#key ⇒ String (readonly)
Returns key for private key encryption/decryption.
14 15 16 |
# File 'lib/izokatu/openssl/private_key/default/decrypter.rb', line 14 def key @key end |
#nonce ⇒ String (readonly)
Returns initialization vector for one-time use.
16 17 18 |
# File 'lib/izokatu/openssl/private_key/default/decrypter.rb', line 16 def nonce @nonce end |
Instance Method Details
#create_decrypter! ⇒ OpenSSL::Cipher (private)
Initializing decrypter
49 50 51 |
# File 'lib/izokatu/openssl/private_key/default/decrypter.rb', line 49 def create_decrypter! @decrypter = OpenSSL::Cipher.new(cipher).decrypt end |
#decrypt_data! ⇒ Hash (private)
Decrypting data
68 69 70 |
# File 'lib/izokatu/openssl/private_key/default/decrypter.rb', line 68 def decrypt_data! { decrypted_data_string: decrypter.update(encrypted_data) + decrypter.final } end |
#initialize_decrypter_params! ⇒ Object (private)
Initializing decrypter params
57 58 59 60 |
# File 'lib/izokatu/openssl/private_key/default/decrypter.rb', line 57 def initialize_decrypter_params! decrypter.key = key decrypter.iv = nonce end |