Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
Loading...
Searching...
No Matches
CipherStream Class Reference

AES 128bit CFB8 Cipher stream. More...

#include <stream.h>

Inheritance diagram for CipherStream:
IMCStream

Public Member Functions

 CipherStream (IMCStream *baseStream, std::byte *key, std::byte *iv)
 Construct a new Cipher Stream object.
 
 ~CipherStream ()
 Destroy the Cipher Stream object.
 
void read (std::byte *buffer, std::size_t offset, std::size_t len) override
 Reads from an encrypted stream.
 
void write (const std::byte *buffer, std::size_t offset, std::size_t len) override
 Writes to an encrypted stream.
 
size_t available () override
 Gets the number of available bytes Returns the number of available bytes in the sub-stream. Not accurate as to the real length because it doesn't account for the encryption.
 
void finishPacketWrite (const std::byte *packetData, size_t len) override
 Finishes to write the packet in a Minecrafty way.
 
void flush () override
 Flushes the base stream.
 
- Public Member Functions inherited from IMCStream
bool readBoolean ()
 Reads a Boolean.
 
void writeBoolean (bool b)
 Writes a Boolean.
 
std::int8_t readByte ()
 Reads a Byte.
 
void writeByte (std::int8_t b)
 Writes a Byte.
 
std::uint8_t readUnsignedByte ()
 Reads an Unsigned Byte.
 
void writeUnsignedByte (std::uint8_t b)
 Writes an Unsigned Byte.
 
std::int16_t readShort ()
 Reads a Short.
 
void writeShort (std::int16_t s)
 Writes a Short.
 
std::uint16_t readUnsignedShort ()
 Reads an Unsigned Short.
 
void writeUnsignedShort (std::uint16_t s)
 Writes an Unsigned short.
 
std::int32_t readInt ()
 Reads an Integer.
 
void writeInt (std::int32_t i)
 Writes a Integer.
 
std::int64_t readLong ()
 Reads a Long.
 
void writeLong (std::int64_t l)
 Writes a Long.
 
float readFloat ()
 Reads a Float.
 
void writeFloat (float f)
 Writes a Float.
 
double readDouble ()
 Reads a Double.
 
void writeDouble (double d)
 Writes a Double.
 
std::string readString ()
 Reads a String.
 
void writeString (const std::string &s)
 Writes a String.
 
ChatMessage readChat ()
 Reads a Chat Message.
 
void writeChat (const ChatMessage &c)
 Writes a Chat Message.
 
std::int32_t readVarInt ()
 Reads a Variable Integer.
 
void writeVarInt (std::int32_t i)
 Writes a Variable Integer.
 
std::int64_t readVarLong ()
 Reads a Variable Long.
 
void writeVarLong (std::int64_t l)
 Writes a Variable Long.
 
MinecraftUUID readUUID ()
 Reads an MinecraftUUID.
 
void writeUUID (const MinecraftUUID &uuid)
 Writes an MinecraftUUID.
 

Detailed Description

AES 128bit CFB8 Cipher stream.

Cipher stream for minecraft, is updates for every packet and not finalized then restarted.

Constructor & Destructor Documentation

◆ CipherStream()

CipherStream::CipherStream ( IMCStream * baseStream,
std::byte * key,
std::byte * iv )

Construct a new Cipher Stream object.

Parameters
baseStreamthe stream to IO on, the class takes ownership
keythe key for the AES cipher
ivthe IV for the AES cipher

Member Function Documentation

◆ available()

size_t CipherStream::available ( )
overridevirtual

Gets the number of available bytes Returns the number of available bytes in the sub-stream. Not accurate as to the real length because it doesn't account for the encryption.

Warning
Only use to check if there are bytes to read.
Returns
size_t the number of available bytes

Implements IMCStream.

◆ finishPacketWrite()

void CipherStream::finishPacketWrite ( const std::byte * packetData,
size_t len )
overridevirtual

Finishes to write the packet in a Minecrafty way.

Parameters
packetDatathe packet data
lenthe length of the packet data

Implements IMCStream.

◆ flush()

void CipherStream::flush ( )
overridevirtual

Flushes the base stream.

Implements IMCStream.

◆ read()

void CipherStream::read ( std::byte * buffer,
std::size_t offset,
std::size_t len )
overridevirtual

Reads from an encrypted stream.

Parameters
bufferthe buffer to write to
offsetthe offset to start writing to
lenthe length to read from baseStream and write to buffer

Implements IMCStream.

◆ write()

void CipherStream::write ( const std::byte * buffer,
std::size_t offset,
std::size_t len )
overridevirtual

Writes to an encrypted stream.

Parameters
bufferthe buffer to read from
offsetthe offset to start reading from
lenthe length to read from buffer

Implements IMCStream.


The documentation for this class was generated from the following files: