Download the PHP package tourze/tls-crypto-curves without Composer
On this page you can find all versions of the php package tourze/tls-crypto-curves. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package tls-crypto-curves
TLS Crypto Curves
中文
A comprehensive elliptic curve cryptography library for TLS protocol support. This package provides secure implementations of various elliptic curves commonly used in TLS connections, including NIST standard curves and modern alternatives.
Features
- NIST Standard Curves: Complete support for P-256, P-384, and P-521 curves
- Modern Curves: X25519 and X448 curve implementations using Sodium
- Secure Key Management: Cryptographically secure key pair generation and public key derivation
- OpenSSL Integration: Native OpenSSL extension support for NIST curves
- Type Safety: Full PHP 8.1+ strict typing with comprehensive error handling
- Performance Optimized: Efficient implementations designed for cryptographic operations
- TLS Protocol Ready: Designed specifically for TLS handshake and key exchange
Installation
Requirements
- PHP 8.1 or higher
- OpenSSL extension
- Sodium extension (automatically provided via paragonie/sodium_compat)
Installation via Composer
Quick Start
Basic Usage with NIST P-256
Modern Curve25519 Usage
Working with Different Curves
Supported Curves
| Curve | Class | Key Size | Format | Security Level | Description |
|---|---|---|---|---|---|
| P-256 | NISTP256 |
256 bits | PEM | Standard | NIST prime256v1, widely supported |
| P-384 | NISTP384 |
384 bits | PEM | High | NIST secp384r1, enhanced security |
| P-521 | NISTP521 |
521 bits | PEM | Maximum | NIST secp521r1, highest security |
| X25519 | Curve25519 |
256 bits | Binary | Modern | Curve25519 for key exchange |
| X448 | Curve448 |
448 bits | Binary | High Modern | Curve448 for high-security applications |
Error Handling
All curve operations implement comprehensive error handling through the CurveException class:
API Reference
CurveInterface
All curve implementations follow the CurveInterface:
Available Methods
getName(): Returns the curve identifier stringgetKeySize(): Returns the key size in bitsgenerateKeyPair(): Generates a secure key pairderivePublicKey(string $privateKey): Derives public key from private key
Security Considerations
Key Management
- Always handle private keys securely and never log them
- Use appropriate curves for your security requirements
- Regenerate keys periodically in production environments
Implementation Security
- NIST curves use OpenSSL's cryptographically secure random number generation
- Modern curves (X25519, X448) use Sodium's secure implementations
- All operations include proper input validation and error handling
Best Practices
- Validate all input parameters before cryptographic operations
- Use constant-time operations where possible
- Follow your organization's key management policies
Performance Considerations
- NIST curves leverage OpenSSL's optimized implementations
- Modern curves benefit from Sodium's high-performance cryptography
- Key generation is computationally expensive - cache when appropriate
- Public key derivation is faster than key pair generation
Contributing
Please see CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
License
The MIT License (MIT). Please see License File for more information.
All versions of tls-crypto-curves with dependencies
ext-openssl Version *
paragonie/sodium_compat Version ^2.0
tourze/tls-common Version 0.0.*
tourze/tls-crypto-random Version 0.0.*