Skip to content

API reference / @jsprismarine/native-network / Cfb8

Class: Cfb8 ​

Defined in: native-network/src/Cfb8.ts:47

One direction of an AES-128-CFB8 stream, Java Edition's connection cipher, run in the native library's TLS library. It exists for Bun, whose node:crypto has no aes-128-cfb8; Node.js has its own.

The native cipher holds its key and register until Cfb8.close, so the owner closes it when the connection ends.

Methods ​

close() ​

close(): void

Defined in: native-network/src/Cfb8.ts:102

Frees the native cipher. Closing it again does nothing.

Returns ​

void


update() ​

update(data): Buffer

Defined in: native-network/src/Cfb8.ts:91

Runs the next bytes of the stream through the cipher.

Parameters ​

data ​

Uint8Array

The bytes, which are left as they are.

Returns ​

Buffer

The same number of bytes, encrypted or decrypted.

Throws ​

When the cipher was closed or the library fails.


available() ​

static available(): boolean

Defined in: native-network/src/Cfb8.ts:62

Whether the native cipher is available: a build of the library for this machine loads and has it.

Returns ​

boolean

True when Cfb8.create returns a cipher.


create() ​

static create(direction, key, iv): Cfb8 | undefined

Defined in: native-network/src/Cfb8.ts:74

Starts one direction of a stream.

Parameters ​

direction ​

"encrypt" | "decrypt"

Which way the stream goes.

key ​

Uint8Array

The sixteen-byte AES-128 key.

iv ​

Uint8Array

The sixteen-byte initial register.

Returns ​

Cfb8 | undefined

The cipher, or undefined when the library is missing or predates the cipher.

Throws ​

When the library refuses the key or the register.