class TlsEngine
source · line 44public class TlsEngine private constructor(private var handle: ULong) : Closeable
- Supertype
Closeable - Inherited
fun dispose(): Unit· Closeable
A transport-independent TLS state machine with explicit ciphertext input and output. The caller drives handshake, transfer, verification, and shutdown steps and serializes access to the engine. Close it to release the native session.
function write
source · line 141@Unsafe public fun write(borrow: NativeByteBorrow): TlsStep
Attempts to encrypt a nonempty readable native borrow, accepting at most 16,384 bytes. The caller keeps the borrow alive and accounts for the returned count.
parameter borrow
source · line 141borrow: NativeByteBorrow
function handshake
source · line 94public fun handshake(): TlsStep
Advances the handshake once and reports whether to feed input, drain output, or perform certificate verification.
function takeCiphertext
source · line 169public fun takeCiphertext(buffer: NativeByteBuffer, requested: Long = buffer.writableBytes): Long
Appends up to the requested pending ciphertext bytes to writable buffer space and returns the amount drained.
parameter requested
source · line 169requested: Long = buffer.writableBytes
parameter buffer
source · line 169buffer: NativeByteBuffer
property connectionInfo
source · line 77public val connectionInfo: TlsConnectionInfo
get: public read-only
The negotiated version and ALPN after handshake completion; querying too early throws IllegalStateException.
getter get
source · line 77get(): TlsConnectionInfo
function takeVerification
source · line 105@Unsafe public fun takeVerification(): Ptr<Unit>
Takes the pending native verification work. Run it, complete it on this engine, and release it exactly once; keep the pointer valid throughout those operations.
function shutdown
source · line 99public fun shutdown(): TlsStep
Advances the TLS close handshake once. The caller continues driving the indicated transport or verification work.
property inputCapacity
source · line 68public val inputCapacity: Long
get: public read-only
The number of additional ciphertext bytes the engine can currently accept.
getter get
source · line 68get(): Long
function close
source · line 187public override fun close(): Unit
- Overrides
close
Releases the native session without driving a network shutdown. Repeated closes are allowed.
function completeVerification
source · line 112@Unsafe public fun completeVerification(work: Ptr<Unit>): Unit
Applies the result of completed verification work to this engine. The caller still owns and must release the work record.
parameter work
source · line 112work: Ptr<Unit>
function verify
source · line 120public fun verify(): Unit
Runs pending certificate verification synchronously, applies its result, and releases the native work record even on failure.
property pendingOutput
source · line 72public val pendingOutput: Long
get: public read-only
The ciphertext byte count available for draining to the transport.
getter get
source · line 72get(): Long
function endInput
source · line 183public fun endInput(): Unit
Marks the ciphertext transport as ended so subsequent steps can distinguish an orderly TLS close from truncation.
function receiveCiphertext
source · line 151public fun receiveCiphertext(buffer: NativeByteBuffer, requested: Long = buffer.readableBytes): Long
Consumes up to the requested readable ciphertext bytes, limited by engine capacity, and advances the input buffer by the accepted count.
parameter buffer
source · line 151buffer: NativeByteBuffer
parameter requested
source · line 151requested: Long = buffer.readableBytes
function read
source · line 132@Unsafe public fun read(borrow: NativeByteBorrow): TlsStep
Attempts to decrypt into a nonempty writable native borrow. The caller keeps the borrow alive and completes it with the actual transferred count.
parameter borrow
source · line 132borrow: NativeByteBorrow