Class IVSplittingOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class IVSplittingOutputStream
    extends java.io.FilterOutputStream
    IV splitting from the first few bytes in the stream. When the iv is completely received the cipher will be initialized and this output stream will be removed from chain of output streams
    • Constructor Summary

      Constructors 
      Constructor Description
      IVSplittingOutputStream​(java.io.OutputStream out, javax.crypto.Cipher cipher, java.security.Key secretKey, int ivLength)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] getIv()  
      private void initializeCipher()  
      boolean isIVComplete()  
      void setParentOutputStream​(ReplaceableOuputStream replaceableOuputStream)  
      void write​(byte[] b)  
      void write​(byte[] b, int off, int len)  
      void write​(int b)  
      • Methods inherited from class java.io.FilterOutputStream

        close, flush
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • iv

        private final byte[] iv
      • ivLength

        private final int ivLength
      • pos

        private int pos
      • cipher

        private final javax.crypto.Cipher cipher
      • secretKey

        private final java.security.Key secretKey
    • Constructor Detail

      • IVSplittingOutputStream

        public IVSplittingOutputStream​(java.io.OutputStream out,
                                       javax.crypto.Cipher cipher,
                                       java.security.Key secretKey,
                                       int ivLength)
    • Method Detail

      • getIv

        public byte[] getIv()
      • isIVComplete

        public boolean isIVComplete()
      • initializeCipher

        private void initializeCipher()
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public void write​(int b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • setParentOutputStream

        public void setParentOutputStream​(ReplaceableOuputStream replaceableOuputStream)