Package io.grpc.alts.internal
Class AltsTsiFrameProtector
- java.lang.Object
-
- io.grpc.alts.internal.AltsTsiFrameProtector
-
- All Implemented Interfaces:
TsiFrameProtector
public final class AltsTsiFrameProtector extends java.lang.Object implements TsiFrameProtector
Frame protector that uses the ALTS framing.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAltsTsiFrameProtector.DeframerState(package private) static classAltsTsiFrameProtector.Protector(package private) static classAltsTsiFrameProtector.Unprotector-
Nested classes/interfaces inherited from interface io.grpc.alts.internal.TsiFrameProtector
TsiFrameProtector.Consumer<T>
-
-
Field Summary
Fields Modifier and Type Field Description private static intHEADER_BYTESprivate static intHEADER_LEN_FIELD_BYTESprivate static intHEADER_TYPE_DEFAULTprivate static intHEADER_TYPE_FIELD_BYTESprivate static intLIMIT_MAX_ALLOWED_FRAME_SIZEprivate static intMAX_FRAME_SIZEprivate static intMIN_FRAME_SIZEprivate AltsTsiFrameProtector.Protectorprotectorprivate AltsTsiFrameProtector.Unprotectorunprotector
-
Constructor Summary
Constructors Constructor Description AltsTsiFrameProtector(int maxProtectedFrameBytes, ChannelCrypterNetty crypter, io.netty.buffer.ByteBufAllocator alloc)Create a new AltsTsiFrameProtector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Must be called to release all associated resources (instance cannot be used afterwards).static intgetHeaderBytes()(package private) static intgetHeaderLenFieldBytes()(package private) static intgetHeaderTypeDefault()(package private) static intgetHeaderTypeFieldBytes()(package private) static intgetLimitMaxAllowedFrameSize()static intgetMaxFrameSize()static intgetMinFrameSize()voidprotectFlush(java.util.List<io.netty.buffer.ByteBuf> unprotectedBufs, TsiFrameProtector.Consumer<io.netty.buffer.ByteBuf> ctxWrite, io.netty.buffer.ByteBufAllocator alloc)Protects the buffers by performing framing and encrypting/appending MACs.voidunprotect(io.netty.buffer.ByteBuf in, java.util.List<java.lang.Object> out, io.netty.buffer.ByteBufAllocator alloc)Unprotects the buffers by removing the framing and decrypting/checking MACs.private static io.netty.buffer.ByteBufwriteSlice(io.netty.buffer.ByteBuf in, int len)
-
-
-
Field Detail
-
HEADER_LEN_FIELD_BYTES
private static final int HEADER_LEN_FIELD_BYTES
- See Also:
- Constant Field Values
-
HEADER_TYPE_FIELD_BYTES
private static final int HEADER_TYPE_FIELD_BYTES
- See Also:
- Constant Field Values
-
HEADER_BYTES
private static final int HEADER_BYTES
- See Also:
- Constant Field Values
-
HEADER_TYPE_DEFAULT
private static final int HEADER_TYPE_DEFAULT
- See Also:
- Constant Field Values
-
LIMIT_MAX_ALLOWED_FRAME_SIZE
private static final int LIMIT_MAX_ALLOWED_FRAME_SIZE
- See Also:
- Constant Field Values
-
MIN_FRAME_SIZE
private static final int MIN_FRAME_SIZE
- See Also:
- Constant Field Values
-
MAX_FRAME_SIZE
private static final int MAX_FRAME_SIZE
- See Also:
- Constant Field Values
-
protector
private final AltsTsiFrameProtector.Protector protector
-
unprotector
private final AltsTsiFrameProtector.Unprotector unprotector
-
-
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.GeneralSecurityExceptionDescription copied from interface:TsiFrameProtectorProtects the buffers by performing framing and encrypting/appending MACs.- Specified by:
protectFlushin interfaceTsiFrameProtector- Parameters:
unprotectedBufs- contain the payload that will be protectedctxWrite- is called with buffers containing protected frames and must release the given buffersalloc- 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.GeneralSecurityExceptionDescription copied from interface:TsiFrameProtectorUnprotects the buffers by removing the framing and decrypting/checking MACs.- Specified by:
unprotectin interfaceTsiFrameProtector- Parameters:
in- contains (partial) protected framesout- is only used to append unprotected payload buffersalloc- is used to allocate new buffers for the unprotected frames- Throws:
java.security.GeneralSecurityException
-
destroy
public void destroy()
Description copied from interface:TsiFrameProtectorMust be called to release all associated resources (instance cannot be used afterwards).- Specified by:
destroyin interfaceTsiFrameProtector
-
writeSlice
private static io.netty.buffer.ByteBuf writeSlice(io.netty.buffer.ByteBuf in, int len)
-
-