Class: Izokatu::Openssl::PublicKey::EC::Decrypter
- Defined in:
- lib/izokatu/openssl/public_key/ec/decrypter.rb
Overview
OpenSSL public key EC decrypter
Constant Summary collapse
- DEFAULT_ECIES_OPTIONS =
Default options for ECIES
{ ecies_cipher: 'AES-256-CTR', ecies_digest: 'SHA512', ecies_mac_length: :full, ecies_kdf_digest: 'SHA512', ecies_mac_digest: 'SHA512' }.freeze
Instance Attribute Summary collapse
-
#ecies_cipher ⇒ String
readonly
ECIES cipher name.
-
#ecies_digest ⇒ String
readonly
ECIES digest name.
-
#ecies_kdf_digest ⇒ String
readonly
ECIES KDF digest name.
-
#ecies_mac_digest ⇒ String
readonly
ECIES MAC digest name.
-
#ecies_mac_length ⇒ Symbol
readonly
ECIES MAC length.
-
#private_key ⇒ String
readonly
Private key string for decryption.
Attributes inherited from Decrypter
#decrypted_data, #decrypter, #encrypted_data
Instance Method Summary collapse
-
#decrypt_data! ⇒ Hash
private
Decrypting data.
-
#initialize(encrypted_data:, private_key:, ecies_options:) ⇒ Decrypter
constructor
A new instance of Decrypter.
-
#initialize_decrypter! ⇒ ECIES::Crypt
Initialize decrypter.
-
#initialize_ecies_options!(ecies_options) ⇒ Object
Initialize ECIES options.
-
#initialize_private_key!(private_key) ⇒ OpenSSL:PKey::EC
Initialize EC private key from private key string.
Methods inherited from Decrypter
#import_encrypted_data!, #perform
Methods included from Callable
Constructor Details
#initialize(encrypted_data:, private_key:, ecies_options:) ⇒ Decrypter
Returns a new instance of Decrypter.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/izokatu/openssl/public_key/ec/decrypter.rb', line 32 def initialize(encrypted_data:, private_key:, ecies_options:) # Initialize options for OpenSSL EC decryption # # @param encrypted_data (#encrypted_data) # @param private_key (#private_key) # @param ecies_options Hash with ECIES options # # @since 0.1.0 super(encrypted_data: encrypted_data) initialize_private_key!(private_key) ( || DEFAULT_ECIES_OPTIONS) initialize_decrypter! end |
Instance Attribute Details
#ecies_cipher ⇒ String (readonly)
Returns ECIES cipher name.
12 13 14 |
# File 'lib/izokatu/openssl/public_key/ec/decrypter.rb', line 12 def ecies_cipher @ecies_cipher end |
#ecies_digest ⇒ String (readonly)
Returns ECIES digest name.
14 15 16 |
# File 'lib/izokatu/openssl/public_key/ec/decrypter.rb', line 14 def ecies_digest @ecies_digest end |
#ecies_kdf_digest ⇒ String (readonly)
Returns ECIES KDF digest name.
18 19 20 |
# File 'lib/izokatu/openssl/public_key/ec/decrypter.rb', line 18 def ecies_kdf_digest @ecies_kdf_digest end |
#ecies_mac_digest ⇒ String (readonly)
Returns ECIES MAC digest name.
20 21 22 |
# File 'lib/izokatu/openssl/public_key/ec/decrypter.rb', line 20 def ecies_mac_digest @ecies_mac_digest end |
#ecies_mac_length ⇒ Symbol (readonly)
Returns ECIES MAC length.
16 17 18 |
# File 'lib/izokatu/openssl/public_key/ec/decrypter.rb', line 16 def ecies_mac_length @ecies_mac_length end |
#private_key ⇒ String (readonly)
Returns private key string for decryption.
10 11 12 |
# File 'lib/izokatu/openssl/public_key/ec/decrypter.rb', line 10 def private_key @private_key end |
Instance Method Details
#decrypt_data! ⇒ Hash (private)
Decrypting data
98 99 100 |
# File 'lib/izokatu/openssl/public_key/ec/decrypter.rb', line 98 def decrypt_data! { decrypted_data_string: decrypter.decrypt(private_key, encrypted_data) } end |
#initialize_decrypter! ⇒ ECIES::Crypt
Initialize decrypter
80 81 82 83 84 85 86 87 88 |
# File 'lib/izokatu/openssl/public_key/ec/decrypter.rb', line 80 def initialize_decrypter! @decrypter = ECIES::Crypt.new( cipher: ecies_cipher, digest: ecies_digest, mac_length: ecies_mac_length, kdf_digest: ecies_kdf_digest, mac_digest: ecies_mac_digest ) end |
#initialize_ecies_options!(ecies_options) ⇒ Object
Initialize ECIES options
66 67 68 69 70 71 72 |
# File 'lib/izokatu/openssl/public_key/ec/decrypter.rb', line 66 def () @ecies_cipher = [:ecies_cipher] @ecies_digest = [:ecies_digest] @ecies_mac_length = [:ecies_mac_length] @ecies_kdf_digest = [:ecies_kdf_digest] @ecies_mac_digest = [:ecies_mac_digest] end |
#initialize_private_key!(private_key) ⇒ OpenSSL:PKey::EC
Initialize EC private key from private key string
54 55 56 57 58 |
# File 'lib/izokatu/openssl/public_key/ec/decrypter.rb', line 54 def initialize_private_key!(private_key) raise 'ERROR: No private key!' unless private_key @private_key = OpenSSL::PKey.read(private_key) end |