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
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/packetgen/plugin/crypto.rb', line 47 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
41 42 43 |
# File 'lib/packetgen/plugin/crypto.rb', line 41 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
32 33 34 35 36 37 |
# File 'lib/packetgen/plugin/crypto.rb', line 32 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
71 72 73 74 |
# File 'lib/packetgen/plugin/crypto.rb', line 71 def decipher(data) @intg&.update(data) @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
62 63 64 65 66 |
# File 'lib/packetgen/plugin/crypto.rb', line 62 def encipher(data) enciphered_data = @conf.update(data) @intg&.update(enciphered_data) 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 28 |
# 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 |