Class: BlockCipherKit::BaseScheme
- Inherits:
-
Object
- Object
- BlockCipherKit::BaseScheme
- Defined in:
- lib/block_cipher_kit/base_scheme.rb
Direct Known Subclasses
AES256CBCScheme, AES256CFBCIVScheme, AES256CFBScheme, AES256CTRScheme, AES256GCMScheme, PassthruScheme
Instance Method Summary collapse
-
#decrypt_range(from_ciphertext_io:, range:) ⇒ String
Decrypts the desired range of the ciphered message, reading ciphertext out of
from_ciphertext_io. -
#streaming_decrypt(from_ciphertext_io:, into_plaintext_io: nil) {|String| ... } ⇒ void
Decrypts the entire ciphered message, reading ciphertext out of
from_ciphertext_iountil itsreadreturnsnil(until EOF is implicitly reached). -
#streaming_decrypt_range(from_ciphertext_io:, range:, into_plaintext_io: nil) {|String| ... } ⇒ void
Decrypts the desired range of the ciphered message, reading ciphertext out of
from_ciphertext_io. -
#streaming_encrypt(into_ciphertext_io:, from_plaintext_io: nil) {|#write| ... } ⇒ void
Encrypts the entire ciphered message, reading plaintext either from the
from_plaintext_iountil itsreadreturnsnil(until EOF is implicitly reached) or from writes to the object it yields (for streaming writes).
Instance Method Details
#decrypt_range(from_ciphertext_io:, range:) ⇒ String
Decrypts the desired range of the ciphered message, reading ciphertext out of from_ciphertext_io. Reading requires the from_ciphertext_io to be seekable - it must support #pos, ‘#read`and #seek. The decrypted plaintext gets returned as a single concatenated String.
61 62 63 64 65 |
# File 'lib/block_cipher_kit/base_scheme.rb', line 61 def decrypt_range(from_ciphertext_io:, range:) buf = StringIO.new.binmode streaming_decrypt_range(from_ciphertext_io: from_ciphertext_io, range: range, into_plaintext_io: buf) buf.string end |
#streaming_decrypt(from_ciphertext_io:, into_plaintext_io: nil) {|String| ... } ⇒ void
This method returns an undefined value.
Decrypts the entire ciphered message, reading ciphertext out of from_ciphertext_io until its read returns nil (until EOF is implicitly reached). The scheme will also read any data at the start of the IO that it requires for operation, and consume the IO until exhaustion.
15 16 17 |
# File 'lib/block_cipher_kit/base_scheme.rb', line 15 def streaming_decrypt(from_ciphertext_io:, into_plaintext_io: nil, &blk) raise "Unimplemented" end |
#streaming_decrypt_range(from_ciphertext_io:, range:, into_plaintext_io: nil) {|String| ... } ⇒ void
This method returns an undefined value.
Decrypts the desired range of the ciphered message, reading ciphertext out of from_ciphertext_io. Reading requires the from_ciphertext_io to be seekable - it must support #pos, ‘#read`and #seek. The decrypted plaintext either gets written into into_plaintext_io if it is provided, or yielded to the passed block in String chunks.
50 51 52 |
# File 'lib/block_cipher_kit/base_scheme.rb', line 50 def streaming_decrypt_range(from_ciphertext_io:, range:, into_plaintext_io: nil, &blk) raise "Unimplemented" end |
#streaming_encrypt(into_ciphertext_io:, from_plaintext_io: nil) {|#write| ... } ⇒ void
This method returns an undefined value.
Encrypts the entire ciphered message, reading plaintext either from the from_plaintext_io until its read returns nil (until EOF is implicitly reached) or from writes to the object it yields (for streaming writes).
The scheme will also write any leading data at the start of the output that should prefix the ciphertext (usually the IV) and any trailing data after the ciphertext (like a validation tag for cipher authentication) into the into_ciphertext_io.
33 34 35 |
# File 'lib/block_cipher_kit/base_scheme.rb', line 33 def streaming_encrypt(into_ciphertext_io:, from_plaintext_io: nil, &blk) raise "Unimplemented" end |