Class: BlockCipherKit::AES256CFBCIVScheme
- Inherits:
-
BaseScheme
- Object
- BaseScheme
- BlockCipherKit::AES256CFBCIVScheme
show all
- Defined in:
- lib/block_cipher_kit/aes_256_cfb_civ_scheme.rb
Instance Method Summary
collapse
Methods inherited from BaseScheme
#decrypt_range, #read_copy_stream_via_cipher, #write_copy_stream_via_cipher
Constructor Details
Returns a new instance of AES256CFBCIVScheme.
4
5
6
7
8
|
# File 'lib/block_cipher_kit/aes_256_cfb_civ_scheme.rb', line 4
def initialize(encryption_key, **)
raise ArgumentError, "#{required_encryption_key_length} bytes of key material needed, at the minimum" unless encryption_key.bytesize >= required_encryption_key_length
@iv = BlockCipherKit::KeyMaterial.new(encryption_key.byteslice(0, 16))
@key = BlockCipherKit::KeyMaterial.new(encryption_key.byteslice(16, 32))
end
|
Instance Method Details
#required_encryption_key_length ⇒ Object
10
11
12
|
# File 'lib/block_cipher_kit/aes_256_cfb_civ_scheme.rb', line 10
def required_encryption_key_length
48
end
|
#streaming_decrypt(from_ciphertext_io:, into_plaintext_io: nil, &blk) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/block_cipher_kit/aes_256_cfb_civ_scheme.rb', line 14
def streaming_decrypt(from_ciphertext_io:, into_plaintext_io: nil, &blk)
cipher = OpenSSL::Cipher.new("aes-256-cfb")
cipher.decrypt
cipher.iv = @iv
cipher.key = @key
read_copy_stream_via_cipher(source_io: from_ciphertext_io, cipher: cipher, destination_io: into_plaintext_io, &blk)
end
|
#streaming_decrypt_range(from_ciphertext_io:, range:, into_plaintext_io: nil, &blk) ⇒ Object
30
31
32
33
34
|
# File 'lib/block_cipher_kit/aes_256_cfb_civ_scheme.rb', line 30
def streaming_decrypt_range(from_ciphertext_io:, range:, into_plaintext_io: nil, &blk)
writable = BlockCipherKit::BlockWritable.new(into_plaintext_io, &blk)
lens = BlockCipherKit::IOLens.new(writable, range)
streaming_decrypt(from_ciphertext_io: from_ciphertext_io, into_plaintext_io: lens)
end
|
#streaming_encrypt(into_ciphertext_io:, from_plaintext_io: nil, &blk) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/block_cipher_kit/aes_256_cfb_civ_scheme.rb', line 22
def streaming_encrypt(into_ciphertext_io:, from_plaintext_io: nil, &blk)
cipher = OpenSSL::Cipher.new("aes-256-cfb")
cipher.encrypt
cipher.iv = @iv
cipher.key = @key
write_copy_stream_via_cipher(source_io: from_plaintext_io, cipher: cipher, destination_io: into_ciphertext_io, &blk)
end
|