The first release of the TLS 1.3 protocol implementation in Java with GOST algorithms according to RFC 9367

Module crypto-gost-tls13 contains an implementation of TLS 1.3 (RFC 8446 + RFC 9367) with GOST cryptography. This release is the initial version of the library and is ready for internal use.

A distinctive feature of the library is its implementation in pure Java. All cryptographic operations are performed using the library's built-in features β€” without external dependencies.

This is one of the first open implementations of TLS 1.3 with GOST on Java, so interop testing has been done in the minimally available scope.

Below are the capabilities of the library.

  1. Protocols:
  • Handshake: full (client/server), abbreviated (PSK), mutual (mTLS).
  • ALPN (RFC 7301) β€” application layer protocol negotiation (HTTP/2, HTTP/1.1).
  • SNI (RFC 6066) β€” name indication server for multi-tenant deployments.
  • KeyUpdate (RFC 8446 Β§4.6.3) β€” updating traffic encryption keys.
  • Cipher suites: TLS_KUZNYECHIK_MGM_STREEBOG_256_L/S.
  • ECDHE: CryptoPro-A (256-bit), CryptoPro-B (512-bit)
  • Per-record TLSTREE re-keying β€” changing the encryption key for each TLS record.
  • Fragmentation and assembly of handshakes and records (RFC 8446 Β§5.1).
  • Session resumption: PSK via NewSessionTicket (PskStore in-memory, single-use).
  • OCSP stapling: server attaches the OCSP response to the certificate.
  • Post-handshake messages: NewSessionTicket (saved for PSK).
  1. Cryptography:
  • Key schedule: HKDF-Streebog (RFC 5869) according to TLS 1.3 scheme (RFC 8446 Β§7.1).
  • Record protection: MGM-AEAD (Kuznyechik) with nonce as per RFC 8446 Β§5.3.
  • Ephemeral keys are wiped after use.
  1. Certificates:
  • Parsing X.509v3 (GOST R 34.10-2012) β€” built-in DER parser.
  • Chain validation: signatures, DN (issuer β†’ subject), Basic Constraints, Key Usage, Extended Key Usage (serverAuth/clientAuth), pathLen.
  • Hostname verification: dNSName + iPAddress (RFC 6125).
  • Verifying OCSP responses (RFC 6960).

4.Transport:

  • TlsTransport β€” interface.
  • InMemoryTlsTransport β€” for tests and single-process scenarios (in-memory queue).
  • SocketTlsTransport β€” blocking I/O via java.net.Socket.
  • ChannelTlsTransport β€” NIO SocketChannel-based transport (blocking mode, interruptible).
  1. Step-by-step handshake:
  • TlsHandshakeEngine β€” state machine for handshake (decoupled from I/O). TlsSession is used as an orchestrator; suitable for integration with JSSE (SSLEngine).
  1. ByteBuffer API:
  • TlsRecord.protect/unprotect β€” ByteBuffer overloads for zero-copy integration with NIO. Key loading:
  • Pkcs12Loader β€” reading PFX (PKCS#12) with PBKDF2-HMAC-SHA256 + AES-256-CBC.
  1. Session termination:
  • close_notify β€” correct closure according to the protocol.
  • Wiping key material upon closure or error.
  • Alert handling: fatal β€” immediate closure + wiping.
  1. Implementation security:
  • Constant-time comparison for verify_data and PSK binders (protection against timing attacks)
  • Key material zeroing: destroy() on all objects with keys (TlsKeySchedule, TlsTrafficKeys, TlsRecord, HandshakeContext), during close, fatal alert, exception in handshake
  • DoS protection: limits on certificate chain length (10), post-handshake messages, record size.
  • MGM nonce: MSB of the first byte is cleared for ICN (RFC 9058 Β§3, RFC 9367 Β§3.3).
  • ECDHE private key and handshake transcript are destroyed after completion of the handshake.
  • HMAC key material is zeroed after use (HkdfStreebog, KdfGostR3411_2012_256).
  1. Limitations:
  • Only resumption PSK (0-RTT and external PSK are not supported).
  • Only psk_dhe_ke (pure PSK without ECDHE is not supported).
  • HelloRetryRequest (RFC 8446 Β§4.1.4) is not supported β€” only one named group is used (GC256A by default).
  • Only GOST (non-GOST cipher suites are not supported).
  1. Testing:
  • The library contains Known Answer Tests from RFC 9367 Appendix A.1 (L and S variants) β€” complete key schedule, TLSTREE, AEAD, ECDHE. It passes a full range of KAT tests.
  • 4 integration tests (self-interop) via real TCP sockets.
  • Fuzz testing for parsers: TlsMessageParser (8 methods), TlsDerParser (3 methods), TlsOcspVerifier (1 method), to ensure security and reduce the attack vector on parsers.
  1. Architectural solutions:
  • TlsHandshakeEngine β€” a state machine decoupled from I/O (for future JSSE module).
  • ByteBuffer overloads TlsRecord.protect/unprotect for NIO/JSSE.
  • TLSTREE cache (TlsTreeCache) β€” recalculation only of changed levels (RFC 9367).
  • InMemoryTlsTransport.Pair β€” a bidirectional pair for testing and single-process interaction.

The library is distributed under a free license.

Source: linux.org.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers πŸ”₯ Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster