Class: ActiveCipherStorage::Adapters::S3Adapter::StreamingDecryptor
- Inherits:
-
Object
- Object
- ActiveCipherStorage::Adapters::S3Adapter::StreamingDecryptor
- Includes:
- KeyUtils
- Defined in:
- lib/active_cipher_storage/adapters/s3_adapter.rb
Overview
Accumulates bytes from a streaming S3 response, parses ACS frames as they arrive, and yields each decrypted plaintext chunk. Frame layout: seq(4) + iv(12) + ct_len(4) + ciphertext(ct_len) + auth_tag(16).
Constant Summary collapse
Instance Method Summary collapse
- #finish! ⇒ Object
-
#initialize(config) ⇒ StreamingDecryptor
constructor
A new instance of StreamingDecryptor.
- #push(bytes, &block) ⇒ Object
Constructor Details
#initialize(config) ⇒ StreamingDecryptor
Returns a new instance of StreamingDecryptor.
177 178 179 180 181 182 183 |
# File 'lib/active_cipher_storage/adapters/s3_adapter.rb', line 177 def initialize(config) @config = config @buffer = "".b @dek = nil @header_done = false @done = false end |
Instance Method Details
#finish! ⇒ Object
192 193 194 195 196 |
# File 'lib/active_cipher_storage/adapters/s3_adapter.rb', line 192 def finish! raise Errors::InvalidFormat, "Stream ended before final frame" unless @done ensure zero_bytes!(@dek) end |
#push(bytes, &block) ⇒ Object
185 186 187 188 189 190 |
# File 'lib/active_cipher_storage/adapters/s3_adapter.rb', line 185 def push(bytes, &block) return if @done @buffer += bytes.b try_parse_header unless @header_done drain_frames(&block) if @header_done end |