Method: ECIES::Crypt#initialize
- Defined in:
- lib/ecies/crypt.rb
#initialize(cipher: 'AES-256-CTR', digest: 'SHA256', mac_length: :half, kdf_digest: nil, mac_digest: nil, kdf_shared_info: '', mac_shared_info: '') ⇒ Crypt
Creates a new instance of ECIES::Crypt.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ecies/crypt.rb', line 38 def initialize(cipher: 'AES-256-CTR', digest: 'SHA256', mac_length: :half, kdf_digest: nil, mac_digest: nil, kdf_shared_info: '', mac_shared_info: '') @cipher = OpenSSL::Cipher.new(cipher) @mac_digest = OpenSSL::Digest.new(mac_digest || digest) @kdf_digest = OpenSSL::Digest.new(kdf_digest || digest) @kdf_shared_info = kdf_shared_info @mac_shared_info = mac_shared_info CIPHERS.include?(@cipher.name) or raise "Cipher must be one of #{CIPHERS}" DIGESTS.include?(@mac_digest.name) or raise "Digest must be one of #{DIGESTS}" DIGESTS.include?(@kdf_digest.name) or raise "Digest must be one of #{DIGESTS}" [:half, :full].include?(mac_length) or raise "mac_length must be :half or :full" @mac_length = @mac_digest.digest_length @mac_length /= 2 if mac_length == :half end |