Class CryptoOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.hadoop.crypto.CryptoOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, CanSetDropBehind, IOStatisticsSource, StreamCapabilities, Syncable

@Private @Evolving public class CryptoOutputStream extends FilterOutputStream implements Syncable, CanSetDropBehind, StreamCapabilities, IOStatisticsSource
CryptoOutputStream encrypts data. It is not thread-safe. AES CTR mode is required in order to ensure that the plain text and cipher text have a 1:1 mapping. The encryption is buffer based. The key points of the encryption are (1) calculating counter and (2) padding through stream position.

counter = base + pos/(algorithm blocksize); padding = pos%(algorithm blocksize);

The underlying stream offset is maintained as state. Note that while some of this class' methods are synchronized, this is just to match the threadsafety behavior of DFSOutputStream. See HADOOP-11710.