Method: HexaPDF::Encryption::AES#initialize
- Defined in:
- lib/hexapdf/encryption/aes.rb
#initialize(key, iv, mode) ⇒ Object
Creates a new AES object using the given encryption key and initialization vector.
The mode must either be :encrypt or :decrypt.
Classes prepending this module have to have their own initialization method as this method just performs basic checks.
213 214 215 216 217 218 219 220 221 222 |
# File 'lib/hexapdf/encryption/aes.rb', line 213 def initialize(key, iv, mode) unless VALID_KEY_LENGTH.include?(key.length) raise HexaPDF::EncryptionError, "AES key length must be 128, 192 or 256 bit" end unless iv.length == BLOCK_SIZE raise HexaPDF::EncryptionError, "AES initialization vector length must be 128 bit" end mode = mode.intern super end |