Class AltsTsiFrameProtector

  • All Implemented Interfaces:
    TsiFrameProtector

    public final class AltsTsiFrameProtector
    extends java.lang.Object
    implements TsiFrameProtector
    Frame protector that uses the ALTS framing.
    • Constructor Detail

      • AltsTsiFrameProtector

        public AltsTsiFrameProtector​(int maxProtectedFrameBytes,
                                     ChannelCrypterNetty crypter,
                                     io.netty.buffer.ByteBufAllocator alloc)
        Create a new AltsTsiFrameProtector.
    • Method Detail

      • getHeaderLenFieldBytes

        static int getHeaderLenFieldBytes()
      • getHeaderTypeFieldBytes

        static int getHeaderTypeFieldBytes()
      • getHeaderBytes

        public static int getHeaderBytes()
      • getHeaderTypeDefault

        static int getHeaderTypeDefault()
      • getLimitMaxAllowedFrameSize

        static int getLimitMaxAllowedFrameSize()
      • getMinFrameSize

        public static int getMinFrameSize()
      • getMaxFrameSize

        public static int getMaxFrameSize()
      • protectFlush

        public void protectFlush​(java.util.List<io.netty.buffer.ByteBuf> unprotectedBufs,
                                 TsiFrameProtector.Consumer<io.netty.buffer.ByteBuf> ctxWrite,
                                 io.netty.buffer.ByteBufAllocator alloc)
                          throws java.security.GeneralSecurityException
        Description copied from interface: TsiFrameProtector
        Protects the buffers by performing framing and encrypting/appending MACs.
        Specified by:
        protectFlush in interface TsiFrameProtector
        Parameters:
        unprotectedBufs - contain the payload that will be protected
        ctxWrite - is called with buffers containing protected frames and must release the given buffers
        alloc - is used to allocate new buffers for the protected frames
        Throws:
        java.security.GeneralSecurityException
      • unprotect

        public void unprotect​(io.netty.buffer.ByteBuf in,
                              java.util.List<java.lang.Object> out,
                              io.netty.buffer.ByteBufAllocator alloc)
                       throws java.security.GeneralSecurityException
        Description copied from interface: TsiFrameProtector
        Unprotects the buffers by removing the framing and decrypting/checking MACs.
        Specified by:
        unprotect in interface TsiFrameProtector
        Parameters:
        in - contains (partial) protected frames
        out - is only used to append unprotected payload buffers
        alloc - is used to allocate new buffers for the unprotected frames
        Throws:
        java.security.GeneralSecurityException
      • destroy

        public void destroy()
        Description copied from interface: TsiFrameProtector
        Must be called to release all associated resources (instance cannot be used afterwards).
        Specified by:
        destroy in interface TsiFrameProtector
      • writeSlice

        private static io.netty.buffer.ByteBuf writeSlice​(io.netty.buffer.ByteBuf in,
                                                          int len)