Module: PacketGen::Plugin::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! ⇒ Boolean
private
Check authentication.
-
#authenticated? ⇒ Boolean
private
Say if crypto modes permit authentication.
-
#confidentiality_mode ⇒ String
private
Get confidentiality mode name.
-
#decipher(data) ⇒ String
private
Decipher
data
. -
#encipher(data) ⇒ String
private
Encipher
data
. -
#set_crypto(conf, intg) ⇒ void
private
Register cryptographic modes.
Instance Method Details
#authenticate! ⇒ 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.
Check authentication
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/packetgen/plugin/crypto.rb', line 45 def authenticate! @conf.final if @intg @intg.update @esn.to_s if defined? @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
39 40 41 |
# File 'lib/packetgen/plugin/crypto.rb', line 39 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
31 32 33 34 35 |
# File 'lib/packetgen/plugin/crypto.rb', line 31 def confidentiality_mode mode = @conf.name.match(/-([^-]*)$/)[1] raise Error, 'unknown cipher mode' if mode.nil? mode.downcase end |
#decipher(data) ⇒ 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.
Decipher data
69 70 71 72 |
# File 'lib/packetgen/plugin/crypto.rb', line 69 def decipher(data) @intg.update(data) if @intg @conf.update(data) end |
#encipher(data) ⇒ 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.
Encipher data
60 61 62 63 64 |
# File 'lib/packetgen/plugin/crypto.rb', line 60 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
21 22 23 24 25 26 27 |
# File 'lib/packetgen/plugin/crypto.rb', line 21 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 |