Class: Ronin::Support::Crypto::Cipher::AES

Inherits:
Ronin::Support::Crypto::Cipher show all
Defined in:
lib/ronin/support/crypto/cipher/aes.rb

Overview

The AES cipher.

Since:

  • 1.0.0

Direct Known Subclasses

AES128, AES256

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Ronin::Support::Crypto::Cipher

#decrypt, #encrypt, #stream

Constructor Details

#initialize(key_size:, mode: :cbc, **kwargs) ⇒ AES

Initializes the AES cipher.

Parameters:

  • key_size (Integer)

    The desired key size in bits.

  • mode (:cbc, :cfb, :ofb, :ctr, Symbol) (defaults to: :cbc)

    The desired AES cipher mode.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for Ronin::Support::Crypto::Cipher#initialize.

Since:

  • 1.0.0



53
54
55
56
57
58
# File 'lib/ronin/support/crypto/cipher/aes.rb', line 53

def initialize(key_size: , mode: :cbc, **kwargs)
  super("aes-#{key_size}-#{mode}", **kwargs)

  @key_size = key_size
  @mode     = mode
end

Instance Attribute Details

#key_sizeInteger (readonly)

The AES cipher key size.

Returns:

  • (Integer)

    The key size in bits.

Since:

  • 1.0.0



34
35
36
# File 'lib/ronin/support/crypto/cipher/aes.rb', line 34

def key_size
  @key_size
end

#mode:cbc, ... (readonly)

The AES cipher mode.

Returns:

  • (:cbc, :cfb, :ofb, :ctr, Symbol)

Since:

  • 1.0.0



39
40
41
# File 'lib/ronin/support/crypto/cipher/aes.rb', line 39

def mode
  @mode
end

Class Method Details

.supportedArray<String>

The list of supported AES ciphers.

Returns:

  • (Array<String>)

    The list of supported AES cipher names.

Since:

  • 1.0.0



66
67
68
# File 'lib/ronin/support/crypto/cipher/aes.rb', line 66

def self.supported
  super().grep(/^aes/)
end