<?php
 declare(strict_types=1); namespace SpomkyLabs\Pki\CryptoBridge; use RuntimeException; use SpomkyLabs\Pki\CryptoBridge\Crypto\OpenSSLCrypto; use SpomkyLabs\Pki\CryptoTypes\AlgorithmIdentifier\Cipher\CipherAlgorithmIdentifier; use SpomkyLabs\Pki\CryptoTypes\AlgorithmIdentifier\Feature\SignatureAlgorithmIdentifier; use SpomkyLabs\Pki\CryptoTypes\Asymmetric\PrivateKeyInfo; use SpomkyLabs\Pki\CryptoTypes\Asymmetric\PublicKeyInfo; use SpomkyLabs\Pki\CryptoTypes\Signature\Signature; use function defined; abstract class Crypto { abstract public function sign( string $data, PrivateKeyInfo $privkey_info, SignatureAlgorithmIdentifier $algo ): Signature; abstract public function verify( string $data, Signature $signature, PublicKeyInfo $pubkey_info, SignatureAlgorithmIdentifier $algo ): bool; abstract public function encrypt(string $data, string $key, CipherAlgorithmIdentifier $algo): string; abstract public function decrypt(string $data, string $key, CipherAlgorithmIdentifier $algo): string; public static function getDefault(): self { if (defined('OPENSSL_VERSION_NUMBER')) { return new OpenSSLCrypto(); } throw new RuntimeException('No crypto implementation available.'); } } 