class Izokatu::Openssl::PublicKey::EC::Encrypter
OpenSSL public key EC
encrypter
Constants
- DEFAULT_ECIES_OPTIONS
Default options for ECIES
Attributes
@return [String] ECIES cipher name
@return [String] ECIES digest name
@return [String] ECIES KDF digest name
@return [String] ECIES MAC digest name
@return [Symbol] ECIES MAC length
@return [String] public key string for decryption
Public Class Methods
Initialize options for OpenSSL EC
encryption
@param clear_data (clear_data
) @param public_key
(public_key
) @param ecies_options Hash with ECIES options
@since 0.1.0
Izokatu::Encrypter::new
# File lib/izokatu/openssl/public_key/ec/encrypter.rb, line 39 def initialize(clear_data:, public_key:, ecies_options:) super(clear_data: clear_data) @public_key = public_key initialize_public_key!(public_key) initialize_ecies_options!(ecies_options || DEFAULT_ECIES_OPTIONS) initialize_encrypter! end
Public Instance Methods
Initialize ECIES options
@param ecies_options Hash with ECIES options
@since 0.1.0
# File lib/izokatu/openssl/public_key/ec/encrypter.rb, line 67 def initialize_ecies_options!(ecies_options) @ecies_cipher = ecies_options[:ecies_cipher] @ecies_digest = ecies_options[:ecies_digest] @ecies_mac_length = ecies_options[:ecies_mac_length] @ecies_kdf_digest = ecies_options[:ecies_kdf_digest] @ecies_mac_digest = ecies_options[:ecies_mac_digest] end
Initialize encrypter
@return [ECIES::Crypt] encrypter instance
@since 0.1.0
# File lib/izokatu/openssl/public_key/ec/encrypter.rb, line 81 def initialize_encrypter! @encrypter = 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 EC
public key from public key string
@param public_key
(public_key
)
@return [OpenSSL:PKey::EC] OpenSSL public key instance
@since 0.1.0
# File lib/izokatu/openssl/public_key/ec/encrypter.rb, line 55 def initialize_public_key!(public_key) raise 'ERROR: No public key!' unless public_key @public_key = OpenSSL::PKey.read(public_key) end
Private Instance Methods
Encrypting data
@return [Array] encrypted data with empty hash in place of params
@since 0.1.0
# File lib/izokatu/openssl/public_key/ec/encrypter.rb, line 99 def encrypt_data! [{ encrypted_data_string: encrypter.encrypt(public_key, clear_data) }, {}] end