Module: PacketGen::Header::Crypto Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Mixin for cryptographic classes
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
- #authenticate! ⇒ Object private
-
#authenticated? ⇒ Boolean
private
Say if crypto modes permit authentication.
-
#confidentiality_mode ⇒ String
private
Get confidentiality mode name.
- #decipher(data) ⇒ Object private
- #encipher(data) ⇒ Object private
-
#set_crypto(conf, intg) ⇒ void
private
Register cryptographic modes.
Instance Method Details
#authenticate! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/packetgen/header/crypto.rb', line 38 def authenticate! @conf.final if @intg @intg.update @esn.to_s if @esn @intg.digest[0, @icv_length] == @icv else true end rescue OpenSSL::Cipher::CipherError false end |
#authenticated? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Say if crypto modes permit authentication
34 35 36 |
# File 'lib/packetgen/header/crypto.rb', line 34 def authenticated? @conf.authenticated? || !@intg.nil? end |
#confidentiality_mode ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get confidentiality mode name
26 27 28 29 30 |
# File 'lib/packetgen/header/crypto.rb', line 26 def confidentiality_mode mode = @conf.name.match(/-([^-]*)$/)[1] raise Error, 'unknown cipher mode' if mode.nil? mode.downcase end |
#decipher(data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 59 |
# File 'lib/packetgen/header/crypto.rb', line 56 def decipher(data) @intg.update(data) if @intg @conf.update(data) end |
#encipher(data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 53 54 |
# File 'lib/packetgen/header/crypto.rb', line 50 def encipher(data) enciphered_data = @conf.update(data) @intg.update(enciphered_data) if @intg enciphered_data end |
#set_crypto(conf, intg) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Register cryptographic modes
16 17 18 19 20 21 22 |
# File 'lib/packetgen/header/crypto.rb', line 16 def set_crypto(conf, intg) @conf = conf @intg = intg return unless conf.authenticated? # #auth_tag_len only supported from ruby 2.4.0 @conf.auth_tag_len = @trunc if @conf.respond_to? :auth_tag_len end |