Interface StreamSegmentEncrypter


  • public interface StreamSegmentEncrypter
    StreamSegmentEncrypter is a helper class that encrypts individual segments of a stream.

    Instances of this interfaces are passed to ...EncryptingChannel. Each instance of a segment encrypter is used to encrypt one stream. Typically, constructing a new StreamSegmentEncrypter results in the generation of a new symmetric key. This new symmetric key is used to encrypt the segments of the stream. The key itself wrapped with or derived from the key from StreamingAead instance. The wrapped key or the salt used to derive the symmetric key is part of the header.

    A StreamSegmentEncrypter has a state: it keeps the number of segments encrypted so far. This state is used to encrypt each segment with different parameters, so that segments in the ciphertext cannot be switched.

    Since:
    1.1.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void encryptSegment​(java.nio.ByteBuffer plaintext, boolean isLastSegment, java.nio.ByteBuffer ciphertext)
      Encrypts the next plaintext segment.
      void encryptSegment​(java.nio.ByteBuffer part1, java.nio.ByteBuffer part2, boolean isLastSegment, java.nio.ByteBuffer ciphertext)
      Encrypt a segment consisting of two parts.
      java.nio.ByteBuffer getHeader()
      Returns the header of the ciphertext stream.
    • Method Detail

      • getHeader

        java.nio.ByteBuffer getHeader()
        Returns the header of the ciphertext stream.
      • encryptSegment

        void encryptSegment​(java.nio.ByteBuffer plaintext,
                            boolean isLastSegment,
                            java.nio.ByteBuffer ciphertext)
                     throws java.security.GeneralSecurityException
        Encrypts the next plaintext segment. This uses encryptedSegments as the segment number for the encryption.
        Throws:
        java.security.GeneralSecurityException
      • encryptSegment

        void encryptSegment​(java.nio.ByteBuffer part1,
                            java.nio.ByteBuffer part2,
                            boolean isLastSegment,
                            java.nio.ByteBuffer ciphertext)
                     throws java.security.GeneralSecurityException
        Encrypt a segment consisting of two parts. This method simplifies the case where one part of the plaintext is buffered and the other part is passed in by the caller.
        Throws:
        java.security.GeneralSecurityException