PHPackages                             tourze/tls-extension-naming - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. tourze/tls-extension-naming

ActiveLibrary

tourze/tls-extension-naming
===========================

TLS Extension Naming Package

0.0.1(11mo ago)053MITPHPPHP ^8.1CI passing

Since Jun 15Pushed 4mo agoCompare

[ Source](https://github.com/tourze/tls-extension-naming)[ Packagist](https://packagist.org/packages/tourze/tls-extension-naming)[ RSS](/packages/tourze-tls-extension-naming/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

TLS Extension Naming Package
============================

[](#tls-extension-naming-package)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/30c1fda8c2c7f152b8f43cff00b35d61d587d4ff9295faebf5a231706cd014e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f746c732d657874656e73696f6e2d6e616d696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/tls-extension-naming)[![Total Downloads](https://camo.githubusercontent.com/14b6c95fef7d7e5ce4b1845bbf4acf0f380ac30fcd247e40e0287dbf02b99ff0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f746c732d657874656e73696f6e2d6e616d696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/tls-extension-naming)[![License](https://camo.githubusercontent.com/e666f77543e3428374e7a272f387057c0084e4c3b66c3fbc9326ebce5cb98131/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f746c732d657874656e73696f6e2d6e616d696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/tls-extension-naming)[![PHP Version](https://camo.githubusercontent.com/e56f7dad722f402ed6252d61c51c3386012c2d809a566d9761b4866242c247aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f746c732d657874656e73696f6e2d6e616d696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/tls-extension-naming)[![Coverage Status](https://camo.githubusercontent.com/c1df6bc48f8a390b16a89a068f70001240da4fcb9c416e299ebeae1c2acac987/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f746f75727a652f7068702d6d6f6e6f7265706f2e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/php-monorepo)

This package provides comprehensive TLS extension naming and handling functionality for PHP applications, implementing various TLS extensions according to RFC specifications.

Features
--------

[](#features)

- Full implementation of 20+ common TLS extensions
- Type-safe extension handling with PHP 8.2+ enums
- Easy-to-use factory methods for creating extensions
- Encoding and decoding support for binary TLS data
- Support for both TLS 1.2 and TLS 1.3 extensions
- Comprehensive test coverage with 128 test cases

Installation
------------

[](#installation)

```
composer require tourze/tls-extension-naming
```

Supported Extensions
--------------------

[](#supported-extensions)

- **Server Name Indication (SNI)** - RFC 6066
- **Application-Layer Protocol Negotiation (ALPN)** - RFC 7301
- **Supported Versions** - RFC 8446 (TLS 1.3)
- **Signature Algorithms** - RFC 8446
- **Key Share** - RFC 8446 (TLS 1.3)
- **Supported Groups** - RFC 8446
- **Pre-Shared Key** - RFC 8446 (TLS 1.3)
- **Early Data** - RFC 8446 (TLS 1.3)
- **Extended Master Secret** - RFC 7627
- **Session Ticket** - RFC 5077
- And many more...

Quick Start
-----------

[](#quick-start)

### Using the Extension Factory

[](#using-the-extension-factory)

```
use Tourze\TLSExtensionNaming\ExtensionFactory;

// Create a Server Name extension
$sniExtension = ExtensionFactory::createServerName('example.com');

// Create an ALPN extension
$alpnExtension = ExtensionFactory::createALPN(['h2', 'http/1.1']);

// Create a Supported Versions extension
$versionsExtension = ExtensionFactory::createSupportedVersions([
    0x0304, // TLS 1.3
    0x0303  // TLS 1.2
]);

// Create a Signature Algorithms extension
$sigAlgsExtension = ExtensionFactory::createSignatureAlgorithms([
    0x0804, // rsa_pss_rsae_sha256
    0x0401  // rsa_pkcs1_sha256
]);

// Create a Key Share extension
$keyShareExtension = ExtensionFactory::createKeyShare([
    ['group' => 0x001d, 'key_exchange' => 'public_key_data_here']
]);
```

### Working with Extensions Directly

[](#working-with-extensions-directly)

```
use Tourze\TLSExtensionNaming\Extension\ServerNameExtension;
use Tourze\TLSExtensionNaming\Extension\ALPNExtension;

// Server Name Extension
$sni = new ServerNameExtension();
$sni->addServerName('example.com')
    ->addServerName('www.example.com');

// Encode to binary
$encoded = $sni->encode();

// Decode from binary
$decoded = ServerNameExtension::decode($encoded);

// ALPN Extension
$alpn = new ALPNExtension();
$alpn->addProtocol(ALPNExtension::PROTOCOL_HTTP_2)
     ->addProtocol(ALPNExtension::PROTOCOL_HTTP_1_1);
```

### Extension Types Enum

[](#extension-types-enum)

```
use Tourze\TLSExtensionNaming\Extension\ExtensionType;

// Access extension type values
$sniType = ExtensionType::SERVER_NAME->value; // 0x0000
$alpnType = ExtensionType::ALPN->value;       // 0x0010
$keyShareType = ExtensionType::KEY_SHARE->value; // 0x0033

// Get extension label
echo ExtensionType::SERVER_NAME->getLabel(); // "服务器名称指示"

// Get all registered extension types
$registeredTypes = ExtensionFactory::getRegisteredTypes();
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Extensions

[](#custom-extensions)

You can register custom extension types:

```
use Tourze\TLSExtensionNaming\ExtensionFactory;
use Tourze\TLSExtensionNaming\Extension\AbstractExtension;

class MyCustomExtension extends AbstractExtension {
    public function getType(): int {
        return 0x9999;
    }

    public function encode(): string {
        // Implementation
    }

    public static function decode(string $data): static {
        // Implementation
    }
}

// Register the custom extension
ExtensionFactory::registerExtension(0x9999, MyCustomExtension::class);
```

### Error Handling

[](#error-handling)

```
use Tourze\TLSExtensionNaming\Exception\UnknownExtensionTypeException;
use Tourze\TLSExtensionNaming\Exception\ExtensionEncodingException;

try {
    $extension = ExtensionFactory::create(0x9999, $data);
} catch (UnknownExtensionTypeException $e) {
    echo "Unknown extension type: " . $e->getMessage();
} catch (ExtensionEncodingException $e) {
    echo "Encoding error: " . $e->getMessage();
}
```

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Composer

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance65

Regular maintenance activity

Popularity8

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

331d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-tls-extension-naming/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-tls-extension-naming/health.svg)](https://phpackages.com/packages/tourze-tls-extension-naming)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
