class Izokatu::Openssl::PrivateKey::Auth::Decrypter

OpenSSL private key decrypter for authenticated ciphers

Constants

DEFAULT_AUTH_TAG_LENGTH

Default Openssl::PrivateKey::Auth::Decrypter option

Attributes

auth_data[R]

@return [String] authenticated data

auth_tag[R]

@return [String] authentication tag

Public Class Methods

new(auth_data:, auth_tag:, cipher:, encrypted_data:, key:, nonce:) click to toggle source

Initializing options for OpenSSL EC decryption

@param encrypted_data (encrypted_data) @param cipher (cipher) @param key (key) @param nonce (nonce) @param auth_data (auth_data) @param auth_tag (auth_tag)

@since 0.1.0

# File lib/izokatu/openssl/private_key/auth/decrypter.rb, line 29
def initialize(auth_data:, auth_tag:, cipher:, encrypted_data:, key:, nonce:)
  @auth_data = auth_data
  @auth_tag = auth_tag
  super(cipher: cipher, encrypted_data: encrypted_data, key: key, nonce: nonce)
end

Public Instance Methods

perform() click to toggle source

Initializing decrypter

@return [OpenSSL::Cipher] decrypter instance

@since 0.1.0

Calls superclass method Izokatu::Decrypter#perform
# File lib/izokatu/openssl/private_key/auth/decrypter.rb, line 41
def perform
  verify_tag_size!
  super
end

Private Instance Methods

initialize_auth_decrypter_params!() click to toggle source

Initializing decrypter auth params

@since 0.1.0

# File lib/izokatu/openssl/private_key/auth/decrypter.rb, line 61
def initialize_auth_decrypter_params!
  # unless added just for ARIA-***-CCM ciphers
  decrypter.auth_data = auth_data unless cipher.include?('ARIA')
  decrypter.auth_tag = auth_tag
end
initialize_decrypter_params!() click to toggle source

Initializing decrypter params

@since 0.1.0

# File lib/izokatu/openssl/private_key/auth/decrypter.rb, line 52
def initialize_decrypter_params!
  super
  initialize_auth_decrypter_params!
end
verify_tag_size!() click to toggle source

Raising exception if auth tag is truncated

@raise RuntimeError

@since 0.1.0

# File lib/izokatu/openssl/private_key/auth/decrypter.rb, line 72
def verify_tag_size!
  raise 'tag is truncated!' unless auth_tag.bytesize == DEFAULT_AUTH_TAG_LENGTH
end