Package io.grpc.alts.internal
Class AltsTsiFrameProtector
java.lang.Object
io.grpc.alts.internal.AltsTsiFrameProtector
- All Implemented Interfaces:
TsiFrameProtector
Frame protector that uses the ALTS framing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enum
(package private) static final class
(package private) static final class
Nested classes/interfaces inherited from interface io.grpc.alts.internal.TsiFrameProtector
TsiFrameProtector.Consumer<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private final AltsTsiFrameProtector.Protector
private final AltsTsiFrameProtector.Unprotector
-
Constructor Summary
ConstructorsConstructorDescriptionAltsTsiFrameProtector
(int maxProtectedFrameBytes, ChannelCrypterNetty crypter, io.netty.buffer.ByteBufAllocator alloc) Create a new AltsTsiFrameProtector. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Must be called to release all associated resources (instance cannot be used afterwards).static int
(package private) static int
(package private) static int
(package private) static int
(package private) static int
static int
static int
void
protectFlush
(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.void
Unprotects the buffers by removing the framing and decrypting/checking MACs.private static io.netty.buffer.ByteBuf
writeSlice
(io.netty.buffer.ByteBuf in, int len)
-
Field Details
-
HEADER_LEN_FIELD_BYTES
private static final int HEADER_LEN_FIELD_BYTES- See Also:
-
HEADER_TYPE_FIELD_BYTES
private static final int HEADER_TYPE_FIELD_BYTES- See Also:
-
HEADER_BYTES
private static final int HEADER_BYTES- See Also:
-
HEADER_TYPE_DEFAULT
private static final int HEADER_TYPE_DEFAULT- See Also:
-
LIMIT_MAX_ALLOWED_FRAME_SIZE
private static final int LIMIT_MAX_ALLOWED_FRAME_SIZE- See Also:
-
MIN_FRAME_SIZE
private static final int MIN_FRAME_SIZE- See Also:
-
MAX_FRAME_SIZE
private static final int MAX_FRAME_SIZE- See Also:
-
protector
-
unprotector
-
-
Constructor Details
-
AltsTsiFrameProtector
public AltsTsiFrameProtector(int maxProtectedFrameBytes, ChannelCrypterNetty crypter, io.netty.buffer.ByteBufAllocator alloc) Create a new AltsTsiFrameProtector.
-
-
Method Details
-
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(List<io.netty.buffer.ByteBuf> unprotectedBufs, TsiFrameProtector.Consumer<io.netty.buffer.ByteBuf> ctxWrite, io.netty.buffer.ByteBufAllocator alloc) throws GeneralSecurityException Description copied from interface:TsiFrameProtector
Protects the buffers by performing framing and encrypting/appending MACs.- Specified by:
protectFlush
in 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:
GeneralSecurityException
-
unprotect
public void unprotect(io.netty.buffer.ByteBuf in, List<Object> out, io.netty.buffer.ByteBufAllocator alloc) throws GeneralSecurityException Description copied from interface:TsiFrameProtector
Unprotects the buffers by removing the framing and decrypting/checking MACs.- Specified by:
unprotect
in 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:
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 interfaceTsiFrameProtector
-
writeSlice
private static io.netty.buffer.ByteBuf writeSlice(io.netty.buffer.ByteBuf in, int len)
-